- Operating System: Ubuntu 24.04 LTS
- ROS 2 Distribution: Jazzy Jalisco (LTS, released May 2024)
- Microcontroller: ESP32 (with WiFi capability)
- Development Environment: Arduino IDE (latest version)
- Additional Hardware:
- HC-SR04 Ultrasonic Sensor
- DC Motors with motor driver (L298N or similar)
- Wheels and chassis for robot platform
- Network: Both ESP32 and Ubuntu machine should be on the same local network (WiFi or Ethernet)
- Python 3: Ensure Python 3 is installed on your Ubuntu system
- Basic Knowledge: Familiarity with ROS 2 concepts, Arduino programming, and terminal commands
ROS 2 Jazzy Jalisco is fully compatible with ESP32 microcontrollers through micro-ROS. Jazzy is the latest Long Term Support (LTS) release launched in May 2024, with support extending until May 2029. The micro-ROS project has been actively updated to support Jazzy, with all core repositories and standalone build systems receiving Jazzy branch updates.123
Key Compatibility Points:
- Supported Platforms: Ubuntu 24.04 LTS (your setup) is a Tier 1 platform for ROS 2 Jazzy21
- ESP32 Support: ESP32 has been officially supported by micro-ROS since 2020, with native WiFi and UDP transport capabilities45
- Network Communication: UDP port 8888 is the default transport method for micro-ROS agents67
First, set up the micro-ROS agent on your host system:
# Source ROS 2 Jazzy
source /opt/ros/jazzy/setup.bash
# Create workspace for micro-ROS
mkdir ~/microros_ws
cd ~/microros_ws
# Clone micro-ROS setup tools
git clone -b jazzy https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup
# Clone roboneo_bot package
git clone https://github.com/Aqirito/roboneo_ros_bot.git src/roboneo_bot
# Optional: Clone teleop_twist_keyboard for manual control
git clone -b dashing https://github.com/ros2/teleop_twist_keyboard.git src/teleop_twist_keyboard
# Install dependencies
sudo apt update && rosdep update
rosdep install --from-paths src --ignore-src -y
# Build micro-ROS tools
colcon build
source install/local_setup.bash
# Create and build micro-ROS agent
ros2 run micro_ros_setup create_agent_ws.sh
ros2 run micro_ros_setup build_agent.sh
source install/local_setup.bashAdd this to your .bashrc for convenience:
echo "source ~/microros_ws/install/local_setup.bash" >> ~/.bashrc- Download and install the micro-ROS Arduino library:
Download as ZIP: micro_ros_arduino
- Go to
Sketch → Include Library → Add .ZIP Library...in Arduino IDE - Select the downloaded ZIP file
- Check
Sketch → Include Libraryfind the installed libraries probably namedmicro_ros_arduinoto confirm installation
- Go to
- Install ESP32 Board Support:
- Open Arduino IDE
- Go to
File → Preferences - Add this URL to Additional Board Manager URLs: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- Go to
Tools → Board → Boards Manager - Search for "ESP32" and install version 2.0.2 for safe compatibility with micro-ROS
- Select Board and Port:
Tools → Board → ESP32 Arduino → ESP32 Dev ModuleTools → Port → [Your ESP32 Port](usually/dev/ttyUSB0or/dev/ttyACM0)
ESP32 HC-SR04
---------------------
5V ----> VCC
GND ----> GND
GPIO 25 ----> Trig
GPIO 26 ----> Echo
ESP32 Motor Driver Motors
-------------------------------------
GPIO 16 ---> IN1 (Left) Left Motor
GPIO 17 ---> IN2 (Left)
GPIO 18 ---> IN3 (Right) Right Motor
GPIO 19 ---> IN4 (Right)
5V ---> VCC (Logic)
GND ---> GND
The project includes multiple Arduino sketches for different functionalities:
ESP32 code that publishes a "hello" string message via WiFi UDP: esp32_hello_publisher.ino
ESP32 code that publishes distance measurements from HC-SR04 sensor: ultrasonic_publisher.ino
ESP32 code that subscribes to Twist messages for motor control: twist_subscriber.ino
Combined functionality with both ultrasonic sensor publishing and motor control: roboneo_bot.ino
Key Configuration Points for all sketches:
- Update
YOUR_WIFI_SSIDandYOUR_WIFI_PASSWORDwith your network credentials - Change
host_ipto your Ubuntu PC's IP address (find withip addr show) - Built-in LED (pin 2) indicates micro-ROS agent connection status
- All sketches use UDP port 8888 for communication
Create ROS 2 nodes for communication with ESP32:
Receives messages from ESP32 hello publisher: hello_sub.py
Publishes messages to control ESP32 LED: led_state_pub.py
Receives distance measurements from ESP32: ultrasonic_sub.py
Comprehensive test script for the complete robot system: test_roboneo_bot.py
You likely already have the rclpy, std_msgs, and geometry_msgs packages installed as part of your ROS 2 system. It's good practice to run rosdep in the root of your workspace (ros2_ws) to check for missing dependencies before building:
rosdep install -i --from-path src --rosdistro jazzy -yThen build your workspace:
cd ~/microros_ws
colcon build --packages-select roboneo_bot
source install/setup.bashTerminal 1 - Start micro-ROS Agent:
source ~/microros_ws/install/local_setup.bash
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888You should see:
[INFO] [UDPv4AgentLinux.cpp] init | running... | port: 8888
Terminal 2 - Run ROS 2 Subscriber:
source /opt/ros/jazzy/setup.bash
ros2 run roboneo_bot hello_subTerminal 3 - Monitor Topics (Optional):
source /opt/ros/jazzy/setup.bash
ros2 topic list
ros2 topic echo /esp32/helloTerminal 1 - Start micro-ROS Agent:
source ~/microros_ws/install/local_setup.bash
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888Terminal 2 - Run Ultrasonic Distance Subscriber:
source /opt/ros/jazzy/setup.bash
ros2 run roboneo_bot ultrasonic_subTerminal 3 - Run Robot Test Script:
source /opt/ros/jazzy/setup.bash
ros2 run roboneo_bot test_roboneo_bot- Upload Code: Flash the desired Arduino sketch to your ESP32
- Monitor Connection: Watch the serial monitor - you should see WiFi connection and micro-ROS agent discovery
- Verify Communication: The ESP32's LED should turn on when connected to the agent
- Check Messages: Your Python subscribers should receive messages from the ESP32
To run individual components of the roboneo_bot system:
# Publish distance measurements
ros2 topic pub /ultrasonic_distance std_msgs/msg/Float32 "data: 0.0" --once
# Control motors with Twist messages
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "linear:
x: 0.5
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.5" --onceUse the test script to verify all functionality:
ros2 run roboneo_bot test_roboneo_botThis will:
- Move the robot forward
- Rotate the robot
- Stop the robot
- Display distance measurements
You can manually control the roboneo_bot using the teleop_twist_keyboard package:
Terminal 1 - Start micro-ROS Agent:
source ~/microros_ws/install/local_setup.bash
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888Terminal 2 - Run teleop_twist_keyboard:
ros2 run teleop_twist_keyboard teleop_twist_keyboardFollow the on-screen instructions to control the robot:
i/k- Move forward/backwardj/l- Turn left/rightq/z- Increase/decrease linear speedw/x- Increase/decrease angular speedspace- Stop the robot
Terminal 3 - Monitor distance sensor (optional):
ros2 topic echo /ultrasonic_distanceCommon Issues:
- No topics visible: Ensure both devices are on the same network and firewall allows UDP traffic on port 888889
- Connection fails: Verify IP address is correct and micro-ROS agent is running8
- WiFi connection issues: Double-check SSID and password in the ESP32 code10
- Sensor readings inaccurate: Check HC-SR04 wiring and power supply
- Motor not responding: Verify motor driver connections and power supply
Network Verification:
# Check if ESP32 can reach your PC
ping [ESP32_IP]
# Verify micro-ROS agent is listening
netstat -ulnp | grep 8888Debugging Connection Issues:
- Check that the micro-ROS agent is running on port 8888
- Verify that both ESP32 and PC are on the same network
- Confirm that the IP address in the ESP32 code matches your PC's IP
- Use the serial monitor to check ESP32 connection status
This setup provides a robust foundation for ESP32-ROS 2 Jazzy communication over your local network via UDP, enabling real-time bidirectional communication between your microcontroller and ROS 2 system for robotics applications.1112 1314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Footnotes
-
https://www.openrobotics.org/blog/2024/5/ros-jazzy-jalisco-released ↩ ↩2
-
https://discourse.openrobotics.org/t/ros-2-jazzy-jalisco-released/37862 ↩ ↩2
-
https://github.com/micro-ROS/micro_ros_setup/discussions/694 ↩
-
https://discourse.ros.org/t/micro-ros-porting-to-esp32/16101 ↩
-
https://github.com/micro-ROS/micro_ros_setup/issues/532 ↩ ↩2
-
https://github.com/micro-ROS/micro_ros_platformio/issues/139 ↩
-
https://technologiehub.at/project-posts/micro-ros-on-esp32-tutorial/ ↩
-
https://www.reddit.com/r/ROS/comments/15jey91/dynamic_communication_between_esp32_and_ros2/ ↩
-
https://dev.to/lonebots/seamless-robotics-integration-setting-up-micro-ros-on-esp32-2ad2 ↩
-
https://xiangyu.xlog.app/Integrating-ESP32-with-ROS-over-WiFi?locale=en ↩
-
https://www.reddit.com/r/ROS/comments/175k1hl/ros2_esp32_sos/ ↩
-
https://xiangyu-fu.github.io/2023/08/07/misc/esp32_ros_wifi/ ↩
-
https://ros2-tutorial.readthedocs.io/en/latest/publishers_and_subscribers.html ↩
-
https://blog.hadabot.com/set-up-esp32-microcontroller-for-ros2-robotics.html ↩
-
https://www.theconstruct.ai/how-to-write-a-ros-publisher-and-subscriber-with-a-custom-message/ ↩
-
https://deepwiki.com/micro-ROS/micro-ROS-Agent/3.2-running-the-agent\&rut=8410700258b7e59a9cf9de81d68c668823c76557b9b72b971bac5b6970e81766 ↩
-
https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html ↩
-
https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html ↩
-
https://www.reddit.com/r/ROS/comments/1cyvjfg/ros_2_jazzy_jalisco_has_been_released_details/ ↩
-
https://adityakamath.github.io/2022-07-02-even-more-microros-examples/ ↩
-
https://adityakamath.github.io/2022-06-26-more-microros-examples/ ↩
-
https://discourse.ros.org/t/ros-2-jazzy-jalisco-released/37862 ↩
-
https://www.hackster.io/514301/micro-ros-on-esp32-using-arduino-ide-1360ca ↩
-
https://docs.ros.org/en/humble/Releases/Release-Jazzy-Jalisco.html ↩
-
https://gist.github.com/rasheeddo/5a6dd95b206233ad58bda8304ae2f30d ↩
-
https://automaticaddison.com/how-to-create-a-ros-2-python-subscriber-iron/ ↩
-
https://www.reddit.com/r/ROS/comments/vgycwx/microros_node_on_esp32_that_both_publishes_and/ ↩
-
https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html ↩
-
https://www.theconstruct.ai/ros2-programming-basics-using-python/ ↩
-
https://ppl-ai-code-interpreter-files.s3.amazonaws.com/web/direct-files/8d9aff20712c0dc808dee3a1918c6910/b500273d-9cec-4b5c-99bc-498499d85735/422142d4.ino ↩
-
https://ppl-ai-code-interpreter-files.s3.amazonaws.com/web/direct-files/8d9aff20712c0dc808dee3a1918c6910/3808b7d3-c2a7-4dd1-ab48-8ed0e178d6fd/dc0c08fa.py ↩