Skip to main content

mjc_viewer

PyPI Python Version PyPI version Open In Colab

mjc_viewer is a browser-based 3D viewer for MuJoCo that can render static trajectories from JSON.

Installation

The recommended way to install this package is via PyPI:

pip install mjc_viewer

Usage

import numpy as np
import mujoco
from mjc_viewer import Serializer, Trajectory

# Load your MuJoCo model.
model = mujoco.MjModel.from_xml_path("humanoid.xml")
data = mujoco.MjData(model)

# Create a Serializer and Trajectory instance.
serializer = Serializer(model)
trajectory = Trajectory(data)

# Simulate for 3 seconds.
trajectory.reset()
while data.time < 3.0:
    data.ctrl = np.random.uniform(*model.actuator_ctrlrange.T)
    mujoco.mj_step(model, data)
    trajectory.step()

html = serializer.render(trajectory)
with open("traj.html", "w") as f:
    f.write(html)
# You can now open traj.html in a browser or render in a notebook with
# `IPython.display.HTML`.

Todos

  • Robustify XML parser
  • Parse lights
  • Add support for meshes and height fields
  • Better default camera / light settings
  • Figure out plane reflection
  • Someday, make it interactive

Acknowledgements

mjc_viewer is heavily adapted from Brax's javascript viewer, full credit goes to its developers.

Metadata

Release files for mjc-viewer 0.0.5

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

Source distribution (sdist)

Source distribution for mjc-viewer 0.0.5
File Size Uploaded Provenance
mjc_viewer-0.0.5.tar.gz 19.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mjc-viewer 0.0.5
File Interpreter ABI Platform
mjc_viewer-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 40.1 kB

Release files / mjc_viewer-0.0.5.tar.gz

Download URL mjc_viewer-0.0.5.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dc0d9caad3444a8d6e20e40b8dc221c1533be809975672859da1b415494937bc
BLAKE2b-256 checksum
How to use checksums
e86aeef22e5564975fda4141b2cab4121f5364d4840ba99471514a0daccc3ba9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / mjc_viewer-0.0.5-py3-none-any.whl

Download URL mjc_viewer-0.0.5-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e901f60e3be3ccbf8528ab9d77d82bea8680e6a661181734748532fd752270e
BLAKE2b-256 checksum
How to use checksums
fdaae7af182a955159ade5c5067a57082e40efca6f0454f78a659b7d6432b4ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for mjc-viewer 0.0.5

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.

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