how to controll the opening of Rg2 gripper through python.

Typically: "How do I... ", "How can I... " questions
Post Reply
Wang
Posts: 10
Joined: 11 Jul 2022, 07:55

how to controll the opening of Rg2 gripper through python.

Post by Wang »

About controlling the opening and closing of Rg2 gripper through python.
The software version is 4.2.0 edu windows/ubuntu.
As a beginner, I hope to communicate with vrep through Python and use Python to send signals to control the opening and closing of Rg2 gripper (where Rg2 gripper is installed on UR3 or UR5 manipulator)
I found many codes on the Internet, but they can't work normally. Their software is 3.0+.
I want to ask you how to operate. Do you need to modify or delete all the Lua scripts automatically generated after importing ur and Rg2 models? How to deal with Python side. Yes get Rg2_ Openclosejoint and then call the simxsetjointmaxforce and simxsetjointtargetvelocity functions?
The error is reported below: External call to simCallScriptFunction failed (rg2Open@RG2): Failed calling script function.
Thanks a lot

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: how to controll the opening of Rg2 gripper through python.

Post by coppelia »

Hello,

from an external application, e.g. from an external Python script, best is to use the ZeroMQ remote API. From there you can then easily call any CoppeliaSim script function with sim.callScriptFunction (e.g. in the called function you can open/close the gripper). You could also simply use sim.setInt32Signal from Pyhon, and react to it in CoppeliaSim with sim.getInt32Signal. There are many different possibilities.

If you look at the RG2 model, you will see:

Code: Select all

function sysCall_actuation()
    local v=-motorVelocity
    local data=sim.getInt32Signal('RG2_open')
    if data and data~=0 then
        v=motorVelocity
    end
    sim.setJointTargetForce(motorHandle,motorForce)
    sim.setJointTargetVelocity(motorHandle,v)
end
so from your external application, simply set the RG2_open int32 signal to 0 or 1.

Cheers

Wang
Posts: 10
Joined: 11 Jul 2022, 07:55

Re: how to controll the opening of Rg2 gripper through python.

Post by Wang »

非常感谢您的回复 我的问题已经得到解决。
Thank you very much for your reply. My problem has been solved.

Post Reply