Skip to content

jkoba0512/mujoco_so101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MuJoCo SO-101 Simulation

GPU-accelerated physics simulation for the SO-ARM100 robotic arm using MuJoCo.

Overview

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

Prerequisites

  • Python 3.10+
  • CUDA-capable GPU (for EGL rendering)
  • Git

Installation

1. Clone this repository

git clone https://github.com/YOUR_USERNAME/mujoco_so101.git
cd mujoco_so101

2. Install MuJoCo Menagerie

# Clone robot model collection
git clone https://github.com/google-deepmind/mujoco_menagerie.git

3. Install dependencies

# Install project and dependencies
pip install -e .

# Or install dependencies directly
pip install mujoco>=3.4.0 numpy imageio pillow

Quick Start

Run GPU Rendering Demo

python test_so101.py

This script:

  1. Loads the SO-ARM100 scene (robot + floor) from MuJoCo Menagerie
  2. Simulates 5 seconds of animated joint movements with floor collision
  3. Renders at 30 FPS using GPU acceleration
  4. Saves output as so101_video.mp4

Output:

  • Video file: so101_video.mp4 (5 seconds, 480x640 resolution)
  • Console progress: Frame count updates

Project Structure

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

Code Walkthrough

test_so101.py

The main simulation script demonstrates:

1. GPU Rendering Setup (Critical!)

# Must be set BEFORE importing mujoco
os.environ['MUJOCO_GL'] = 'egl'
import mujoco

2. 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 Roll

5. Physics Stepping & Rendering

mujoco.mj_step(model, data)              # Advance physics
renderer.update_scene(data, camera=-1)   # Update render
pixels = renderer.render()               # Get frame

Customization

Change Video Duration or Resolution

Edit test_so101.py:

FPS = 30
DURATION = 10  # Change to 10 seconds
renderer = mujoco.Renderer(model, height=720, width=1280)  # HD resolution

Modify Joint Trajectories

Edit 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
# ... etc

Use Different Camera View

renderer.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)

Disable Floor Collision

To simulate without floor, edit test_so101.py:

MODEL_PATH = "mujoco_menagerie/trs_so_arm100/so_arm100.xml"  # Robot only

Troubleshooting

GPU Rendering Issues

If 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)

Model Not Found Error

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

Technical Details

  • 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

Resources

License

[Your License] - See LICENSE file for details

MuJoCo Menagerie models are licensed under Apache 2.0.

Acknowledgments

About

GPU-accelerated MuJoCo simulation of the SO-ARM100 robotic arm with EGL rendering

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages