Create a new message
Steps
-
Create Message
bash roscd thorlabs_linear_actuator/ mkdir msg cd msg nano write.msg -
Paste in the following, save, then close:
txt uint8 register uint8 value -
open package.xml
bash roscd thorlabs_linear_actuator/ nano package.xml -
paste in the following, save, then close:
xml <build_depend>message_generation</build_depend> <exec_depend>message_runtime</exec_depend> -
Open CMakeLists.txt in your favorite text editor (rosed from the previous tutorial is a good option).
-
Add the message_generation dependency to the find_package call which already exists in your CMakeLists.txt so that you can generate messages. You can do this by simply adding message_generation to the list of COMPONENTS such that it looks like this:
```
Do not just add this to your CMakeLists.txt, modify the existing text to add message_generation before the closing parenthesis
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation ) ```
-
Also make sure you export the message runtime dependency.
txt catkin_package( ... CATKIN_DEPENDS message_runtime ... ...) -
Find the following block of code:
```txt
add_message_files(
FILES
Message1.msg
Message2.msg
)
```
-
Uncomment it by removing the # symbols and then replace the stand in Message*.msg files with your .msg file, such that it looks like this:
txt add_message_files( FILES write.msg )By adding the .msg files manually, we make sure that CMake knows when it has to reconfigure the project after you add other .msg files.
-
Now we must ensure the generate_messages() function is called.
For ROS Hydro and later, you need to uncomment these lines:
```txt
generate_messages(
DEPENDENCIES
std_msgs
)
```
-
-
Check message
bash rosmsg show thorlabs_linear_actuator/write -
Make
```bash cd ~/code/code_idealab_ros/ catkin_make
catkin_make install # (optionally)
make one thing
catkin_make --source my_src
catkin_make install --source my_src # (optionally)
```