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.17

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.17
File Size Uploaded Provenance Actions
mjviser-0.0.17.tar.gz 38.3 kB Without provenance Details for mjviser-0.0.17.tar.gz

Built distribution (wheel)

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

Total release size: 79.5 kB

Release files / mjviser-0.0.17.tar.gz

Download URL mjviser-0.0.17.tar.gz
Size 38.3 kB
Tags Source
SHA-256 checksum
How to use checksums
717530280d40eb73fb70792dcec1890176b922b9f7ed3d73a825d89fb3ace78f
BLAKE2b-256 checksum
How to use checksums
becfbc4c7a36e1ffb58925b2fa30cb10a9b0d40ac227a4dbcaa1d6d683d305a9
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.17-py3-none-any.whl

Download URL mjviser-0.0.17-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9aa372e8b6721d46a16ca28c0661fdc2182d353df127e70a8d6178eef5ba4aa
BLAKE2b-256 checksum
How to use checksums
c8a9282be843589b71e72ce1a34c6eec8e8db411b3d526e9e721b45a0657baa5
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.17

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