Main Content

Using micro-ROS on the Raspberry Pi Pico

Raspberry Pi Pico can communicate with a ROS2 graph natively via micro-ROS… with ROS2 development using VSCode

Running micro-ROS on Raspberry Pi Pico

In this post, we’ll look at how the Raspberry Pi Pico can communicate with a ROS2 graph natively via micro-ROS. In VSCode, we’ll create a project, build it, and upload it to the microcontroller. As a result, we’ll presume you’re comfortable with ROS2 development using VSCode.

Running ROS2 on RP2040 microcontrollers.
The Raspberry Pi Pico with RP2040 chip is totally open-hardware and created by the Pi’s developers. At only $4, it is extraordinarily inexpensive, as is typical of the Pi foundation.

The board’s specifications, the distinctions between a microprocessor and a microcontroller, the 101 on how to get started, and what the Pi Pico can accomplish are all outside the scope of this article. But, whether you’re familiar with microcontrollers or not, I strongly advise you to have a look for yourself.

micro-ROS
Microcontrollers have long been treated as second-class citizens in the ROS (1) world. They can’t communicate with the ROS graph directly, therefore developers must rely on libraries like rosserial. However, ROS2 is a completely new universe, and things are evolving all the time.

> micro-ROS instals ROS 2 on microcontrollers, allowing them to participate in the ROS 2 ecosystem as first-class citizens.
> micro-ROS instals ROS 2 on microcontrollers, allowing them to participate in the ROS 2 ecosystem as first-class citizens.
The micro-ROS project is led by huge industry names like Bosch, eProsima, Fiware Foundation, and a slew of partners and collaborators, including Amazon and Canonical, as well as the OFERA H2020 project.

So, what exactly is it? It’s simply a thin wrapper (see its design paper) on top of DDS for eXtremely Resource Constrained Environments (DDS-XRCE) that runs on a real-time OS and allows microcontrollers to communicate with a ROS2 graph (the standard talker/listener) using an optimised subset of the DDS protocol. It’s a mouthful. It uses a ‘bridged’ communication architecture with the ‘micro-ROS Agent‘ as a ‘broker.’ The agent is responsible for bridging the gap between the ROS2 graph and one or more micro-ROS devices.

More information, including how it compares/differs from rosserial, may be found on the micro-ROS website (see here and here).

So, now that we’ve explained a few terminology, let’s get started with the official micro-ROS on Raspberry Pi Pico example available on github, step by step. Note that I’m using Ubuntu 20.04 with the VSCode snap for this lesson.

If you haven’t yet upgraded to Ubuntu 20.04, you might want to consider utilising an LXD container. To get started setting up the container, refer to our earlier piece ‘ROS Development with LXC.’”

Link to article