Adding a custom message type to Micro ROS for the Pico is quite involved. In this video, I show the process and demonstrate this for a Servo control message.
The source code for this example is on GitHub.
There are a number of excellent ROS2 Tutorials that will help back up what I say in the video. Check out:
I don’t explain how PWM controls the servo in this video but I have a short video covering this. Short video Controlling Servos using PWM
Setup & Build uRos workspace and micro_ros_setup:
source /opt/ros/humble/local_setup.bash
mkdir uros_ws
cd uros_ws
git submodule add -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup
rosdep install --from-paths src --ignore-src –y
colcon build
source install/local_setup.bash
Create New Custom Package
cd uros_ws/src
ros2 pkg create --build-type ament_cmake ros2_servo
create msg definition
Edit CMakeList.txt & Package
cd ..
colcon build --package-select ros2_servo
source instal/local_setup.bash
Setup and Build for Cross Compile
ros2 run micro_ros_setup create_firmware_ws.sh generate_lib
Copy in my_toolchain.cmake and my_colcon.meta
ros2 run ros2_servo create_fwws.sh
ros2 run micro_ros_setup build_firmware.sh $(pwd)/my_toolchain.cmake $(pwd)/my_colcon.meta
