Welcome to mjswan!¶
Real-time Interactive AI Robot Simulation in Your Browser
What is mjswan?¶
mjswan is a powerful framework for creating interactive MuJoCo simulations with real-time policy control, running entirely in the browser. Built on top of mujoco wasm, onnxruntime, and three.js, it enables easy sharing of AI robot simulation demos as static sites, perfect for GitHub Pages hosting.
Key Features¶
-
Real-time Simulation
Run MuJoCo simulations and policy control in real time
-
Interactive
Change the state of objects by applying forces with intuitive controls
-
Client-only
All computation runs in the browser - no server required for simulation
-
Easy Sharing
Host as a static site for effortless demo distribution (e.g., GitHub Pages)
-
Cross-platform
Works seamlessly on desktop, mobile, and VR devices
-
Portable
Embed the simulation in any web page or Google Colab notebook output cell
Use Cases¶
mjswan is perfect for:
- Research Demos: Share your robot learning research with interactive visualizations
- Education: Create interactive physics and robotics tutorials
- Prototyping: Quickly test and visualize different MuJoCo models and policies
- Portfolio: Showcase your robotics projects in an accessible way
Live Demos¶
- Main Demo - Main mjswan demos
- MyoSuite - Musculoskeletal models
- MuJoCo Menagerie - Various high-quality robot models
- MuJoCo Playground - Interactive environments
Quick Example¶
import mujoco
import mjswan
builder = mjswan.Builder()
project = builder.add_project(name="My Robot")
spec = mujoco.MjSpec.from_string("""
<mujoco>
<worldbody>
<light diffuse=".5 .5 .5" pos="0 0 3" dir="0 0 -1"/>
<geom type="plane" size="1 1 0.1" rgba=".9 0 0 1"/>
<body pos="0 0 1">
<joint type="free"/>
<geom type="box" size=".1 .2 .3" rgba="0 .9 0 1"/>
</body>
</worldbody>
</mujoco>
""")
project.add_scene(spec=spec, name="My Scene")
app = builder.build()
app.launch()
See Examples for a walkthrough and more patterns.
Links¶
License¶
mjswan is licensed under the Apache-2.0 License.