Skip to content

Conversation

@juan-g-bonilla
Copy link
Contributor

Description

  • Extend MuJoCo body support to cover translational-only bodies without a free joint:
    • Introduce an internal helper areJoints3DTranslation that detects when the first three scalar joints are sliders aligned with x, y, z.
    • Update MJBody::setPosition and MJBody::setVelocity to:
      • Use the free joint when present.
      • Otherwise drive the first three translational scalar joints when the body is a pure 3D translator.
      • Throw an explicit error if neither pattern is available (no free joint and no 3D translational joint chain).
  • Add joint inspection helpers on MJScalarJoint:
    • getAxis() to return the rotation axis for hinge joints or translation direction for slide joints.
    • isHinge() to distinguish rotational from translational joints.
    • Mark MJJoint::checkInitialized as const to support these const accessors.
  • Update tests and fixtures:
    • Replace the <freejoint/> in test_ball.xml with three orthogonal slide joints (ball_x, ball_y, ball_z).
    • In test_mass_update, set an initial position on ballBody to validate that the position can be set even through the body is not longer <freejoint/>.
  • Update release notes.

Verification

  • test_mass_update: confirms that the test passes with the 3-slider joint configuration and an arbitrary initial position set through MJBody::setPosition.

Documentation

Update release notes.

@juan-g-bonilla juan-g-bonilla self-assigned this Nov 25, 2025
@juan-g-bonilla juan-g-bonilla requested a review from a team as a code owner November 25, 2025 01:24
Copy link
Contributor

@Will-Schwend Will-Schwend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR! It will be excellent to support attitude free motion explicitly.

@schaubh schaubh self-requested a review November 25, 2025 18:43
@schaubh schaubh added the enhancement New feature or request label Nov 25, 2025
@schaubh schaubh added this to Basilisk Nov 25, 2025
@schaubh schaubh moved this to 👀 In review in Basilisk Nov 25, 2025
@juan-g-bonilla juan-g-bonilla force-pushed the feature/1194-pos-vel-translation-mujoco branch from c4c7779 to 0afadc2 Compare November 25, 2025 18:47
Copy link
Contributor

@schaubh schaubh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Just one small request to make MJJoint a hyperlink to the associated class in the release notes. Good to go after that change.

Copy link
Contributor

@schaubh schaubh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the unit tests just wrapped up running and I'm getting lots of errors from simulation/mujocoDynamics/NBodyGravity/_UnitTest/test_gravity.py?

@juan-g-bonilla
Copy link
Contributor Author

Actually, the unit tests just wrapped up running and I'm getting lots of errors from simulation/mujocoDynamics/NBodyGravity/_UnitTest/test_gravity.py?

This was the culprit:

void MJBody::setVelocity(const Eigen::Vector3d& velocity)
{
    if (this->freeJoint.has_value()) {
        this->freeJoint.value().setPosition(velocity);

I'll amend and ping you when everything passes.

@juan-g-bonilla juan-g-bonilla force-pushed the feature/1194-pos-vel-translation-mujoco branch from 0afadc2 to f3ea074 Compare November 25, 2025 22:19
@juan-g-bonilla juan-g-bonilla force-pushed the feature/1194-pos-vel-translation-mujoco branch from b17538c to 055f03b Compare November 26, 2025 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Support setting pos and vel of MuJoCo body with 3 slider joints

4 participants