BCI (Brain Computer Interface) system for robot control using EMG/EEG signals.
-
(host) Leer info del arduino
-
(host) Realizar promedio de muestras de forma vectorizada (en el futuro esto seria procesamiento)
-
(host) Enviar indicaciones al esp32 via BLE
-
(esp32) Leer indicaciones
-
(esp32) Actuar
Note
Importante tener en cuenta la siguiente data:
| Baudrate | Tiempo para 256 bytes (aprox.) |
|---|---|
| 9600 | ~267 ms |
| 115200 | ~22 ms |
| 1000000 | ~2.5 ms |
- Configuracion de Comunicacion serial entre Arduino y Host
- Protocolo de comunicacion serial
- Implementar la comunicacion
- Configuracion de Conexion BLE
- Protocolos de comunicacion entre esp32 y el host
- Implementar la comunicacion
- Implementar un procesamiento MUY simple de señales
- Control de motores
- Filtrar señales
- Implementar procesamiento ML-based
robrain/
├── common/ # Shared protocol between components
├── docs/ # Technical documentation
├── firmware/
│ ├── arduino-emg/ # EMG signal capture (PlatformIO)
│ └── esp32-robot/ # Robot motor control (PlatformIO)
└── host/ # Laptop application (CMake)
[Electrodes] --> [Arduino] --serial--> [Laptop] --BLE--> [ESP32] --> [Motors]
EMG processes robot
signals
- CMake >= 3.16
- C++17 compiler (GCC, Clang)
- Boost
- SimpleBLE (for BLE communication)
# Ubuntu/Debian
sudo apt install cmake build-essential libboost-dev libbluetooth-dev
# macOS
brew install cmake boost
# SimpleBLE (all platforms)
# https://github.com/OpenBluetoothToolbox/SimpleBLE
git clone https://github.com/OpenBluetoothToolbox/SimpleBLE.git
cd SimpleBLE && mkdir build && cd build
cmake .. && make && sudo make install- PlatformIO Core (CLI) or PlatformIO IDE
# Install PlatformIO CLI
pip install platformio
# Or with pipx (recommended)
pipx install platformioThere are multiple targets for flashing devices and compiling code in the root's cmake file, where you can read the command options you have, for each you need to run from the root directory:
mkdir build
cd build
cmake ..
make <command>
# eg commands:
# firmware-esp32
# firmware-arduino
# firmware-all
# upload-ep32
# upload-arduinoSanitizers help detect bugs at runtime:
cd robrain/build
# AddressSanitizer (buffer overflow, use-after-free, memory leaks)
cmake -DENABLE_ASAN=ON ..
make
# UndefinedBehaviorSanitizer (integer overflow, null pointer, etc)
cmake -DENABLE_UBSAN=ON ..
make
# ThreadSanitizer (data races, deadlocks)
cmake -DENABLE_TSAN=ON ..
make
# Combine ASan + UBSan
cmake -DENABLE_ASAN=ON -DENABLE_UBSAN=ON ..
make# PlatformIO (for firmware builds)
pipx install platformio
# Host dependencies (macOS)
brew install cmake boost
# Host dependencies (Ubuntu/Debian)
sudo apt install cmake build-essential libboost-dev libbluetooth-devcd firmware/arduino-emg && pio runThese editors use clangd as LSP. Since clangd doesn't natively understand AVR, the project includes a script that generates everything needed for clangd:
./scripts/setup-clangd.sh- Generates
compile_commands.jsonfor firmware (viapio run -t compiledb) and host (viacmake) - Generates
.clangdfiles forfirmware/arduino-emg/andhost/with the correct include paths, defines, and diagnostic suppressions
Install these extensions:
- PlatformIO IDE
- CMake Tools
# Build host once to generate compile_commands.json
mkdir build && cd build && cmake ..