Recap from Assignment 3#
In the previous assignment, you converted simple_1dcnn_model.h5 to TensorFlow Lite and verified its interface:
Input: float32 [1, 200, 3]
Output: float32 [1, 4]You then converted model.tflite into model.cpp and replaced the model source in the gesture recognition application. The example’s existing model.h already declares the required symbols:
1gesture_recognition/
2└── main/
3 ├── model.cpp
4 └── include/
5 └── model.hThe model now embedded in the ESP-IDF project recognizes the three original classes plus the movement collected in Assignment 1. The remaining task is to synchronize the application labels, build the firmware, and test inference on the ESP-SensairShuttle.
What you will do#
In this assignment, you will:
- Add the new gesture name to the application label table.
- Build and flash the updated firmware.
- Test all four classes and record the results.
Assignment steps#
Step 1: Update the class labels#
Open main/app_model.cpp and find kLabels. Replace the complete array so its order matches the labels used during training:
1static const char *kLabels[] = {
2 "Counterclockwise circle",
3 "V",
4 "Unknown",
5 "YOUR_GESTURE",
6};Replace YOUR_GESTURE with the name of the movement collected in Assignment 1.
0, V is 1, unknown is 2, and the new gesture is 3. A different order displays the wrong name even when the model predicts the correct output index.No other source changes are required for the fourth class:
app_model.cppreads the class count fromoutput->dims->data[1].app_model_pipeline.cpphandles class IDs without assuming a fixed count.- The BMI270 configuration and
200 × 3input pipeline remain unchanged. model.cppwas already replaced in Assignment 3; the existingmodel.hremains unchanged.
Step 2: Build the application#
- Select File → Open Folder and open the
gesture_recognitionproject directory, not itstrainingsubdirectory. - Run
ESP-IDF: Build Your Projectfrom the Command Palette. - Follow the build output in VS Code.
From the gesture_recognition project directory, build with the ESP-IDF v6.1 environment activated:
idf.py buildThe first build may take longer while the Component Manager downloads dependencies.
If compilation reports an undefined model symbol, confirm:
main/model.cppdefinesmodel_tfliteandmodel_tflite_len.main/include/model.hdeclares the same names and types.main/CMakeLists.txtincludes themainsource directory.
Step 3: Flash and monitor#
- Run
ESP-IDF: Select Port to Usefrom the Command Palette and select the ESP-SensairShuttle. - Run
ESP-IDF: Build, Flash and Start a Monitor on Your Device. - Select UART if prompted.
- Use the trash-can icon in the VS Code Terminal panel to stop the monitor.
Replace <PORT> with the serial port used earlier:
idf.py -p <PORT> flash monitorPress Ctrl+] to exit the monitor.
Move the board using one of the trained gestures. Expected output resembles:
I (...) Model Pipeline: Motion detected: Counterclockwise circle (confidence: 98.4%)
I (...) Model Pipeline: Motion detected: YOUR_GESTURE (confidence: 94.7%)
I (...) Model Pipeline: Motion detected: Unknown (confidence: 91.2%)Class names, confidence values, and timestamps depend on your model and movement.
Step 4: Validate physical gestures#
Use the same grip and board orientation used during data collection. Perform at least 10 trials per class and record every result, including incorrect classifications and rejected movements.
| Gesture | Trials | Correct | Incorrect | Rejected |
|---|---|---|---|---|
| Counterclockwise circle | 10 | |||
| V gesture | 10 | |||
| Unknown movements | 10 | |||
| New gesture | 10 |
For this workshop, aim for at least 7 correct detections out of 10 for each intentional gesture. This is a workshop checkpoint, not a production-quality acceptance threshold.
If the new gesture performs poorly:
- Confirm that
kLabelsuses the correct class order. - Repeat the movement with the training grip, orientation, speed, and amplitude.
- Review the confusion matrix from Assignment 2.
- Collect more varied samples and retrain.
- Adjust the trigger or confidence threshold only after checking the dataset and model.
Acceptance criteria#
- The project builds successfully for ESP32-C5.
- Tensor allocation completes without errors.
- BMI270 data fills a
float32input tensor with shape(1, 200, 3). - Inference returns four class scores.
kLabelscontains four names in training-label order.- Serial output reports class names and confidence values.
- Physical tests include all four classes with at least 10 trials each.
Going further#
- Collect data from more participants and orientations.
- Compare
float32and fully quantized models. - Measure tensor arena usage and inference latency.
- Tune trigger and confidence thresholds using recorded results.
- Test the model with gestures performed by people not represented in the training dataset.
Conclusion#
You collected a new gesture, trained and converted a four-class model, embedded it in an ESP-IDF application, and ran inference locally on the ESP32-C5.
