The Pololu 3pi+2040 is a very capable (and adorable) mobile robotics experimentation platform sporting the powerful Raspberry Pi RP2040 microcontroller. The ROS 2 robot operating system is the standard platform for mobile robotics, providing reliable publisher-subscriber communication, simulation and visualization. While ROS is too complex to run on a microcontroller, a microcontroller adaptation called micro ROS has been developed to provide ROS primitives. A serial bridge provides communication between the target microcontroller and the ROS host. My project is to demonstrate and provide a tutorial for running the Pololu 3pi+2040 with micro ROS communicating with a ROS host.
Major steps of this project include:
- Running Micro ROS on a bare Raspberry Pi Pico RP2040 development board
- Running Micro ROS on the Pololu 3pi+2040 with basic functionality
- Adding sensor telemetry to the Pololu 3pi+2040 micro ROS implementation
- Remote motion control of the Pololu 3pi+2040 through micro ROS
- Bonus step: wireless control of the Pololu 3pi+2040 using the Pololu Wixel
This first post will focus on steps 1 & 2, running micro ROS on the RP2040 and then on the 3pi+2040.
Step 1: Micro ROS on a Raspberry Pi Pico RP2040 dev board
I can take no credit for adapting Micro ROS to the Raspberry Pi Pico development board. In fact, all I did was follow the instructions from RoboFoundry on building and installing micro ROS and the micro ROS host bridge.
The only problem I encountered was when I built the base ROS system. I installed a Ubuntu 20.04 virtual machine on my Intel-based Mac using the UTM hypervisor. I tried using Ubuntu 22.04 but the micro ROS build failed; make sure use 20.04. Then I installed ROS 2 Focal using the instructions directly from ros.org.
Step 2: Micro ROS on the Pololu 3pi+2040 with basic functionality
In general I hoped to follow the same instructions from RoboFoundry (linked above), but swapping the Pololu 3pi+2040 for the Raspberry Pi Pico.
The Pololu 3pi+2040 can be put into boot loader mode by holding the “b” button and pressing reset. I loaded the same pico_micro_ros_example.uf2 image that I generated in step 1.
The only change I had to make to the RobotFoundry instructions above is to build the Micro Ros Agent manually from source using the instructions here.
ros2 topic list
ros2 topic echo publisher_node
You should see the integer published by the 3pi+ 2040 incrementing.
The only two problems I encountered were not adding /usr/local/lib to the ldconfig and having set a ROS_DOMAIN_ID. If you have set one, make sure to unset the ROS_DOMAIN_ID. If you don’t, the micro ROS publisher will not appear in the topic list. I’ll have to look into how to set the ROS_DOMAIN_ID intentionally during the firmware generation.
Next Steps
That’s enough for now. Next up I’ll figure out how to compile in telemetry and motor control to the Pololu 3Pi+ RP2040 image.
Pingback: Micro ROS on the Pololu 3pi+2040, Part 2 | Peter F. Klemperer