Skip to content

add message data type string to message traits #258

@wjwwood

Description

@wjwwood

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions