Skip to main content

A browser-based 3D viewer for MuJoCo

Project description

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.

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

mjc_viewer-0.0.5.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

mjc_viewer-0.0.5-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file mjc_viewer-0.0.5.tar.gz.

File metadata

  • Download URL: mjc_viewer-0.0.5.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for mjc_viewer-0.0.5.tar.gz
Algorithm Hash digest
SHA256 dc0d9caad3444a8d6e20e40b8dc221c1533be809975672859da1b415494937bc
MD5 825def33527450296daf07dc765154c3
BLAKE2b-256 e86aeef22e5564975fda4141b2cab4121f5364d4840ba99471514a0daccc3ba9

See more details on using hashes here.

File details

Details for the file mjc_viewer-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: mjc_viewer-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for mjc_viewer-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4e901f60e3be3ccbf8528ab9d77d82bea8680e6a661181734748532fd752270e
MD5 0e3e288bd70372907e6b7825f6c6ac3a
BLAKE2b-256 fdaae7af182a955159ade5c5067a57082e40efca6f0454f78a659b7d6432b4ea

See more details on using hashes here.

Supported by

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