ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rosmsg show in C++

asked 2013-03-12 09:34:27 -0600

Chuck Claunch gravatar image

updated 2014-01-28 17:15:38 -0600

ngrennan gravatar image

Hello, I'd like a way I can recursively iterate all topics/types in C++. Essentially a rosmsg show through all types, down to the basic types. I've seen it done in Python using the function get_topic_class() but I have thoroughly searched and been unable to find a way to do this in C++. Anyone have any ideas? I really don't want to have to hard code all of my message types (we have about thirty custom message types). Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-12 10:22:37 -0600

dornhege gravatar image

What do you mean with hard code? Do you want to be able to pass in a type as a string definition like "geometry_msgs/PoseStamped" without have that type in your code? That is likely to be impossible as c++ needs to know about the type.

If you just want to access a specific known (at compile-time) type in general, generated messages provide a specialization of the Definition struct with a value() function that contains the message definition.

edit flag offensive delete link more


I don't necessarily need to have the ability to process the type without including the headers, I understand that. I simply want to be able to recursively run down the full list of topics and drill down to the most basic data types available (as strings). (the exact funcationality of rosmsg show).

Chuck Claunch gravatar image Chuck Claunch  ( 2013-03-12 10:29:43 -0600 )edit

I see what you mean. My guess is: impossible, but maybe someone can come up with a solution to that.

dornhege gravatar image dornhege  ( 2013-03-12 10:50:20 -0600 )edit

Well it'd be possible with system execs but that's a really hokey solution. I'd hope if we can do this in Python it could be done in C++. Thanks for the effort, the "impossible" is what brings me here :)

Chuck Claunch gravatar image Chuck Claunch  ( 2013-03-12 11:03:38 -0600 )edit

Question Tools


Asked: 2013-03-12 09:34:27 -0600

Seen: 589 times

Last updated: Mar 12 '13