Skip to main content

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

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)

Mouse and keyboard

Viewer follows MuJoCo's simulate:

  • Click a body to select it, and click empty space to deselect. Cmd/Ctrl+click is more reliable, since it keeps the camera still.
  • Cmd/Ctrl + right-drag moves the selected body and Cmd/Ctrl + left-drag rotates it. Hold Shift for the horizontal plane; it can be toggled mid-drag.
  • While running, the body is pulled by a spring. While paused, it is posed directly.
  • Keyboard shortcuts match simulate where viser allows (Space, Backspace, C, F, J, 0-5, and more). Every command is listed in viser's command palette.

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.

Metadata

Release files for mjviser 0.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mjviser 0.0.16
File Size Uploaded Provenance Actions
mjviser-0.0.16.tar.gz 38.3 kB Without provenance Details for mjviser-0.0.16.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mjviser 0.0.16
File Interpreter ABI Platform Actions
mjviser-0.0.16-py3-none-any.whl Python 3 none any Details for mjviser-0.0.16-py3-none-any.whl

Total release size: 79.5 kB

Release files / mjviser-0.0.16.tar.gz

Download URL mjviser-0.0.16.tar.gz
Size 38.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fe8042eb1e97edbb310ac46e72e61d986b4dbe92048ef3c7a4598d2efe60ca53
BLAKE2b-256 checksum
How to use checksums
5d3946ce93815f3322feb3c096f25a54f0d4112dd708c2708dfcfeef1754001f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mjviser-0.0.16-py3-none-any.whl

Download URL mjviser-0.0.16-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f50ea07ec4f35749eb9fd0470e921bc5ce6b8ae449926888c35fe8800ef3c8a0
BLAKE2b-256 checksum
How to use checksums
7b17cdbdfc6cf84867286f8a845f2e283e6c45c4a27260be20679dc8a2e12f8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for mjviser 0.0.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page