3.New ROS package with created ROS message
Consider building a new ROS package with a non-official created ROS message. This non-official type of ROS message is created in one of your previous ROS packages. The new type of ROS message can be used in a new ROS package in your project. There are two ways to add it to your new codes.
1.1 Add the ROS package that built the required ROS message in your new ROS project
First, you need to include that ROS package in CMakeLists.txt
:
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
<ROS_message_package_name> # Should already built as a ROS package in the ROS PATH(before); to include UWB msg
)
And then, don't forget to include the dependencies to your
add_dependencies(NEW_PROJECT_node ${catkin_EXPORTED_TARGETS})
1.2 Directly add the required ROS message in your new ROS project by adding the header file generated by ROS for that required ROS message.
You can find a header file named ‘New_massege.h', if you create this new message in your previous project using ‘New_massege.msg'. You can include this header file in your new project, then, of course, you can use this non-official required message. Just include that ROS package in CMakeLists.txt
:
include_directories(
"<PATH_TO_catkin_ws>/devel/include" # In the ROS workspace named catkin_ws (workspace that includes your new message ROS package) you can find a 'New_massege.h'
)
2 Now you can use the required message in your new projects.
In both ways above, you can include the required message by referencing it in your source code. For C++ users, you can use:
#include "<ROS_message_package_name>/New_massege.h" // Include the header file in your source code.
For Python users you can similarly add this new message, like
from <ROS_message_package_name.msg> import New_massege
# Or
from <ROS_message_package_name> import New_massege
The main idea is to let your new ROS project know where is your required ‘New_massege.h' that includes the message.