Create Topic using an existing library C++
I am taking part in a robotics project that is introducing ROS into its development.
I have an existing library of classes that are used to pass information. My task is to integrate this library into ROS messages.
I am unable to create a publisher using ros::Publisher controls_pub = nForPublishing.advertise<communication::messages>("controlChannel", 1000);
where communication::messages is the library namespace/class.
Below is the compiler error message I'm getting:
In file included from /home/user/ros_catkin_ws/install_isolated/include/ros/serialization.h:37:0,
from /home/user/ros_catkin_ws/install_isolated/include/ros/publisher.h:34,
from /home/user/ros_catkin_ws/install_isolated/include/ros/node_handle.h:32,
from /home/user/ros_catkin_ws/install_isolated/include/ros/ros.h:45,
from /home/user/new_catkin_ws/src/demo_robot_ros_driver/src/demo_robot_ros_driver.cpp:1:
/home/user/ros_catkin_ws/install_isolated/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<M>::value(const M&) [with M = communications::messages*]’:
/home/user/ros_catkin_ws/install_isolated/include/ros/message_traits.h:255:104: required from ‘const char* ros::message_traits::md5sum(const M&) [with M = communications::messages*]’
/home/user/ros_catkin_ws/install_isolated/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = communications::messages*]’
/home/user/new_catkin_ws/src/demo_robots_ros_driver/src/demo_robots_ros_driver.cpp:68:34: required from here
/home/user/ros_catkin_ws/install_isolated/include/ros/message_traits.h:126:34: error: request for member ‘__getMD5Sum’ in ‘m’, which is of pointer type ‘communications::messages* const’ (maybe you meant to use ‘->’ ?)
return m.__getMD5Sum().c_str();
From the tutorials, I understand how ROS Topics/Messages are created (MSG files). This is not practical in our situation as the library is quite large and undergoing further development. catkin_make
pre-processes the MSG files to create header files.
It is not practical to manually create MSG files for each class, due to maintenance issues, nor is it desirable to create a parsing program that generates MSG files from the library's code (ie rosJava).
As it stands, all the classes have a to_string() method which I can use to serialise the objects, but I would like to have topics based on class structures not delimited strings.
Would anyone be able to point me to a tutorial that explains how I can incorporate an existing library class into a topic?