mujoco: Implement AttachFixedJointFeature and DetachJointFeature#1001
Merged
Conversation
- Implemented `AttachFixedJoint` using MuJoCo equality weld constraints. - Optimized `AttachFixedJoint` and `DetachJoint` to reuse and toggle constraints (`active = 0/1`) to avoid expensive `mjModel` recompilations. - Implemented `CastToFixedJoint` to identify fixed joints. - Added comprehensive unit tests in `detachable_joint.cc`. Generated-by: Gemini 3.1 Pro Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
iche033
reviewed
Jun 9, 2026
| const char *n1 = mjs_getString(eqSpec->name1); | ||
| const char *n2 = mjs_getString(eqSpec->name2); | ||
| if (!n1 || !n2 || std::string_view(childBodyName) != n1 || | ||
| std::string_view(parentBodyName) != n2) |
Contributor
There was a problem hiding this comment.
do you need to check if childBodyName / parentBodyName are null?
Contributor
Author
There was a problem hiding this comment.
I don't think it's possible to have a body without a name. It's assigned immediately after creation:
Do you think we should still add the extra check?
Contributor
There was a problem hiding this comment.
Mainly because I saw the use of std::string_view which does not work well with nullptr. Yeah if mjs_getString(mjs_getName(childLinkInfo->body->element)) never returns null then I think it should be fine.
Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
iche033
approved these changes
Jun 10, 2026
shameekganguly
pushed a commit
that referenced
this pull request
Jun 26, 2026
* mujoco: Implement AttachFixedJointFeature and DetachJointFeature - Implemented `AttachFixedJoint` using MuJoCo equality weld constraints. - Optimized `AttachFixedJoint` and `DetachJoint` to reuse and toggle constraints (`active = 0/1`) to avoid expensive `mjModel` recompilations. - Implemented `CastToFixedJoint` to identify fixed joints. - Added comprehensive unit tests in `detachable_joint.cc`. Generated-by: Gemini 3.1 Pro --------- Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎉 New feature
Part of #299
Summary
AttachFixedJointusing MuJoCo equality weld constraints.AttachFixedJointandDetachJointto reuse and toggle constraints (active = 0/1) to avoid expensivemjModelrecompilations.CastToFixedJointto identify fixed joints.detachable_joint.cc.Test it
Screenshot
Orbital Centrifuge Target Game (gist
detachable_joint_space.sdf)A physics-based timing game in Gazebo Sim using the MuJoCo plugin. Players must trigger the detach command at the perfect millisecond to launch the rotating payloads through the target gate.
Note: Developing this demo exposed a reset bug where dynamic weld constraints failed to update their relative offsets after a simulation reset. The recording demonstrates that this is now resolved and working properly.
Checklist
codecheckpassed (See contributing)Generated-by: Gemini 3.1 Pro
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.