Cannot set joint's position even if it is in passive mode.

Typically: "How do I... ", "How can I... " questions
Post Reply
potatolige
Posts: 4
Joined: 09 Apr 2018, 10:31

Cannot set joint's position even if it is in passive mode.

Post by potatolige » 07 Dec 2018, 14:46

Hi my friend,

I am writing a plugin with C++ and working on a prismatic joint in force/torque mode. During the simulation, I want to reset this joint to its original position. But I could not do it even after I set it to passive mode.

My work flow and some simple code is described here:
0. The joint is in force/torque mode and has reached to a target velocity.

1. At the first time step, I set the joint's mode to passive, with simSetJointMode(joint_id, sim_jointmode_passive, 0).
( Then I Called simGetJointMode() and the return value is 0)

2. At the second time step, I set the joint's position to 0, with simSetJointPosition().

3. At the third time step, I set the joint's mode back to force/torque.
( Then I Called simGetJointMode() and the return value is 5)

After 1. and 2. , the position of the joint will not change, although the joint's mode has been changed to passive. I am using different time steps to do it because I think I should let the simulator or physics engine to response my settings step by step.

So, I think I may need some suggestions to explain why it does not work and how can I set a joint in force/torque mode to a enforced position.

potatolige
Posts: 4
Joined: 09 Apr 2018, 10:31

Re: Cannot set joint's position even if it is in passive mode.

Post by potatolige » 07 Dec 2018, 17:34

Hello,

I think I figure out what happened in my case.
So I just reply this question myself.

The problem is that if the joint has a dynamic object as a child, even if it is set to be a passive joint, the function simSetJointPosition(...) cannot work properly.

My solution is that firstly set the dynamic child object to be parentless and set joint position. After that, set the child object's parent back to the joint and reset the position/orientation of the child relative to the parent joint.

Post Reply