Search code examples
ros

How to include ros msg outside of ros environment?


I am utilizing ros outside of the ros workspace using g++ and i want to include a custom msg I made. Normally I would just do "#include "msg_filter/my_msg.h"" but that doesn't seem to work outside the environment. What should I do instead?


Solution

  • Let's get into the low-level of what's happening. If you have a catkin_ws/src/my_pkg/msg/CustomMessage.msg, and you compile it correctly (you can use it as normal within ROS), you'll find a header file for it at catkin_ws/devel/include/my_pkg/CustomMessage.h and a python msg file at catkin_ws/devel/lib/python2.7/dist-packages/my_pkg/msg/_MyMsg.py. You can still see them, in another workspace, if you have source catkin_ws/devel/setup.bash, either at the cmd line or in your .bashrc.

    But trying to compile & utilize ROS msgs outside of the catkin buildsystem is probably unwise - at that point it's far easier to make your own data struct in a common header & use that for interfacing between libraries or programs (just guessing at your use case). For the record, while you could compile ROS related things on the cmd line using g++ (the rest of the headers/libs are at /opt/ros/<distro>/), I suspect that would be more quickly painful than changing your dependencies/interfaces or doing it within catkin.