Custom classes in message files
I would like to communicate (mulitple) custom C++ classes between nodes. On the ROS wiki I have found how to adapt C++ types to be used with publish and subcribe: http://wiki.ros.org/roscpp/Overview/M...
Using the approach above I can publish only one class for each topic.
However, I would also like to use these C++ classes in the messages used by the SimpleActionServer/SimpleActionClient and send some additional information (so not only sending the class itself). Hence, I had to idea to use these classes inside a message file.
I have tried to use a test class in an example message item_test.msg with some class Item, adapted as described on the ROS wiki.
Item item
This was to test if it is possible to use the adapted C++ classes with .msg/.srv/.action files. However, I got the following error when compiling:
CMake Error at /home/mathijs/git/rose2_0/gui/build/gui_item_selector/cmake/gui_item_selector-genmsg.cmake:3 (message):
Could not find messages which
'/home/mathijs/git/rose2_0/gui/src/gui_item_selector/msg/item_test.msg'
depends on. Did you forget to specify generate_messages(DEPENDENCIES ...)?
Cannot locate message [Item]: unknown package [custom_classes] on search
path [{{'geometry_msgs':
['/opt/ros/hydro/share/geometry_msgs/cmake/../msg'], 'gui_item_selector':
['/home/mathijs/git/rose2_0/gui/src/gui_item_selector/msg',
'/home/mathijs/git/rose2_0/gui/devel/share/gui_item_selector/msg'],
'std_msgs': ['/opt/ros/hydro/share/std_msgs/cmake/../msg'],
'actionlib_msgs': ['/opt/ros/hydro/share/actionlib_msgs/cmake/../msg'],}}]
Call Stack (most recent call first):
/opt/ros/hydro/share/genmsg/cmake/genmsg-extras.cmake:303 (include)
gui_item_selector/CMakeLists.txt:39 (generate_messages)
I have specified generate_messages(DEPENDENCIES custom_classes) in the CMakelist, so that is not the fault. Is there a way to use the Item class in a .msg/.srv/.action file?
Is Item a ROS message?
Item is a C++ class which I have adapted for serialization (from http://wiki.ros.org/roscpp/Overview/MessagesSerializationAndAdaptingTypes)
I am also looking for a method to uses custom classes as messages in pub/sub, services and GFR. I am building a datamanager node which retrieves data from disk or database and wraps this in an object, which I want to send to another node.
I'm also looking for an answer to this.
For now, we have still have not found a solution for this. What we do at this moment is using the adaptions of C++ types as described above and sending only one class over topics and services. A big drawback for us is that you lose the interface to Python and introspection of topics/services.
I just want to clear up that my problem was with services using adapted C++ types, not the multiple-class per-topic problem. In fact, I believe this is a limitation of ROS itself, where you publish one message type per topic.