micro-ROS brings ROS 2 to microcontrollers, such as a Raspberry Pi Pico or an ESP32. A microcontroller running micro-ROS appears as a normal node: it can publish, subscribe and offer services, so motor drivers and sensors join the robot's ROS 2 system without a custom serial protocol.
How It Fits Together
- the microcontroller runs the rclc C library on top of a small middleware (Micro XRCE-DDS client)
- a micro-ROS agent runs on the main computer, for example a Raspberry Pi
- the agent talks to the microcontroller over serial (USB or UART), UDP or other transports, and acts for it on the full DDS network
- other nodes see topics from the microcontroller as if a normal node published them
Typical Firmware Loop
Steps each cycle:
- let the executor handle new messages for a short, bounded time, so callbacks run
- read sensors, run safety checks and control loops
- publish results
- wait until the fixed loop period ends, so the control rate stays constant
What It Is Good For
- motor control with encoders, where timing must be exact and Linux is not real time
- reading simple sensors (ultrasonic, encoders) and publishing them
- safety functions that must keep working if the main computer or the network fails, such as a command watchdog
Limits
- static memory: publishers, subscribers and message sizes are fixed at build time
- limited message size and rate compared with a full computer
- if the agent link drops, the firmware should stop the motors by itself (for example, set speed to zero if no command arrives for 500 ms)
Alternative
- a simple framed serial protocol with a checksum, plus a small ROS 2 node on the main computer that converts it
- simpler to understand, but every message type must be written and tested by hand