Skip to main content

Web-based MuJoCo viewer powered by viser.

Project description

mjviser

GitHub Actions License PyPI

A web-based MuJoCo viewer built on Viser.

Quick start

Run it directly with uvx (nothing to install):

uvx mjviser path/to/model.xml

Or pip install mjviser and run mjviser path/to/model.xml.

mjviser also does fuzzy path matching against the current directory:

mjviser humanoid        # finds **/humanoid*.xml
mjviser shadow_hand     # finds **/shadow_hand*.xml

Use --port to bind to a specific port (default: 8080):

mjviser model.xml --port 7070

If robot_descriptions is available, you can load any of its 57 MuJoCo models by name:

uvx --with robot_descriptions mjviser go1

[!NOTE] uvx defaults to the system Python and may not respect requires-python constraints (astral-sh/uv#8206). If your system Python is 3.14+, where MuJoCo can't build yet, pass -p 3.13 explicitly: uvx -p 3.13 mjviser path/to/model.xml.

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 most of what the native MuJoCo viewer offers: simulation controls, joint and actuator sliders, contact and force visualization, camera tracking, keyframes, and more.

Extension points

Viewer accepts three optional callbacks:

  • step_fn(model, data): called each simulation step. Defaults to mujoco.mj_step.
  • render_fn(scene): called each render frame. Defaults to scene.update_from_mjdata(data).
  • reset_fn(model, data): called on reset.

For full control, use ViserMujocoScene directly. The server is a standard Viser server, so you can add GUI elements, scene overlays, or anything else Viser supports.

server = viser.ViserServer()
scene = ViserMujocoScene(server, model, num_envs=1)
scene.create_visualization_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 controls
  • active_viewer_with_controller.py: custom step_fn with random torques
  • passive_viewer.py: manual simulation loop with ViserMujocoScene
  • multi_env.py: 4 humanoids in parallel via mujoco-warp
  • ghost_overlay.py: custom render_fn that overlays a time-delayed ghost
  • motion_playback.py: recorded trajectory with timeline scrubber, speed control, and contact replay

Acknowledgments

Thanks to Matija Kecman for early feedback and suggestions.

Limitations

  • No mouse interaction: clicking/dragging bodies and keyboard callbacks require upstream Viser support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mjviser-0.0.9.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mjviser-0.0.9-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file mjviser-0.0.9.tar.gz.

File metadata

  • Download URL: mjviser-0.0.9.tar.gz
  • Upload date:
  • Size: 29.0 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

Hashes for mjviser-0.0.9.tar.gz
Algorithm Hash digest
SHA256 ff2c5d477c360738b8b0df1c891e79aaaf8db880843f93b219727c92a52dc05f
MD5 f6b8c9cb53e55e84230ea6ea57a0fd17
BLAKE2b-256 57b4343a19e914b1a5a18b12a2852a4a78d40beeebf7d6d9ccf43f08c51cbb18

See more details on using hashes here.

File details

Details for the file mjviser-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: mjviser-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 31.5 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

Hashes for mjviser-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 19a1a27f17ddf10bde513a8d77222b4c1d02c8cacf61e3e581a877d6361a1049
MD5 33132f6bbadba8021a272bf9bfed6e95
BLAKE2b-256 3b34cba1de59a799100c084f7614b93ae7921ba14db609e04c274f90e21c405e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page