Skip to content

Add MuJoCo-style body selection and perturbation. - #21

Merged
kevinzakka merged 1 commit into
mainfrom
kz/interactive-perturbation
Oct 31, 2026
Merged

kevinzakka merged 1 commit into
mainfrom
kz/interactive-perturbation

Conversation

@kevinzakka

@kevinzakka kevinzakka commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Click a body to select it, Cmd/Ctrl+right-drag to move it, and Cmd/Ctrl+left-drag to rotate it. Hold Shift for the horizontal plane. Everything except the input goes through MuJoCo's own mjv_* perturbation functions, so it behaves like simulate. MuJoCo's translation connector is hidden for now because viser always draws its own drag arrow.

@kevinzakka
kevinzakka force-pushed the kz/interactive-perturbation branch from a59ff07 to d73aed2 Compare June 10, 2026 21:28
@kevinzakka
kevinzakka marked this pull request as ready for review June 10, 2026 21:28
@Flova

Flova commented Jun 14, 2026

Copy link
Copy Markdown

I am very much looking forward to this. Are there plans to integrate an xy plane drag that allows the robot to be repositioned without changing its height or rotation? Other simulators features this and I think it is also missing from the official mujoco viewer.

@kevinzakka

Copy link
Copy Markdown
Contributor Author

@Flova it actually does exist in the native viewer but it's modifier-gated. Ctrl+(right-drag) translates in the vertical plane (mjMOUSE_MOVE_V) and Ctrl+Shift+(right-drag) is a horizontal-plane move (mjMOUSE_MOVE_H).

The blocker is on the viser side, not MuJoCo: viser only projects the cursor onto a camera-aligned plane and freezes the drag modifier at drag-start, so we can't reproduce the "Shift switches to the world-horizontal plane mid-drag" behavior. We'd need viser to expose the drag-plane normal (or allow live modifiers during a drag).

cc @brentyi

@brentyi

brentyi commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Live modifiers: doable!
Drag-plane normal: this is also possible to support natively in Viser, but seems [initially] implementable without? In the mjviser callback, we can take the camera-aligned drag vector and add some modifier-conditioned projection logic.

@Flova

Flova commented Jun 17, 2026

Copy link
Copy Markdown

@Flova it actually does exist in the native viewer but it's modifier-gated. Ctrl+(right-drag) translates in the vertical plane (mjMOUSE_MOVE_V) and Ctrl+Shift+(right-drag) is a horizontal-plane move (mjMOUSE_MOVE_H).

Maybe I am missing something, but I tried this in the native viewer and while the force vector stays in the plane, it only applies a sidewards force, which is not that great if you e.g. want to reposition a humanoid in a (maybe also stopped) simulator without messing with its stability. Webots for example supports both force/torque based interaction and "absolute" changing of the environment relative to the ground plane. It would be really great to have a feature like this for higher level robot behavior tests with mujoco.

@kevinzakka
kevinzakka force-pushed the kz/interactive-perturbation branch from e2f41dd to 39da3b4 Compare October 31, 2026 23:07
@kevinzakka kevinzakka changed the title Add keyboard shortcuts, body selection, and drag perturbation Add MuJoCo-style body selection and perturbation. Oct 31, 2026
@kevinzakka
kevinzakka merged commit 784a8dc into main Oct 31, 2026
6 checks passed
@kevinzakka
kevinzakka deleted the kz/interactive-perturbation branch October 31, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants