Skip to main content

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 to mujoco.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 to scene.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 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

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.1.tar.gz (25.2 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.1-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mjviser-0.0.1.tar.gz
  • Upload date:
  • Size: 25.2 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.1.tar.gz
Algorithm Hash digest
SHA256 15720037b292d1b6085b46cc656028052f2c18e9fb5218accaa8cc3d0be26970
MD5 72769973c38405408925a4113a910367
BLAKE2b-256 c8d5f27bf7d1b1ff64ae61785e97e73bb8082c531d4eaa4a2230ba0fe7686215

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mjviser-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 27.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d93ddd24b3c528a637491386fca71d87d4dd8732fcf724772b9d139b421595d5
MD5 17bf4e401591fae5a3a79230d3983101
BLAKE2b-256 522c6efb8a4b67b289f5754c4e69123f30ceaa02c19443698dcb792ad41e5d0f

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