4.2 KiB
4.2 KiB
MIT Mini Cheetah URDF Tutorial
Overview
This tutorial demonstrates serving a URDF (Unified Robot Description Format) file locally to visualize the MIT Mini Cheetah robot in Vuer with animated leg movements.
Directory Structure
Set up your assets directory:
assets/mini_cheetah/
├── meshes/
│ ├── mini_abad.obj
│ ├── mini_body.obj
│ ├── mini_lower_link.obj
│ └── mini_upper_link.obj
└── mini_cheetah.urdf
Download Assets
Use wget to fetch the URDF and mesh files:
mkdir -p assets/mini_cheetah/meshes
cd assets/mini_cheetah
# Download URDF file
wget https://raw.githubusercontent.com/vuer-ai/vuer/main/assets/mini_cheetah/mini_cheetah.urdf
# Download mesh files
cd meshes
wget https://raw.githubusercontent.com/vuer-ai/vuer/main/assets/mini_cheetah/meshes/mini_abad.obj
wget https://raw.githubusercontent.com/vuer-ai/vuer/main/assets/mini_cheetah/meshes/mini_body.obj
wget https://raw.githubusercontent.com/vuer-ai/vuer/main/assets/mini_cheetah/meshes/mini_lower_link.obj
wget https://raw.githubusercontent.com/vuer-ai/vuer/main/assets/mini_cheetah/meshes/mini_upper_link.obj
Complete Code Example
import math
import asyncio
from vuer import Vuer
from vuer.schemas import Scene, Urdf, AmbientLight, Movable, PointLight
# Configure app to serve static files from assets directory
app = Vuer(static_root="assets/mini_cheetah")
@app.spawn(start=True)
async def main(session):
# Setup scene with lighting
session.set @ Scene(
AmbientLight(intensity=0.8),
Movable(
PointLight(
intensity=2.0,
position=[1, 2, 1],
key="point-light-1",
)
),
Movable(
PointLight(
intensity=2.0,
position=[-1, 2, -1],
key="point-light-2",
)
),
)
# Animation loop
for i in range(1000):
# Calculate joint angles using sine waves
hip_angle = 0.5 * math.sin(i * 0.1)
thigh_angle = 0.785 - 0.25 * math.sin(i * 0.1)
calf_angle = -1.5 + 0.5 * math.sin(i * 0.1)
# Update robot with animated joints
session.upsert @ Urdf(
src="/static/mini_cheetah.urdf",
position=[0, 0, 0],
rotation=[0, 0, 0],
jointValues={
# Front Left leg
"FL_hip_joint": hip_angle,
"FL_thigh_joint": thigh_angle,
"FL_calf_joint": calf_angle,
# Front Right leg
"FR_hip_joint": -hip_angle,
"FR_thigh_joint": thigh_angle,
"FR_calf_joint": calf_angle,
# Rear Left leg
"RL_hip_joint": hip_angle,
"RL_thigh_joint": thigh_angle,
"RL_calf_joint": calf_angle,
# Rear Right leg
"RR_hip_joint": -hip_angle,
"RR_thigh_joint": thigh_angle,
"RR_calf_joint": calf_angle,
},
key="mini-cheetah",
)
# Update at ~60 FPS
await asyncio.sleep(0.016)
app.run()
Joint Control
The Mini Cheetah has 12 joints (3 per leg):
- Hip joint: Abduction/adduction (side-to-side movement)
- Thigh joint: Hip flexion/extension (forward/backward)
- Calf joint: Knee flexion/extension
Animation Details
The example creates a walking motion using sinusoidal functions:
hip_angle = 0.5 * math.sin(i * 0.1)
thigh_angle = 0.785 - 0.25 * math.sin(i * 0.1)
calf_angle = -1.5 + 0.5 * math.sin(i * 0.1)
Expected Result
When executed correctly, the tutorial produces a 3D visualization of the Mini Cheetah robot with animated leg movements displayed in a web interface at http://localhost:8012.
Troubleshooting
Robot not appearing
- Verify all mesh files are downloaded
- Check that
static_rootpoints to the correct directory - Ensure URDF file references correct mesh paths
Animation not smooth
- Adjust the sleep interval (currently 0.016s for ~60 FPS)
- Reduce animation speed by changing the multiplier in
i * 0.1
Source
Documentation: https://docs.vuer.ai/en/latest/tutorials/robotics/urdf_mini_cheetah.html