Page 1 of 1

Torque mode control with Python in CoppeliaSim 4.3

Posted: 29 Jul 2022, 05:25
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.

Re: Torque mode control with Python in CoppeliaSim 4.3

Posted: 29 Jul 2022, 11:51
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?

Re: Torque mode control with Python in CoppeliaSim 4.3

Posted: 29 Jul 2022, 17:54
by realjsk
Yes, the same behavior with Lua.

Re: Torque mode control with Python in CoppeliaSim 4.3

Posted: 01 Aug 2022, 12:32
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

Re: Torque mode control with Python in CoppeliaSim 4.3

Posted: 02 Aug 2022, 18:43
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).

Re: Torque mode control with Python in CoppeliaSim 4.3

Posted: 03 Aug 2022, 12:28
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

Re: Torque mode control with Python in CoppeliaSim 4.3

Posted: 03 Aug 2022, 20:19
by realjsk
Thank you for the clarification. I highly appreciate it.