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

subscribe to a topic without specifying type

asked 2016-03-05 07:03:46 -0500

federico.ferri gravatar image


is is possible to subscribe to a specific topic, without specifying the message type?

I need to pass the message to a Lua interpreter, and I want to avoid having one C++ function for each type I want to subscribe (which would be every message in actionlib_msgs, control_msgs, diagnostic_msgs, geometry_msgs, map_msgs, nav_msgs, pcl_msgs, sensor_msgs, shape_msgs, std_msgs, tf2_geometry_msgs, tf2_msgs, tf2_sensor_msgs, trajectory_msgs, visualization_msgs)

edit retag flag offensive close merge delete


Have you seen wiki/roslua? It's a bit old (although the lua-5.2 branch is pretty recent), but it could provide you with some idea of how to tackle this.

gvdhoorn gravatar image gvdhoorn  ( 2016-03-06 00:58:12 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-05 21:55:11 -0500

ahendrix gravatar image

The topic_tools package provides a ShapeShifter class which can be used to subscribe to any topic, but the API is still limited to either passing around serialized messages, or message types that are known at compile time.

The relay node from topic_tools provides a simple example of how to publish and subscribe generically: relay.cpp

edit flag offensive delete link more

Question Tools



Asked: 2016-03-05 07:03:46 -0500

Seen: 205 times

Last updated: Mar 05 '16