Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JuaniRaggio/Robrain

Repository files navigation

Robrain

BCI (Brain Computer Interface) system for robot control using EMG/EEG signals.

Project Structure

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

Data Flow

[Electrodes] --> [Arduino] --serial--> [Laptop] --BLE--> [ESP32] --> [Motors]
                    EMG                 processes         robot
                                        signals

Schematics

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).

Connection diagram

Full PDF version: conexiones.pdf

Requirements

Host (Laptop)

  • 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

Firmwares (Arduino and ESP32)

  • PlatformIO Core (CLI) or PlatformIO IDE
# Install PlatformIO CLI
pip install platformio

# Or with pipx (recommended)
pipx install platformio

Building

There 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-arduino

Build Options (Host)

Sanitizers (development/debug only)

Sanitizers 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

Developer Environment Setup

1. Install dependencies

# 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-dev

2. Build firmware once (installs PlatformIO toolchains)

cd firmware/arduino-emg && pio run

3. Editor setup

Neovim / Emacs (clangd)

These 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
  1. Generates compile_commands.json for firmware (via pio run -t compiledb) and host (via cmake)
  2. Generates .clangd files for firmware/arduino-emg/ and host/ with the correct include paths, defines, and diagnostic suppressions

VSCode

Install these extensions:

  • PlatformIO IDE
  • CMake Tools
# Build host once to generate compile_commands.json
mkdir build && cd build && cmake ..

About

Brain Computer Interface system for robot control using EMG/EEG. Pipeline: Electrodes -> Arduino -> Host -> ESP32 -> engine

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors