Torque mode control with Python in CoppeliaSim 4.3

Typically: "How do I... ", "How can I... " questions
Post Reply
realjsk
Posts: 25
Joined: 21 Dec 2013, 03:59

Torque mode control with Python in CoppeliaSim 4.3

Post by realjsk »

I am trying to control UR5 robot in torque mode with a Python main script in CoppeliaSim 4.3. I dragged the UR5 robot into the main scene, changed all 6 joints from position to force mode, and replaced the (default) main Lua script with a Python code. Then I tried to play with the torque passed to the first joint while setting the other joint torques to zero (using sim.setJointTargetForce, remember I am using Python). Regardless of the sign of the passed torque value (e.g., +50 or -50), the joint kept rotating in the same direction. The documentation (https://coppeliarobotics.com/helpFiles/ ... tForce.htm) states that the function takes a signed value. However, I am not sure if that's still the case for Python (nothing is specified under "Python
synopsis"). If the Python function doesn't take a signed value, how can I solve the problem? Thanks.

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Torque mode control with Python in CoppeliaSim 4.3

Post by fferri »

Hi,

you mention that is a Python embedded script.
Does the same happen with a Lua script that does exactly the same things?

realjsk
Posts: 25
Joined: 21 Dec 2013, 03:59

Re: Torque mode control with Python in CoppeliaSim 4.3

Post by realjsk »

Yes, the same behavior with Lua.

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

Re: Torque mode control with Python in CoppeliaSim 4.3

Post by coppelia »

Hello,

yes, this is a known bug of one of the latest revisions. This will be fixed in the next revision/version. In the mean time, simply use the velocity mode, and set the velocity to a larger value (e.g. 999) and the modulate the force/torque. This has the same effect.

Cheers

realjsk
Posts: 25
Joined: 21 Dec 2013, 03:59

Re: Torque mode control with Python in CoppeliaSim 4.3

Post by realjsk »

Thank you for your response. Your suggested solution did the trick. However, I noticed another strange behavior. The torque read by function sim.getJointForce is always the opposite of that set by sim.setJointTargetForce (same magnitude but opposite sign).

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

Re: Torque mode control with Python in CoppeliaSim 4.3

Post by coppelia »

Yes, that is normal, it is a matter of perspective, whether you sit at the joint or load location: the force you read is acting on the joint. The force you set, acts on its load.

Cheers

realjsk
Posts: 25
Joined: 21 Dec 2013, 03:59

Re: Torque mode control with Python in CoppeliaSim 4.3

Post by realjsk »

Thank you for the clarification. I highly appreciate it.

Post Reply