Hi,
I want to control RG2 directly through the zmqRemoteApi in python, rather than indirectly through functions in scripts.
First, I get the Handle of openCloseJoint through motorHandle=sim.getObject('./openCloseJoint').
Then, I use sim.setJointTargetForce(motorHandle,20) and sim.setJointTargetVelocity(motorHandle,-0.05) to close the RG2.
I printed motorHandle in script and python separately, and the result was the same:57.
However, When python executes sim.setJointTargetForce(motorHandle,20) and sim.setJointTargetVelocity(motorHandle,-0.05), nothing happens to RG2.
So I want to know how I can achieve my goal.
Thank a lot!
How to control RG2 without using a script?
Re: How to control RG2 without using a script?
Hello,
are you sure the simulation is running? If not, then nothing will happen, since those instructions are forwarded to the physics engine (and the physics engine is only initialized after simulation started).
Cheers
are you sure the simulation is running? If not, then nothing will happen, since those instructions are forwarded to the physics engine (and the physics engine is only initialized after simulation started).
Cheers
-
- Posts: 19
- Joined: 20 Jun 2022, 07:05
Re: How to control RG2 without using a script?
Hi,
I am sure that my simulation is running, becasure my UR5 in scene can move to target position.
I recreated a simple scene with just one RG2, and the python code is follow:
Please help me point out the problem.
Thaks a lot.
I am sure that my simulation is running, becasure my UR5 in scene can move to target position.
I recreated a simple scene with just one RG2, and the python code is follow:
- from zmqRemoteApi import RemoteAPIClient
import os
if __name__ == '__main__':
client = RemoteAPIClient()
sim = client.getObject('sim')
sim.loadScene('G:/PHD_PROJECT/coppeliasim_scene/111.ttt')
rg2 = sim.getObject('./RG2')
motorHandle = sim.getObject('./openCloseJoint')
centerJoint = sim.getObject('./centerJoint')
client.setStepping(True)
sim.startSimulation()
motorVelocity = 0.05
motorForce = 20
v = -motorVelocity
sim.setJointTargetForce(motorHandle, motorForce)
sim.setJointTargetVelocity(motorHandle, v)
sim.stopSimulation()
Please help me point out the problem.
Thaks a lot.
Re: How to control RG2 without using a script?
Calling:
will require you to call for each simulation step:
Make sure to have a look at the simple example in programming/zmqRemoteApi/client/python/simpleTest.py
Cheers
Code: Select all
client.setStepping(True)
Code: Select all
client.step()
Cheers
-
- Posts: 19
- Joined: 20 Jun 2022, 07:05
Re: How to control RG2 without using a script?
Hi,
Thank you very much, and it can work now!
Thanks!
Thank you very much, and it can work now!
Thanks!