Skip to content

Add keyboard shortcuts, body selection, and drag perturbation#21

Draft
kevinzakka wants to merge 2 commits into
mainfrom
kz/interactive-perturbation
Draft

Add keyboard shortcuts, body selection, and drag perturbation#21
kevinzakka wants to merge 2 commits into
mainfrom
kz/interactive-perturbation

Conversation

@kevinzakka
Copy link
Copy Markdown
Contributor

WIP. Interactive features to bring the viewer closer to MuJoCo simulate.

Keyboard shortcuts for simulation control (space=pause, N=step, backspace=reset) and visualization toggles (C=contacts, F=forces, J=joints, I=inertia, V=tendons, M=COM, U=actuators, T=constraints). Camera selection via dropdown. Speed control is command-palette only to avoid clashing with viser's built-in camera keys (WASD, QE, arrows).

Click a body to select it (ray cast via mj_ray). Cmd/Ctrl+drag applies a translational spring force, Cmd/Ctrl+Shift+drag applies torque. The force model uses MuJoCo's critically-damped spring scaled by body mass (from body_invweight0), with velocity damping via finite difference. Hover highlighting comes from viser automatically when on_click is registered.

Known issue: viser collapses Cmd and Ctrl into a single "cmd/ctrl" modifier, so on macOS both Cmd+drag and Ctrl+drag activate perturbation. Ctrl+drag also triggers the browser's context menu (macOS translates Ctrl+left-click to right-click). Ideally only Cmd would match on Mac. This needs a viser-side change to support separate "meta" and "ctrl" modifiers.

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.

2 participants