Skip to content

Commit c9bce71

Browse files
authored
Merge pull request #3318 from matt-cossins/reachy
Build an Edge AI Reachy Mini App with Raspberry Pi, MediaPipe, and MuJoCo
2 parents afea9be + 967e31f commit c9bce71

18 files changed

Lines changed: 1143 additions & 0 deletions

assets/contributors.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,6 @@ Johnny Nunez,NVIDIA,johnnynunez,johnnycano,,
122122
Raymond Lo,NVIDIA,raymondlo84,raymondlo84,,
123123
Kavya Sri Chennoju,Arm,kavya-chennoju,kavya-sri-chennoju,,
124124
Akash Malik,Arm,akashmalik19973,akash-malik-a65bab219,,
125+
Matt Cossins,Arm,matt-cossins,,,
125126
Sue Wu,Arm,,,,
126127
Sabika Tasneem,Memgraph,,,,
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: Build an Edge AI Reachy Mini App with Raspberry Pi, MediaPipe, and MuJoCo
3+
4+
draft: true
5+
cascade:
6+
draft: true
7+
8+
description: Run MediaPipe gesture inference on a Raspberry Pi 5, connect to a Reachy Mini MuJoCo simulation on a development machine, and use a browser dashboard to decide Reachy's fate with a thumbs-up or thumbs-down.
9+
10+
minutes_to_complete: 60
11+
12+
who_is_this_for: This Learning Path is for developers interested in edge AI, robotics simulation, and physical AI applications. You can complete the main path without owning a physical Reachy Mini.
13+
14+
learning_objectives:
15+
- Understand why simulation environments can aid Edge AI and robotics development.
16+
- Run a simulated Reachy Mini robot on a laptop or desktop.
17+
- Use MediaPipe and TensorFlow Lite gesture recognition on Raspberry Pi 5.
18+
- Connect an edge inference node to a robot daemon over the network.
19+
- Display results over a web dashboard.
20+
- (Optional) Extend the project toward a physical Reachy Mini, audio or multimodal interaction, or your own app.
21+
22+
prerequisites:
23+
- A Raspberry Pi 5, ideally with 16 GB RAM.
24+
- A USB webcam connected to the Raspberry Pi.
25+
- A macOS or Linux machine, or a Windows machine with WSL2, capable of running the Reachy Mini MuJoCo simulation.
26+
- Basic Python and Bash terminal experience.
27+
- (Optional) [Reachy Mini](https://huggingface.co/reachy-mini)
28+
29+
author: Matt Cossins
30+
31+
### Tags
32+
skilllevels: Introductory
33+
subjects: ML
34+
armips:
35+
- Cortex-A
36+
tools_software_languages:
37+
- Raspberry Pi
38+
- Reachy Mini
39+
- Python
40+
- MediaPipe
41+
- FastAPI
42+
- MuJoCo
43+
operatingsystems:
44+
- Linux
45+
- macOS
46+
- Windows
47+
48+
### Cross-platform metadata only
49+
shared_path: true
50+
shared_between:
51+
- embedded-and-microcontrollers
52+
- laptops-and-desktops
53+
54+
further_reading:
55+
- resource:
56+
title: Make and publish your Reachy Mini app
57+
link: https://huggingface.co/blog/pollen-robotics/make-and-publish-your-reachy-mini-apps
58+
type: blog
59+
- resource:
60+
title: Reachy Mini Python SDK documentation
61+
link: https://pollen-robotics.github.io/reachy-mini-sdk/
62+
type: documentation
63+
- resource:
64+
title: Reachy Mini project examples
65+
link: https://github.com/pollen-robotics/reachy-mini-sdk/tree/main/examples
66+
type: website
67+
- resource:
68+
title: MediaPipe Gesture Recognizer guide
69+
link: https://ai.google.dev/edge/mediapipe/solutions/vision/gesture_recognizer
70+
type: documentation
71+
72+
73+
74+
### FIXED, DO NOT MODIFY
75+
# ================================================================================
76+
weight: 1 # _index.md always has weight of 1 to order correctly
77+
layout: "learningpathall" # All files under learning paths have this same wrapper
78+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
79+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# ================================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# ================================================================================
5+
weight: 21 # The weight controls the order of the pages. _index.md always has weight 1.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
7.76 MB
Loading
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: (Optional) Extend the project
3+
weight: 7
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Try focused changes
10+
11+
You now have a working physical AI pattern: sensor input at the edge, local
12+
inference, robot commands, and a dashboard for visibility. A good next step is
13+
to make small changes where the effect is easy to observe:
14+
15+
- Change `VERDICT_MIN_CONFIDENCE` in `main.py` to make thumbs detection
16+
stricter or more forgiving.
17+
- Change `MOVE_REPETITIONS` in `main.py` so each move plays more or fewer
18+
times.
19+
- Add a fifth move in `moves.py` and register it in `MOVE_CATALOGUE`.
20+
- Try a different webcam with `REACHY_GLADIATOR_CAMERA_INDEX=1`.
21+
22+
These changes are deliberately small. They help you learn which part of the
23+
system owns each behavior before you make larger changes to perception, robot
24+
motion, or packaging.
25+
26+
## Change the classifier
27+
28+
Trying adding new gesture controls. Start in `gesture.py`, where the app maps MediaPipe labels such as `Thumb_Up` and `Thumb_Down` to app labels. Then add matching robot behavior in `moves.py` and branch on the new label in `main.py`.
29+
30+
Some game-themed ideas:
31+
32+
- Map `Closed_Fist` to `challenge`, and make Reachy repeat the current move
33+
- Map `Pointing_Up` to `reroll`, and make Reachy reject the current move and
34+
choose another one.
35+
- Map `Number of fingers` to choosing a specific move.
36+
37+
## Add audio output
38+
39+
The gladiator theme is a good fit for sound. Try adding audio cues such as:
40+
41+
- a crowd cheer during victory,
42+
- a dramatic sound during defeat,
43+
- a short drum hit before each move,
44+
- a spoken move name before Reachy performs it.
45+
46+
Keep audio output separate from `moves.py` at first. For example, create an
47+
`audio.py` helper and call it from `main.py` when the state changes. This keeps
48+
robot motion and sound effects easy to change independently.
49+
50+
## Replace thumbs with audio input
51+
52+
The vision-based verdict is one edge AI input modality. You can replace
53+
or complement it with audio - many webcams include microphones or you can use a USB microphone.
54+
55+
- say "yes" for victory and "no" for defeat,
56+
- clap once for victory and twice for defeat,
57+
58+
A lightweight keyword-spotting model can map spoken commands to the same game states currently triggered by MediaPipe gestures.
59+
60+
## Try the packaged app on a physical Reachy
61+
62+
If you have a physical Reachy Mini, the quickest way to try the finished
63+
experience is to install the packaged [Reachy Gladiator app](https://huggingface.co/spaces/cossinsmatthew/reachy_gladiator) through the [Reachy Mini Control app](https://github.com/pollen-robotics/reachy-mini-desktop-app).
64+
65+
Simply install Reachy Mini Control on a supported machine, connected to your Reachy, and search for the reachy gladiator app.
66+
67+
{{% notice Warning %}}
68+
If using a physical Reachy Mini, use caution and ensure the robot is used in an area with appropriate space. The robot has moving parts and could be a health & safety risk. You are responsible for your safety and the safety of others around you when using physical robotic devices
69+
{{% /notice %}}
70+
71+
## Adapt this source project for physical Reachy
72+
73+
The main learning path uses the Raspberry Pi USB webcam for perception and a
74+
remote MuJoCo daemon for robot motion. A physical Reachy route changes two
75+
things:
76+
77+
- camera frames come from the Reachy daemon instead of the Pi USB webcam,
78+
- the Pi app connects to the physical Reachy daemon instead of the simulation
79+
daemon.
80+
81+
The source project exposes these switches as environment variables, so you do
82+
not need to edit the Python source:
83+
84+
```bash
85+
REACHY_GLADIATOR_MEDIA_BACKEND=reachy \
86+
REACHY_GLADIATOR_CAMERA=reachy \
87+
REACHY_GLADIATOR_DAEMON_PORT=8000 \
88+
./scripts/run_pi_app.sh localhost
89+
```
90+
91+
Use `localhost` only when the physical daemon runs on the same Pi as the app.
92+
If the daemon runs on another machine, replace `localhost` with that machine's
93+
IP address and set `REACHY_GLADIATOR_DAEMON_PORT` to the daemon port.
94+
95+
These variables map to the code in two places:
96+
97+
- `REACHY_GLADIATOR_MEDIA_BACKEND=reachy` lets `ReachyMiniApp` request daemon
98+
camera media.
99+
- `REACHY_GLADIATOR_CAMERA=reachy` tells `camera.py` to use
100+
`ReachyMediaFrameSource` instead of `OpenCVCameraFrameSource`.
101+
102+
## Build your own Reachy Mini app
103+
104+
A Reachy Mini app is a Python package with a class that inherits from `ReachyMiniApp`, implements `run()`, and exposes an entry point in `pyproject.toml`.
105+
106+
To build a fresh app:
107+
108+
1. Start with one `ReachyMiniApp` class.
109+
2. Add one safe motion such as `neutral()`.
110+
3. Add one input source such as a camera gesture, audio command, button, or web
111+
endpoint.
112+
4. Add a dashboard only after the core loop works.
113+
5. Test in simulation before physical hardware.
114+
6. Package the app when it is stable enough for repeated use.
115+
116+
The Reachy Mini tooling can scaffold and validate a shareable app:
117+
118+
```bash
119+
reachy-mini-app-assistant create my_app ~/reachy_projects
120+
reachy-mini-app-assistant check ~/reachy_projects/my_app
121+
```
122+
123+
The [Reachy Mini app publishing guide](https://huggingface.co/blog/pollen-robotics/make-and-publish-your-reachy-mini-apps)
124+
explains the packaging and publishing workflow in more detail.
125+
126+
Use the Reachy Mini SDK documentation and examples to understand available
127+
motion, media, and daemon APIs. If you use an AI coding agent, give it the
128+
Pollen Robotics `AGENTS.md` instructions, provided by the [Reachy Mini project](https://github.com/pollen-robotics/reachy_mini) so it follows the expected app structure.
129+
130+
## What you learned
131+
132+
You explored options for extending from simulation to a physical Reachy, as well ideas for changing the project to include audio, new vision gestures, or different behaviours.
406 KB
Loading
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
title: Learn about Reachy and understand the application
3+
weight: 2
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Reachy Gladiator - Decide Reachy's Fate
10+
11+
In this Learning Path, Reachy is stepping out onto the sands of the Arena. Reachy has practiced their gladiator moves, but are they good enough?
12+
13+
You will decide Reachy's fate in the classic Roman way - a 👍 for **Victory**, or a 👎 for **Defeat**.
14+
15+
![Illustration of Reachy Mini in a gladiator style pose. The app uses this arena theme for its moves, verdicts, and dashboard.#center](reachy_gladiator.png "Reachy Mini Gladiator App Concept")
16+
17+
## What is Reachy Mini?
18+
19+
Reachy Mini is a small open robotics platform from Pollen Robotics. It is designed for expressive head, antenna, and body motion, and it can be controlled from Python with the Reachy Mini SDK. The Reachy Mini Wireless version includes an onboard Arm-powered Raspberry Pi 4 Compute Module, and the Lite version is operated with external compute (e.g., Raspberry Pi, DGX Spark, Mac/PC).
20+
21+
Reachy can also be simulated using MuJoCo software. Most developers do not have a physical Reachy Mini robot on their desk, and it is often useful to develop software before hardware is available. Extrapolating from Reachy to more industrial robotics, it is also important to test applications in simulation in advance for safety.
22+
23+
{{% notice Warning %}}
24+
If using a physical Reachy Mini, use caution and ensure the robot is used in an area with appropriate space. The robot has moving parts and could be a health & safety risk. You are responsible for your safety and the safety of others around you when using physical robotic devices
25+
{{% /notice %}}
26+
27+
## What will you build?
28+
29+
The workflow of this learning path is split across two machines:
30+
31+
**Laptop/Desktop: macOS, Linux, or Windows with WSL2**
32+
- Runs the Reachy Mini daemon
33+
- Runs the MuJoCo simulation
34+
- Displays simulated Reachy movement
35+
- Displays the Pi-hosted dashboard at `http://<pi-ip-address>:8042`
36+
37+
**Raspberry Pi 5: Raspberry Pi OS**
38+
- Captures frames from a USB webcam
39+
- Runs the Edge AI application (local MediaPipe gesture recognition)
40+
- Serves a dashboard on port 8042
41+
- Sends robot movement commands to the simulation host daemon
42+
43+
This split is a common edge/physical AI pattern:
44+
45+
- A small edge device handles sensors and inference close to the user.
46+
- A robot API or daemon receives movement commands.
47+
- A dashboard gives visibility into the live state of the system.
48+
- Digital twin simulation reduces hardware access as a blocker and allows for safer development.
49+
50+
This is similar to how larger industrial robotics systems are often built.
51+
Keeping perception, robot control, and observability as separate pieces makes it easier to test, replace, and deploy parts of the system independently.
52+
53+
## What does the app do?
54+
55+
The app is called Reachy Gladiator. Reachy (in simulation or otherwise) performs a randomly-chosen scripted gladiator move. You provide a 👍 for **Victory**, or a 👎 for **Defeat**. **Victory** makes Reachy celebrate, **Defeat** makes Reachy react sadly.
56+
57+
This learning path starts from the complete `reachy_gladiator_lp` project instead of asking you to create every file from scratch. The simulation host only needs a launcher script, but the Raspberry Pi will clone and run the full project. You will inspect the different parts of the system so you can recreate your own apps running on Reachy or in simulation.
58+
59+
The Reachy Gladiator app runs a repeated loop:
60+
61+
1. Start with a 10-second preparing countdown
62+
2. Randomly pick one gladiator move
63+
3. Repeat the selected move three times
64+
4. Return Reachy to a neutral pose
65+
5. Watch for a 👍 or a 👎
66+
6. Run a victory or defeat reaction
67+
7. Repeat with another move
68+
69+
There are four preset moves:
70+
71+
- `Salute`
72+
![Salute Move#center](salute.gif "Salute Move")
73+
- `Sword Swing`
74+
![Sword Swing Move#center](sword.gif "Sword Swing Move")
75+
- `Shield Up`
76+
![Shield Up Move#center](shield.gif "Shield Up Move")
77+
- `Battle Cry`
78+
![Battle Cry Move#center](battle-cry.gif "Battle Cry Move")
79+
80+
The app shuffles all four moves and performs each once before any move repeats. When the bag is empty, it reshuffles and avoids repeating the same move at the shuffle boundary.
81+
82+
## Use a compatible terminal
83+
84+
The commands in this learning path use a Bash-style shell. They work directly on macOS and Linux.
85+
86+
On Windows, use WSL2 with an Ubuntu distribution for the simulation host commands. This keeps the commands almost identical to the macOS and Linux flow:
87+
88+
- Use the WSL terminal for `python3`, `source .venv/bin/activate`, and `./scripts/start_sim.sh`.
89+
- Keep the browser on Windows if you prefer; open the Pi dashboard from any browser that can reach the Raspberry Pi.
90+
- If the Pi cannot reach a daemon running inside WSL2, check Windows firewall and WSL networking. WSL2 uses virtualized networking, so inbound access from another device on your LAN may require Windows port forwarding.
91+
92+
The rest of this learning path shows the common Bash commands and calls out the one IP-address command that differs by host operating system.
93+
94+
## Project structure
95+
96+
The simulation host does not need the full project checkout. In the next
97+
section, you will download only the simulation launcher script on that machine.
98+
99+
You will clone the full `reachy_gladiator_lp` project on the Raspberry Pi later on.
100+
101+
The key files are:
102+
103+
```text
104+
reachy_gladiator_lp/
105+
├── pyproject.toml
106+
├── scripts/
107+
│ ├── start_sim.sh
108+
│ ├── setup_pi.sh
109+
│ ├── run_pi_app.sh
110+
│ └── check_pi_camera.sh
111+
└── reachy_gladiator_lp/
112+
├── main.py
113+
├── camera.py
114+
├── gesture.py
115+
├── moves.py
116+
├── assets/
117+
│ └── gesture_recognizer.task
118+
└── static/ # dashboard HTML, CSS, JavaScript, and media
119+
```
120+
121+
## What you learned and what is next
122+
123+
You learned what Reachy Mini is, why simulation is useful for edge/physical AI development, and how the app splits work between a simulation host and a Raspberry Pi. You are now ready to start the simulation host with a lightweight launcher script.
2.29 MB
Loading
2.28 MB
Loading

0 commit comments

Comments
 (0)