This repository contains the PlatformIO firmware for Aquabotics—the ESP32-S3 client that receives motor commands over micro-ROS and drives the L298N motor controllers on the ROV.
aquabotics_platformIO/
├── bno055_IMU/ # IMU example code and configs
├── examples/ # Additional demo sketches
├── images/
│ └── motor_state_machine.png # Main state-machine diagram
├── include/
├── lib/
├── microROS/ # Additional demo sketches about MicroROS
├── src/
│ └── main.cpp # setup(), loop(), callback logic
├── test/ # Unit & integration tests
├── .gitignore
├── README.md
└── platformio.ini # Board settings & dependencies
-
platformio.ini
Defines the ESP32-S3 board, upload and monitor speeds, and library dependencies (e.g.,micro_ros_arduino). -
src/main.cpp
setup():- Initializes serial ports and configures GPIO pins for motor enable/in1/in2
- Initializes micro-ROS, creates a node, and subscribes to
"xbox/motor_command"
loop():- Runs a state machine that pings the micro-ROS agent, creates/destroys entities, and spins the executor
- When a motor command arrives, calls
motor_command_callback()
motor_command_callback():- Reads index, direction, and speed
- Applies a change-threshold filter
- Calls
control_motor(idx, dir, speed)to drive the L298N
- PlatformIO extension (VSCode or CLI)
- ESP32-S3 Development Board
- L298N motor driver modules
- USB-serial cable for programming and micro-ROS agent connectivity
- Open the project in VSCode with the PlatformIO extension
- Start your micro-ROS agent on the host computer:
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0- Upload the firmware to the ESP32-S3 and open the serial monitor. You should see logs indicating:
- Agent ping successes/failures
- Subscription creation
- Incoming motor commands and state transitions
- Use the Aquabotics ROS 2
joy_controllerto publish to"xbox/motor_command"and watch the ROV motors respond.
- Left:
setup()flow—serial/GPIO init, micro-ROS node creation, subscription setup. - Right:
motor_command_callback()logic—filtering small changes, then callingcontrol_motor(idx, dir, speed). - Bottom:
loop()state machine—ping agent, create/destroy entities, spin executor.
