Web-based MuJoCo viewer powered by viser.
Project description
mjviser
Web-based MuJoCo viewer powered by viser.
Quick start
View any MuJoCo model instantly, no install needed:
uvx mjviser path/to/model.xml
Or install and use:
pip install mjviser
mjviser path/to/model.xml
Fuzzy path matching finds models in the current directory tree:
mjviser humanoid # finds **/humanoid*.xml
mjviser shadow_hand # finds **/shadow_hand*.xml
When there's a single match it's used automatically. Multiple matches show a numbered list to pick from.
Python API
import mujoco
from mjviser import Viewer
model = mujoco.MjModel.from_xml_path("robot.xml")
data = mujoco.MjData(model)
Viewer(model, data).run()
Open the printed URL in your browser. You get pause/resume, speed controls, single-stepping, reset, keyframe selection, joint sliders, and actuator sliders out of the box.
Extension points
The Viewer accepts three callbacks for injecting custom logic:
-
step_fn(model, data): Called each simulation step. Use this to apply a controller, external forces, or any per-step logic. Defaults tomujoco.mj_step. -
render_fn(scene): Called each render frame. Use this to push custom state to the scene, add ghost overlays, or render debug geometry. Defaults toscene.update_from_mjdata(data). -
reset_fn(model, data): Called on reset. Use this to restore custom simulation state.
For full control over the loop, use ViserMujocoScene directly. The server is a standard viser server, so you can add custom GUI elements, scene overlays, or anything else viser supports.
server = viser.ViserServer()
scene = ViserMujocoScene(server, model, num_envs=1)
scene.create_visualization_gui()
# Add your own GUI.
with server.gui.add_folder("My Controls"):
slider = server.gui.add_slider("Force", min=0, max=100, initial_value=0)
while True:
mujoco.mj_step(model, data)
scene.update_from_mjdata(data)
Examples
active_viewer.py: simplest usage with playback controlsactive_viewer_with_controller.py: customstep_fnwith random torquespassive_viewer.py: manual simulation loop withViserMujocoScenemulti_env.py: 4 humanoids in parallel via mujoco-warpghost_overlay.py: customrender_fnthat overlays a time-delayed ghostmotion_playback.py: recorded trajectory with timeline scrubber, speed control, and contact replay
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mjviser-0.0.2.tar.gz.
File metadata
- Download URL: mjviser-0.0.2.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eb001523b1b5dd58b2ff1de610a47a3200375e5527c10f79085cbbfc81b83f4
|
|
| MD5 |
e78bb5df55bc14b92be2c9a5372f636a
|
|
| BLAKE2b-256 |
bfb0548020e028fba2245862b404bb2a48aaf9c1efc2f0e42a87c07688d3542c
|
File details
Details for the file mjviser-0.0.2-py3-none-any.whl.
File metadata
- Download URL: mjviser-0.0.2-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cab1fa59f21ce1cc2944684e4975daeabc8eeece1893564c7025dc281dfd1d02
|
|
| MD5 |
63e4f17f06e4f0ea7efaec55ce526035
|
|
| BLAKE2b-256 |
095a19e078e19578ceeabf6976c45394b5c922722fb5e0ef60d52e8726ec7e6a
|