[ODE] possible bug regarding dJointAddHingeTorque and dJOINT_REVERSE

Martin C. Martin martin at metahuman.org
Mon Jan 19 11:09:22 MST 2004


 > In the code for dJointAddHingeTorque, it checks dJOINT_REVERSE to 
determine
 > the sign of the torque to be added.  Is this really correct?

I'm the one who wrote dJointAddHingeTorque(), and it's correct. 
dJOINT_REVERSE gets set when the joint is created.  Internally, if one 
body is NULL and the other non-null, ODE always wants body2 to be NULL. 
  That saves a lot of parallel code in the engine.  So, if you create a 
joint where body1 is null and body2 is non-null, ODE will store them in 
the opposite order and set dJOINT_REVERSE.  Then, any operation that the 
user says to do to body2, ODE must actually do it to body1.

> This means
> that depending on the argument order of dJointAttach (which determines the
> state of dJOINT_REVERSE), that the same call to dJointAddHingeTorque can
> cause joint motion in opposite directions.

I'm not quite sure what you're getting at, but ODE does the right thing. 
   From the docs:

dJointAddHingeTorque(dJointID joint, dReal torque)

Applies the torque about the hinge axis. That is, it applies a torque 
with magnitude torque, in the direction of the hinge axis, to body 1, 
and with the same magnitude but in opposite direction to body 2. This 
function is just a wrapper for dBodyAddTorque()

So reversing the role of body1 and body2 should reverse the motion.

- Martin



More information about the ODE mailing list