Skip to content

BallJoint torque control applies AMotor torques to the ball joint instead of the AMotor #7029

Description

@omichel

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions