Installing Firmware Dependencies
The devcontainer that is installed by default is only the "base" devcontainer and it does not contain all of the dependencies required to build and develop on the firmware. To do this, we need to switch the version of our devcontainer to the "development_image_firmware". See documentation on how to change your your dev container variant.
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. For more information, check out the documentation on connecting to a USB device in WSL.
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 building the raspberry pi pico firmware, 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