Regular API function

simGetJointForce / sim.getJointForce

Description Retrieves the force or torque applied to a joint along/about its active axis. This function retrieves meaningful information only if the joint is prismatic or revolute, and is dynamically enabled. With the Bullet engine, this function returns the force or torque applied to the joint motor (torques from joint limits are not taken into account). With the ODE and Vortex engine, this function returns the total force or torque applied to a joint along/about its z-axis. See also sim.setJointTargetForce and sim.readForceSensor.
C/C++
synopsis
simInt simGetJointForce(simInt jointHandle,simFloat* forceOrTorque)
C/C++
parameters
jointHandle: handle of the joint. Can be combined with sim.handleflag_rawvalue (simply add sim.handleflag_rawvalue to jointHandle), if you wish to access the raw values generated by each individual dynamic simulation step (by default, there are 10 dynamic simulation steps for each simulation step). Raw values can only be accessed from inside a callback function triggered by the physics engine.
forceOrTorque: the force or the torque applied to the joint along/about its z-axis.
C/C++
return value
-1 if operation was not successful. 0 if no value is available yet (e.g. when simHandleDynamics hasn't yet handled that joint), otherwise a value >0.
Lua
synopsis
float forceOrTorque=sim.getJointForce(int jointHandle)
Lua
parameters
Similar to the C-function counterpart
Lua
return values
forceOrTorque: the force or the torque applied to the joint along/about its z-axis, or nil if no value is available yet.
Python
synopsis
float forceOrTorque=sim.getJointForce(int jointHandle)