|Note: This tutorial assumes that you have completed the previous tutorials: Arduino IDE Setup.|
|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
Generating Message Header File(Adding Other Messages)Description: This tutorial shows how to generate message header files for using new message packages with rosserial (i.e. how to add custom message type to your application with rosserial).
Tutorial Level: INTERMEDIATE
Message header files are generated for many important message types when you install rosserial. If you need to use other message types, or you have your own custom message types, you will need to generate the appropriate headers.
Generating Message Header Files (Adding Custom Messages)
New in 0.2.0 The make_library has moved from rosserial_arduino to rosserial_client.
First source your ROS distro and build your workspaces as required:
source /opt/ros/noetic/setup.bash cd ~/catkin_ws catkin build source devel/setup.bash
To add new messages to the library you have to delete (if already created) the whole ros_lib folder in your arduino libraries subpath and generate all from scratch.
rosrun rosserial_client make_libraries path_to_libraries
For instance, suppose I need to generate headers for message definitions contained in my crazy_msgs package, and ros_lib is located at '~/sketchbook/libraries/ros_lib':
rm -r ~/sketchbook/libraries/ros_lib rosrun rosserial_client make_libraries ~/sketchbook/libraries