Initial commit
This commit is contained in:
181
docs/tutorials/robotics/go1-stairs.md
Normal file
181
docs/tutorials/robotics/go1-stairs.md
Normal file
@@ -0,0 +1,181 @@
|
||||
# Unitree Go1 Robot with Stairs
|
||||
|
||||
## Overview
|
||||
This tutorial demonstrates setting up a 3D scene containing a Unitree Go1 quadruped robot positioned in front of a staircase, along with lighting and atmospheric effects.
|
||||
|
||||
## Scene Components
|
||||
|
||||
The visualization includes four main elements:
|
||||
|
||||
1. **Unitree Go1 Robot** - A quadrupedal robot model loaded via URDF format
|
||||
2. **Stairway Mesh** - A textured 3D model of stairs
|
||||
3. **Fog Effect** - Atmospheric fog that darkens distant portions of the scene
|
||||
4. **Lighting** - An ambient light source plus two movable point lights
|
||||
|
||||
## Complete Code Example
|
||||
|
||||
```python
|
||||
import math
|
||||
import asyncio
|
||||
from vuer import Vuer
|
||||
from vuer.schemas import Scene, Urdf, Obj, AmbientLight, PointLight, Movable, Plane, Fog
|
||||
|
||||
app = Vuer()
|
||||
|
||||
@app.spawn(start=True)
|
||||
async def main(session):
|
||||
# Setup scene with fog and lighting
|
||||
session.set @ Scene(
|
||||
# Add fog effect
|
||||
Fog(
|
||||
color="#000000",
|
||||
near=1,
|
||||
far=20,
|
||||
),
|
||||
|
||||
# Ground plane
|
||||
Plane(
|
||||
args=[100, 100],
|
||||
position=[0, -0.01, 0],
|
||||
rotation=[-1.57, 0, 0],
|
||||
key="ground",
|
||||
),
|
||||
|
||||
# Staircase mesh
|
||||
Obj(
|
||||
src="/static/stairs/stairs.obj",
|
||||
position=[2, 0, 0],
|
||||
rotation=[0, 0, 0],
|
||||
materialType="standard",
|
||||
material={
|
||||
"color": "#cccccc",
|
||||
"roughness": 0.8,
|
||||
},
|
||||
key="stairs",
|
||||
),
|
||||
|
||||
# Ambient lighting
|
||||
AmbientLight(intensity=1.0),
|
||||
|
||||
# Movable point lights
|
||||
Movable(
|
||||
PointLight(
|
||||
intensity=3.0,
|
||||
position=[2, 3, 2],
|
||||
key="light-1",
|
||||
)
|
||||
),
|
||||
Movable(
|
||||
PointLight(
|
||||
intensity=3.0,
|
||||
position=[-2, 3, -2],
|
||||
key="light-2",
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
# Animation loop for the robot
|
||||
for i in range(10000):
|
||||
# Calculate joint angles using sinusoidal functions
|
||||
hip_angle = 0.3 * 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 position and joints
|
||||
session.upsert @ Urdf(
|
||||
src="/static/go1/go1.urdf",
|
||||
position=[0, 0, 0.33],
|
||||
rotation=[0, 0, 0],
|
||||
jointValues={
|
||||
# Front Left
|
||||
"FL_hip_joint": hip_angle,
|
||||
"FL_thigh_joint": thigh_angle,
|
||||
"FL_calf_joint": calf_angle,
|
||||
|
||||
# Front Right
|
||||
"FR_hip_joint": -hip_angle,
|
||||
"FR_thigh_joint": thigh_angle,
|
||||
"FR_calf_joint": calf_angle,
|
||||
|
||||
# Rear Left
|
||||
"RL_hip_joint": -hip_angle,
|
||||
"RL_thigh_joint": thigh_angle,
|
||||
"RL_calf_joint": calf_angle,
|
||||
|
||||
# Rear Right
|
||||
"RR_hip_joint": hip_angle,
|
||||
"RR_thigh_joint": thigh_angle,
|
||||
"RR_calf_joint": calf_angle,
|
||||
},
|
||||
key="go1-robot",
|
||||
)
|
||||
|
||||
# Update at ~60 FPS
|
||||
await asyncio.sleep(0.016)
|
||||
|
||||
app.run()
|
||||
```
|
||||
|
||||
## Key Features
|
||||
|
||||
### Fog Effect
|
||||
Creates atmospheric depth:
|
||||
```python
|
||||
Fog(
|
||||
color="#000000", # Black fog
|
||||
near=1, # Fog starts at distance 1
|
||||
far=20, # Full fog at distance 20
|
||||
)
|
||||
```
|
||||
|
||||
### Ground Plane
|
||||
A large plane rotated to be horizontal:
|
||||
```python
|
||||
Plane(
|
||||
args=[100, 100], # 100x100 units
|
||||
position=[0, -0.01, 0], # Slightly below origin
|
||||
rotation=[-1.57, 0, 0], # Rotated 90° (π/2)
|
||||
)
|
||||
```
|
||||
|
||||
### Staircase Mesh
|
||||
3D model with material properties:
|
||||
```python
|
||||
Obj(
|
||||
src="/static/stairs/stairs.obj",
|
||||
materialType="standard",
|
||||
material={
|
||||
"color": "#cccccc",
|
||||
"roughness": 0.8,
|
||||
},
|
||||
)
|
||||
```
|
||||
|
||||
## Robot Animation
|
||||
|
||||
The application updates continuously at approximately 60 frames per second, calculating joint values like:
|
||||
|
||||
```python
|
||||
thigh_angle = 0.785 - 0.25 * math.sin(i * 0.1)
|
||||
```
|
||||
|
||||
This creates realistic walking motion across the stair scene.
|
||||
|
||||
## Leg Coordination
|
||||
|
||||
The Go1 has a specific gait pattern:
|
||||
- Front Left and Rear Right move together (same hip angle)
|
||||
- Front Right and Rear Left move together (opposite hip angle)
|
||||
|
||||
This creates a natural trotting gait.
|
||||
|
||||
## Assets Required
|
||||
|
||||
Make sure you have the following assets:
|
||||
- `go1.urdf` - Robot description file
|
||||
- `stairs.obj` - Staircase 3D model
|
||||
- Associated mesh files for the Go1 robot
|
||||
|
||||
## Source
|
||||
|
||||
Documentation: https://docs.vuer.ai/en/latest/tutorials/robotics/urdf_go1_stairs.html
|
||||
Reference in New Issue
Block a user