As was possible in ROS 1 (http://wiki.ros.org/roscpp/Overview/MessagesTraits) it should be possible to get the type name for a message with a template function, e.g. something like:
#include <sensor_msgs/msg/image__traits.hpp>
const char * message_type_name = rosidl_generator_traits::data_type<sensor_msgs::msg::Image>();
or
#include <sensor_msgs/msg/image__traits.hpp>
const char * message_type_name = sensor_msgs::msg::Image::data_type();
which would be a alias to the other one.
I'm copying the namespace in this file which is where I would add it:
https://github.com/ros2/rosidl/blob/master/rosidl_generator_cpp/resource/msg__traits.hpp.em
Which uses the rosidl_generator_traits namespace for all traits, but I think that might be better changed to rosidl_generator_cpp or something similar which is rosidl and cpp specific.
We need this in rviz (ros2/rviz#164).
As was possible in ROS 1 (http://wiki.ros.org/roscpp/Overview/MessagesTraits) it should be possible to get the type name for a message with a template function, e.g. something like:
or
which would be a alias to the other one.
I'm copying the namespace in this file which is where I would add it:
https://github.com/ros2/rosidl/blob/master/rosidl_generator_cpp/resource/msg__traits.hpp.em
Which uses the
rosidl_generator_traitsnamespace for all traits, but I think that might be better changed torosidl_generator_cppor something similar which is rosidl and cpp specific.We need this in rviz (ros2/rviz#164).