This repository demonstrates the implementation of Micro-ROS on an ESP32 development board using the PlatformIO environment. The project features a ROS2 publisher that transmits integer messages (std_msgs/msg/Int32) to a specified ROS2 topic.
- PlatformIO installed in VS Code
- Micro-ROS library
- ROS2 installed on a compatible system
- Serial transport setup for communication between ESP32 and ROS2
- ESP32 development board
- USB cable for programming and serial communication
-
Clone the Repository
git clone https://github.com/Chinmay-ESP/ESP32_MicroROS_PUB.git cd ESP32_MicroROS_PUB -
Install Dependencies Open the project in VS Code and allow PlatformIO to automatically install the required dependencies.
-
Configure Micro-ROS Serial Transport Ensure the correct serial transport setup for ESP32:
set_microros_serial_transports(Serial); -
Build and Upload the Code
pio run --target upload
- Publisher: Publishes an integer message to the ROS2 topic
micro_ros_platformio_node_publisher. - Timer: Executes a callback function every second, incrementing and publishing the integer value.
- Executor: Manages asynchronous execution of callbacks.
- Setup Function (
setup()):- Initializes the Micro-ROS node, publisher, timer, and executor.
- Loop Function (
loop()):- Executes the Micro-ROS executor to manage message publishing.
To subscribe to the published messages, execute the following command on your ROS2 machine:
ros2 topic echo /micro_ros_platformio_node_publisher- If the Micro-ROS agent is not running, start it using:
docker run -it --rm --ipc host --network host --privileged microros/micro-ros-agent:humble serial -b 115200 --dev /dev/ttyUSB0
- Ensure the correct USB port is configured in
platformio.ini. - Verify ROS2 and Micro-ROS installations are correctly configured.