Spotted while reviewing #7028.
In WbBallJoint::prePhysicsStep(), the torque-control branch (userControl()) calls:
dJointAddAMotorTorques(mJoint, -rm->rawInput(), 0.0, 0.0);
It does the same for rm2 and rm3. But for a BallJoint, mJoint is the dBallJoint created in setJoint(), not the AMotor (mControlMotor).
- In debug builds, this trips
checktype() in dJointAddAMotorTorques().
- In release builds, the ball joint's memory is read as a
dxJointAMotor, so the applied torques are undefined.
Expected: wb_motor_set_torque() on a BallJoint motor applies the torque about the corresponding AMotor axis.
Notes for the fix:
- Pass
mControlMotor instead of mJoint.
dJointAddAMotorTorques() asserts that the AMotor isn't reversed (dJOINT_REVERSE). That's exactly the case when the BallJoint's parent solid has no physics, so it needs separate handling.
Spotted while reviewing #7028.
In
WbBallJoint::prePhysicsStep(), the torque-control branch (userControl()) calls:It does the same for
rm2andrm3. But for a BallJoint,mJointis thedBallJointcreated insetJoint(), not the AMotor (mControlMotor).checktype()indJointAddAMotorTorques().dxJointAMotor, so the applied torques are undefined.Expected:
wb_motor_set_torque()on a BallJoint motor applies the torque about the corresponding AMotor axis.Notes for the fix:
mControlMotorinstead ofmJoint.dJointAddAMotorTorques()asserts that the AMotor isn't reversed (dJOINT_REVERSE). That's exactly the case when the BallJoint's parent solid has no physics, so it needs separate handling.