FastAPI server for controlling the Unitree G1 humanoid robot. Provides a web interface and REST endpoints for movement, gestures, and live camera feeds.
Start the local API:
uvicorn api:app --host 0.0.0.0 --port 8000Make it publicly accessible with ngrok:
ngrok http 8000Use the ngrok URL to access the control panel and API from anywhere.
- Python 3.x
- Unitree SDK2 (
unitree_sdk2py) - FastAPI, uvicorn, opencv-python, numpy, pydantic
pip install fastapi uvicorn opencv-python numpy pydantic| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Web control panel (index.html) |
| GET | /actions |
List available standard actions |
| POST | /action/{action_id} |
Trigger a standard action (3–11) |
| POST | /move_timed |
Execute timed movement |
| GET | /video_feed/{camera_id} |
MJPEG stream from camera 0 or 1 |
| ID | Action |
|---|---|
| 3 | move forward |
| 4 | move lateral |
| 5 | move rotate |
| 9 | wave hand1 |
| 10 | wave hand2 |
| 11 | shake hand |
{
"direction": "forward|backward|left|right|turn_left|turn_right|stop",
"duration": 1.5,
"speed": 0.3
}| File | Description |
|---|---|
api.py |
FastAPI app, robot control, video streams |
index.html |
Web control panel UI |
mock_api.py |
Mock API for testing without robot |