sim.getJointForce() in IK mode returns two signals

Typically: "How do I... ", "How can I... " questions
Post Reply
mikim
Posts: 3
Joined: 29 Mar 2025, 18:32

sim.getJointForce() in IK mode returns two signals

Post by mikim »

When I set up IK for a robot and later on I move the target from external python script and read the torques on joints using sim.getJointForce(), after plotting them it seems to have two different signals in it for each. The line looks like a noise on first glance, but it is because the two sinusoid-like signals overlap and the final line jumps between them. My knowledge of the mechanics isn't deep, but although the torque compensates the gravity and in addition it tries to move the joint to the desired position, I would expect for the signal to still be just one line and not oscilating between the pair.https://imgur.com/a/KzDriue

My question is, whether this behaviour is correct, what those two signals mean and whether it can be read separately using some other commands.
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: sim.getJointForce() in IK mode returns two signals

Post by coppelia »

Hello,

if you are using internal controllers for e.g. position or velocity control of a joint, you won't obtain meaningful forces/torques for that joint. Instead, you should use an inverse dynamics controller: have a look at the demo scene scenes/inverseDynamics.ttt

Cheers
Post Reply