Rosanswers logo

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

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<br> $ 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.

Originally posted by wepmaschda on ROS Answers with karma: 1 on 2014-07-18

Post score: 0


1 Answer 1


Rosanswers logo

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/is-there-a-way-to-recompose-messages-from-command-line/?answer=59004#post-id-59004)

rostopic echo /vehicle/gps | rostopic pub /vehicle_gps_only sensor_msgs/NavSatFix

Originally posted by demmeln with karma: 4306 on 2014-07-18

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by wepmaschda on 2014-07-28:
Thanks for the reply. I will for now just publish both topics in my node, the concatenated one and all the single ones.

Comment by demmeln on 2014-07-28:
Yes, if you can change the implementation of your node, adding multiple publishers is the simplest option it seems.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.