Skip to content

A simple use case of micro-ROS with an ESP32 board to publish Wi-Fi scan data and control the board's LED using a service.

License

Notifications You must be signed in to change notification settings

mgonzs13/esp32_ros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp32_ros

This repository demonstrates a simple use case of micro-ROS with an ESP32 board (specifically the ESP32-S3) to publish Wi-Fi scan data. Additionally, it provides a service to control the board's LED.

Installation and Usage

1. Install micro-ROS Setup and Agent

Follow the official micro-ROS installation guide to set up micro-ROS. Below is a summary of the steps:

# Source the ROS 2 installation
source /opt/ros/$ROS_DISTRO/setup.bash

# Create a workspace and download the micro-ROS tools
mkdir microros_ws
cd microros_ws
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup

# Update dependencies using rosdep and pip
sudo apt update && rosdep update
rosdep install --from-paths src --ignore-src -y
sudo apt-get install python3-pip

# Build micro-ROS tools and source them
colcon build
source install/local_setup.bash

# Download micro-ROS-Agent packages
ros2 run micro_ros_setup create_agent_ws.sh
ros2 run micro_ros_setup build_agent.sh
source install/local_setup.bash

2. Install the Arduino IDE

Install the Arduino IDE using the following commands:

sudo apt install flatpak -y
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub cc.arduino.arduinoide -y

3. Prepare micro-ROS for Arduino

  1. Download the micro_ros_arduino library and place it in ~/Arduino/libraries.
  2. Create custom interfaces for the esp32_msgs package:
# Copy the message package to the extra_packages directory
cp -r esp32_msgs ~/Arduino/libraries/micro_ros_arduino/extras/library_generation/extra_packages

# Modify the colcon.meta file to use the parameter server in micro_ros_arduino
# You have to increase the max services to 6
# Take a look at the provided colcon.meta file in this repository
nano ~/Arduino/libraries/micro_ros_arduino/extras/library_generation/colcon.meta

# Create the code for Arduino
cd ~/Arduino/libraries/micro_ros_arduino
docker run -it --rm -v $(pwd):/project --env MICROROS_LIBRARY_FOLDER=extras microros/micro_ros_static_library_builder:humble

# Optional: Copy the ESP32 library for the ESP32-S3 board
cd ~/Arduino/libraries/micro_ros_arduino/src
cp -r esp32 esp32s3

4. Configure the Arduino IDE

  1. Open the Arduino IDE.
  2. Install the Adafruit_NeoPixel library via Tools > Manage Libraries.
  3. Install the ESP32 board support package via Tools > Board > Board Manager.
  4. Select the correct port (/dev/ttyACM0) and the board (ESP32S3 DEV Module).

5. Load the Code and Run the micro-ROS Agent

  1. Load the code from the esp32_node directory onto the ESP32 board using the Arduino IDE.
  2. Start the micro-ROS agent:
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0

6. Verify the Setup

  • Check the /wifi_scan topic:
ros2 topic echo /wifi_scan
  • Test the /set_led_color service:
ros2 service call /set_led_color esp32_msgs/srv/SetLedColor "{'color': {'r': 1, 'g': 0, 'b': 1}}"

Additional Notes

  • The esp32_msgs package defines the custom message and service types used in this project.
  • Ensure all dependencies are properly installed to avoid build or runtime issues.

This project showcases the seamless integration of an ESP32-S3 board with ROS 2 using micro-ROS, providing an excellent starting point for robotics projects requiring lightweight and efficient communication between devices.

About

A simple use case of micro-ROS with an ESP32 board to publish Wi-Fi scan data and control the board's LED using a service.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published