How to create custom micro ros message service for use in arduino framework - kajmoerk/Brick_Feeder GitHub Wiki
2. Next you have to install and setup the Arduino IDE or platformIO to be able to compile the micro-ros library
For platformtIO you can follow this guide link
I use platformIO and i found the extra_packages folder at:
/home/<YOUR_USERNAME>/Documents/PlatformIO/Projects/<YOUR_PROJECT_NAME>/.pio/libdeps/<YOUR_BOARD>/micro_ros_arduino/src/extras/library_generation/extra_packages
As an example, my username is ubu, my platformIO project name is micro_ros_test_dev and the microcontroller board i use is the nodemcu-32s, so for me i can find the extra_packages folder at:
/home/ubu/Documents/PlatformIO/Projects/micro_ros_test_dev/.pio/libdeps/nodemcu-32s/micro_ros_arduino/src/extras/library_generation/extra_packages
Remember that .pio is a hidden folder.
You can follow this guide on how to create a custom msg:
https://micro.ros.org/docs/tutorials/advanced/create_new_type/
You can substitute the .msg file with .srv depending on if you want to create a custom message or service.
Extra info about messages and services can be found here:
https://docs.ros.org/en/foxy/Tutorials/Custom-ROS2-Interfaces.html
For me the root of the micro-ros library is located at:
/home/<YOUR_USERNAME>/Documents/PlatformIO/Projects/<YOUR_PROJECT_NAME>/.pio/libdeps/<YOUR_BOARD>/micro_ros_arduino
The build command is:
docker pull microros/micro_ros_static_library_builder:galactic
docker run -it --rm -v $(pwd):/project --env MICROROS_LIBRARY_FOLDER=extras microros/micro_ros_static_library_builder:galactic -p esp32
You can change the last part after -p to whatever board type you have (esp32, teensy or olimex-stm32-e407) Remember to run as super user.
#include <my_custom_message/msg/my_custom_message.h>
my_custom_message__msg__MyCustomMessage msg;
msg.byte_test = 3;
msg.uint32_test = 42;
More examples can be found here.
Extra information for troubleshooting can be found here:
Cannot create a custom micro-ROS type following the tutorial. #193
Video guide for setup of custom msg.
Custom messages/services generation #14