Installing MicroROS
To create a layer of protection between Jetson and high voltages, and extend the number of GPIO pins we have access to, we use an RP2040 microcontroller, which communicates via a serial connection. Luckily, we are able to extend our software infrastructure to it through the microros platform. It runs nodes directly on the microcontroller, and then allows them to publish and listen on topics through the USB serial connection. Due to resource-restricted nature of the microcontrollers, the code is written in C and many of the principles when writing nodes for Jetson are inapplicable.
To install microros on your machine, navigate to /src/microros/
and run the following command. Note that the installation will take approximately 5 GB:
bash microros_setup.sh
Don't forget to source your ~/.bashrc file:
source ~/.bashrc
Note
Notice that you need to establish communication between Pi Pico and WSL by USB to flash it. If you are on Windows, download and install the latest release of USB support software from WSL USB GUI Releases. By default, devices are not automatically shared with WSL, so you will need to manually autoattach.
To flash Pi Pico with a .uf2 file, plug Pico into your computer while pressing the Boot Select button (you may release it after Pi Pico is in) and run:
picotool_load #write/the/address/of/your/file/here
The Pi Pico cannot communicate with the computer while it is in Boot Select mode. To exit it, you can uplug it and replug it from the USB port. Alretnatively, you may run:
picotool_reboot -F
Then, to establish communication with Pi Pico, run the following commands:
sudo chmod 666 /dev/ttyACM0 && ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0 -b 115200
If you encounter problems during the installation, consult Elias.
Running the Example Code
If you want to get started with microros, a good idea would be to try to flash Pi Pico with the example file. Note that you would need to build it first:
cd $PICO_MICROROS_SDK_PATH
mkdir build && cd build
cmake ..
make
picotool_load pico_micro_ros_example.uf2
Then, proceed to open the serial communication:
sudo chmod 666 /dev/ttyACM0 && ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0 -b 115200
And finally, open a new terminal, and type
source ~/.bashrc
ros2 topic list
If you have done everything correctly, /pico_publisher
would show up in the list of topics. You can watch its output by typing:
ros2 topic echo /pico_publisher