This projects outlines the process of building a ROS 2 RC receiver using ESP32 and micro-ROS. It aims to design a ROS 2 plug-and-play receiver which can be used to replace any standard RC receiver. The receiver can communicate either over serial using USB-C or Wifi.
The receiver is based on a Adafruit ESP32 Feather V2 (any board supported by micro_ros_arduino can be used). In the future, the Adafruit ESP32 Feather V2 might be replaced by the Arduino Nano RP2040 Connect to make use of the additional 6-axis IMU.
A custom PCB is used to connect at least two (more can be added) 3-pin plugs for connecting e.g. the ESC and servo of a standard RC car. This can be built using cheap perfboards.
This simple hardware setup already allows us to control a RC car using ROS 2.
For the advanced setup the receiver includes ports for four hall sensors which are used for wheel odometry.
To integrate the micro-ROS receiver into a ROS 2 environment, two things are needed: a micro-ROS agent running on a host computer and the micro-ROS client running on the ESP32.
To get the agent running, simply setup Docker on your host computer and run the following command in a shell:
# Serial micro-ROS Agent
docker run -it --rm -v /dev:/dev --privileged --net=host microros/micro-ros-agent:[YOUR ROS 2 VERSION] serial --dev [YOUR BOARD PORT] -v6
This command connects to an micro-ROS client over serial. Check your PORT and ROS 2 VERSION. Find more information here. There is also an command for connecting the client over Wifi.
When using WSL2 this article discribes how to connect a USB device to the Linux distribution.
The client is based on micro-ROS for Arduino reconnection example. Install Arduino IDE 2, add Arduino-ESP32 support and download the micro-ROS library for Arduino following the instructions on micro-ROS for Arduino. Use the board manage to select your board and port.
Clone this repo and upload the micro_ros_rc_receiver.ino file to your device.
Connect the device over USB to the host where the micro-ROS agent is running.
To check the devices port run ls /dev/ttyACM*
or ls /dev/ttyUSB*
(linux) or check your device manager (windows).