GPU-accelerated physics simulation for the SO-ARM100 robotic arm using MuJoCo.
This project demonstrates GPU-based rendering and physics simulation of the SO-ARM100 robot (from MuJoCo Menagerie) with animated joint movements.
Features:
- GPU-accelerated rendering via EGL
- Real-time physics simulation with floor collision
- Checkered ground plane visualization
- Video generation of robot movements
- Customizable joint trajectories
- Python 3.10+
- CUDA-capable GPU (for EGL rendering)
- Git
git clone https://github.com/YOUR_USERNAME/mujoco_so101.git
cd mujoco_so101# Clone robot model collection
git clone https://github.com/google-deepmind/mujoco_menagerie.git# Install project and dependencies
pip install -e .
# Or install dependencies directly
pip install mujoco>=3.4.0 numpy imageio pillowpython test_so101.pyThis script:
- Loads the SO-ARM100 scene (robot + floor) from MuJoCo Menagerie
- Simulates 5 seconds of animated joint movements with floor collision
- Renders at 30 FPS using GPU acceleration
- Saves output as
so101_video.mp4
Output:
- Video file:
so101_video.mp4(5 seconds, 480x640 resolution) - Console progress: Frame count updates
mujoco_so101/
├── test_so101.py # GPU rendering demo with floor collision
├── pyproject.toml # Project metadata and dependencies
├── .python-version # Python version (3.12)
├── mujoco_menagerie/ # Robot models (clone separately)
│ └── trs_so_arm100/ # SO-ARM100 MJCF model
│ ├── so_arm100.xml # Robot model only
│ └── scene.xml # Robot + floor scene (used by demo)
└── README.md # This file
The main simulation script demonstrates:
1. GPU Rendering Setup (Critical!)
# Must be set BEFORE importing mujoco
os.environ['MUJOCO_GL'] = 'egl'
import mujoco2. Model Loading
# Load scene with floor collision
model = mujoco.MjModel.from_xml_path("mujoco_menagerie/trs_so_arm100/scene.xml")
data = mujoco.MjData(model)3. GPU-Backed Renderer
renderer = mujoco.Renderer(model, height=480, width=640)4. Joint Animation
# Sinusoidal motion for 5 joints
data.ctrl[0] = 0.8 * np.sin(t) # Base Rotate
data.ctrl[1] = -1.5 + 1.0 * np.sin(t*2) # Shoulder Pitch
data.ctrl[2] = 0.8 + 0.4 * np.sin(t*1.5) # Elbow Pitch
data.ctrl[3] = 0.5 * np.sin(t*2.5) # Wrist Pitch
data.ctrl[4] = 0.3 * np.sin(t*3) # Wrist Roll5. Physics Stepping & Rendering
mujoco.mj_step(model, data) # Advance physics
renderer.update_scene(data, camera=-1) # Update render
pixels = renderer.render() # Get frameEdit test_so101.py:
FPS = 30
DURATION = 10 # Change to 10 seconds
renderer = mujoco.Renderer(model, height=720, width=1280) # HD resolutionEdit the data.ctrl values in the animation loop (lines 40-44):
# Example: Static pose
data.ctrl[0] = 0.5 # Fixed base rotation
data.ctrl[1] = -1.0 # Fixed shoulder pitch
# ... etcrenderer.update_scene(data, camera=0) # Use first camera
renderer.update_scene(data, camera=1) # Use second camera
renderer.update_scene(data, camera=-1) # Free camera (default)To simulate without floor, edit test_so101.py:
MODEL_PATH = "mujoco_menagerie/trs_so_arm100/so_arm100.xml" # Robot onlyIf you see rendering errors:
# Check available rendering backends
python -c "import mujoco; print(mujoco.GLContext.available_backends())"
# Try different backends
export MUJOCO_GL=glfw # Window-based (requires display)
export MUJOCO_GL=osmesa # Software rendering (slow but works without GPU)Error: Model not found at mujoco_menagerie/trs_so_arm100/so_arm100.xml
Solution: Clone MuJoCo Menagerie in the project root:
git clone https://github.com/google-deepmind/mujoco_menagerie.git- Physics Timestep: Defined in model XML (typically 0.002s)
- Rendering: EGL backend (GPU-accelerated, headless)
- Joint Control: Position control via
data.ctrl - Video Format: MP4 (H.264 encoding via imageio-ffmpeg)
- Floor Collision: Infinite plane at z=0 with checkered texture
- Scene: Includes lighting, skybox, and ground plane from MuJoCo Menagerie
- MuJoCo Documentation: https://mujoco.readthedocs.io/
- MuJoCo Menagerie: https://github.com/google-deepmind/mujoco_menagerie
- SO-ARM100 Robot: https://www.seeedstudio.com/
[Your License] - See LICENSE file for details
MuJoCo Menagerie models are licensed under Apache 2.0.
- Google DeepMind MuJoCo Team
- MuJoCo Menagerie
- Seed Studio for SO-ARM100 robot