Add SetEqualityActive service for runtime equality (weld) toggle#1
Merged
Conversation
Exposes ~/set_equality_active service so external nodes can enable or disable an MJCF <equality> at runtime by name. Primary use case: weld constraints between a gripper jaw and a graspable object, toggled on close / off on open so the object follows the gripper rigidly during pick-and-place tasks without depending on contact friction. The runtime enable flag lives on mj_data->eq_active, NOT mj_model->eq_active0 (which is only the initial value from XML). Crucially: for mjEQ_WELD, activation with a non-matching XML-default relpose applies a large impulse to satisfy the compiled relpose. The service takes an optional relpose_from_current flag — when set with active=true on a weld, the callback reads body1/body2 current world poses, computes relpose = body1^-1 * body2 via mju_negPose + mju_mulPose, and writes it into mj_model->eq_data[id*mjNEQDATA + 3..9] before flipping eq_active. The weld then locks the present configuration with zero residual and zero activation impulse. References: google-deepmind/mujoco#2323 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Exposes a new
~/set_equality_activeservice so external nodes can enable or disable an MJCF<equality>at runtime by name.Primary use case: weld constraints between a gripper jaw and a graspable object, toggled on close / off on open so the object follows the gripper rigidly during pick-and-place tasks without depending on contact friction. This is a common pattern in MuJoCo manipulation environments.
Service definition
The
relpose_from_currentflag is critical for welds. Without it, activating a weld at runtime applies a large impulse because the constraint solver tries to enforce the XML-default relative pose (compiled intomj_model->eq_dataat load time), not the current pose between the bodies. When this flag is true on activation and the equality type ismjEQ_WELD, the callback:body1andbody2frommj_data->xpos/xquat.relpose = body1^-1 * body2viamju_negPose+mju_mulPose.mj_model->eq_data[id*mjNEQDATA + 3..9](positions at 3..5, quat at 6..9 formjEQ_WELD).mj_data->eq_active[id] = 1.The weld then locks the present configuration with zero residual and zero activation impulse.
The runtime enable flag lives on
mj_data->eq_active, NOTmj_model->eq_active0(which is only the initial value from XML).References
eq_data.<weld>.Test plan
ros2 service call /mujoco_node/set_equality_active mujoco_ros2_control_msgs/srv/SetEqualityActive "{equality_name: '<name>', active: false, relpose_from_current: false}"returnssuccess=falsewith "not found" when the equality doesn't exist.success=trueand the constraint deactivates (verified by absence of impulse).relpose_from_current: truewhile body1 and body2 are at arbitrary current poses produces no impulse and locks the current relative pose (verified visually insimulate).sim_mutex_so it doesn't race against the physics loop.Downstream consumers
pathon_so101PR Reuse the logger with get_logger method ros-controls/mujoco_ros2_control#28 — adds<weld>blocks per spawned YCB object inscene_generator.py.pathon_vlgraspingPR [Jazzy] Added capability to provide a key frame as starting configuration ros-controls/mujoco_ros2_control#4 —control_grippercalls this service on close (activate with snapshot) and open (deactivate).🤖 Generated with Claude Code