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

How to echo to multiple topics at once

asked 2016-10-13 09:42:24 -0600

Cerin gravatar image

Is it possible to use rostopic to echo multiple topics at once?

I have a node that's consuming a lot of CPU, and I'm not sure why. It publishes a dozen topics, so to help debug, I tried to do:

rostopic echo /mynode/*

but of course, rostopic told me the topic "/mynode/*" doesn't exist.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-10-13 11:45:57 -0600

Mark Rose gravatar image

You can open multiple terminal windows/tabs and use rostopic echo in each one, or you spawn multiple copies of rostopic, all echoing to the console.

rostopic echo /nodename/topic1 & rostopic echo /nodename/topic2 & rostopic echo /nodename/topic3 & ...

But you might find it more useful to use rostopic hz or rostopic bw to see the publish rate or bandwidth for some of these topics. It may be more likely that your main loop is publishing faster than you need. Are you using a rospy.Rate to publish at regular intervals, as in this rospy tutorial? (For the C++ code counterpart see this tutorial.)

edit flag offensive delete link more

answered 2022-10-23 07:28:00 -0600

lucasw gravatar image

I made this mainly to have a generic way to subscribe to a couple of topics and check that they are synchronized to each other, but you can turn use_sync off if you don't want that:

rosrun topic_state /topic1 /topic2 /topic3

It won't expand the * for you but some command line processing of rostopic list output could do that in one (probably unwieldy) line- or modify to do that internally.

Internally it uses AnyMsg to figure out the types of messages on the first stage then sets up regular callbacks for the second stage optionally using message_filters.TimeSynchronizer.

edit flag offensive delete link more

Question Tools



Asked: 2016-10-13 09:42:24 -0600

Seen: 5,643 times

Last updated: Oct 23 '22