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

How to echo to multiple topics at once

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

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
2

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

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
0

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

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:

https://github.com/lucasw/topic_state...

rosrun topic_state multi_echo.py /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 multi_echo.py 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

2 followers

Stats

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

Seen: 6,043 times

Last updated: Oct 23 '22