BCI (Brain Computer Interface) system for robot control using EMG/EEG signals.
robrain/
├── CMakeLists.txt
├── common
│ ├── protocol
│ └── types
├── docs
│ ├── CHECKPOINTLOG
│ └── especificaciones_tecnicas.typ
├── firmware
│ ├── arduino-emg
│ └── esp32-robot
├── host
│ ├── CMakeLists.txt
│ ├── lib
│ └── src
├── README.md
└── scripts
└── setup-clangd.sh
[Electrodes] --> [Arduino] --serial--> [Laptop] --BLE--> [ESP32] --> [Motors]
EMG processes robot
signals
The system uses two separate circuits: the EMG acquisition side (Arduino Uno + MyoWare sensors powered by 9V batteries) and the robot side (ESP32 + L298N motor driver powered by a 7.4V LiPo pack).
Full PDF version: conexiones.pdf
- 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 ..