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

How can I realize subscribing to subtopics

asked 2014-07-18 02:04:53 -0500

wepmaschda gravatar image

I have a message that consists of two (or more) submessages:

my_msgs/VehicleData:
sensor_msgs::NavSatFix gps
gps_msgs::GPSFix gps_fix

When I publish the message as /vehicle I can afterwards use these three commands:

$ rostopic echo /vehicle
$ rostopic echo /vehicle/gps
$ rostopic echo /vehicle/gps_fix

All the commands return the specific submsgs. When I now use the rqt_marble_plugin it doesn't display the /vehicle/gps submessage. Internally this program searches for NavSatFix topics but it doesn't find this one.

Can I somehow fix this?

I would like to be able to publish this VehicleData msg and subscribe either to the whole topic or to subtopics.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-07-18 08:11:01 -0500

demmeln gravatar image

AFAIK there is not automatic way to do this. The subtopic concept does not really exist in ROS. Every node subscribes to topics and has to take care of accessing the composing messages itself. The rostopic tool works some magic to allow echoing only part of a message like in your example.

However, you might be able to use rostopic to republish the NavSatFix messages on a different topic (see the comment to this answer: http://answers.ros.org/question/58995... )

rostopic echo /vehicle/gps | rostopic pub /vehicle_gps_only sensor_msgs/NavSatFix
edit flag offensive delete link more

Comments

Thanks for the reply. I will for now just publish both topics in my node, the concatenated one and all the single ones.

wepmaschda gravatar image wepmaschda  ( 2014-07-28 11:47:46 -0500 )edit

Yes, if you can change the implementation of your node, adding multiple publishers is the simplest option it seems.

demmeln gravatar image demmeln  ( 2014-07-28 12:05:01 -0500 )edit

Question Tools

Stats

Asked: 2014-07-18 02:04:53 -0500

Seen: 2,135 times

Last updated: Jul 18 '14