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

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.4.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

mjc_viewer-0.0.4-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mjc_viewer-0.0.4.tar.gz
  • Upload date:
  • Size: 18.0 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.4.tar.gz
Algorithm Hash digest
SHA256 7ec87521c93e7980544fad54128fc1a1162908f8a4c308844f8c0532fcce4163
MD5 dbec58580ac3506b9f7bcf812ae4af77
BLAKE2b-256 b4c7aa3fb01e069b3de9e57aa84129279d13d6a6863d7cbb037293ffdfe3825b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mjc_viewer-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 20.4 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 90beb610a66eb71098b7bd05481719fbee9643d566d62a174a4cacdd3cb60b6d
MD5 a35874158a67bd6ffcd2efc14b3151b9
BLAKE2b-256 1f28dd9982367f1b7d3be3782916ddc09eebfb9f5462ceeef7682d5fd02622ac

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