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

How to create a global listener for any ROS topic and extract all data from any message?

asked 2011-06-15 03:35:42 -0600

pparescasellas gravatar image

Hey everybody,

I am trying to build a ROS node that receives all the messages published by all the other nodes present in my software architecture. This new node should be able to receive any message (with different contents), extract all the data and log it (so it's important for me to be able to know all the contained data types and their values). Is there any good way to:

  • Convert any .msg to some "common" format, like XML (so I can treat all the messages as just one string and then do my parsing)?
  • If not, how do I to easily parse each contained data inside any message ( type and value )?. I want to treat all the messages as if they were generic; I don't want to manually extract all the data one variable at a time, this would force me to make one hardcoded callback for each topic.
  • Also, is there any better way to receive all the messages from any node with any topic without having to create a new subscriber and a callback for each new topic in my "listener" node?

Thanks!

edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted
3

answered 2011-06-15 08:02:35 -0600

kwc gravatar image

The rosbag tool already does basically what you ask, e.g.

rosbag record --all

It records topic data efficiently to disk, which allows you to do offline processing (using the rosbag library). Efficiency is important as it's generally not a good idea to subscribe to all topics (it creates a huge performance drain).

edit flag offensive delete link more

Comments

This is an offline solution which I already use (check my answer below) but that's not what I'm looking for; I need the logging to be on runtime and in a matlab-friendly format. I also need to know whether it is possible to deserialize every message of any topic to name-type-value for each attribute
pparescasellas gravatar image pparescasellas  ( 2011-06-19 05:34:57 -0600 )edit
1

answered 2011-06-15 07:49:44 -0600

Take a look at the internals of rostopic. It likely does much of what you want.

edit flag offensive delete link more

Comments

If I could get the output of "rostopic echo" for all topics inside my logging node on runtime that would really make my day! Is this even possible? :)
pparescasellas gravatar image pparescasellas  ( 2011-06-19 05:38:50 -0600 )edit
1

answered 2011-06-19 04:05:33 -0600

pparescasellas gravatar image

Thanks for the answers guys. Let's see, I already knew about rosbag but I only use it from the command line; are you suggesting me to call to rosbag / rostopic from within my logger node?

What I need is a node that receives all topics and is able to log them at runtime in a matlab-friendly format. What I do now to achieve that (offline) is:

first of all, record a bag file:

rosbag record -a

Once this is done, I can play this rosbag at any time and log the topics I need:

rosbag play 2011-06-19-17-19-56.bag
rostopic echo -p /any_topic/bleh > log.txt

This is exactly what I need for the logging part. Is this possible to achieve from within a node subscribed to all the topics? If so, do I really need to subscribe manually to all the topics or there's a way to subscribe to all of them?

Also, it would be nice for me to be able to convert any ROS message to an xml-like notation (something like <name="age" type="integer" value"30"=""/> if the message contains an uint32 age = 30 ).

Thanks for your patience!

edit flag offensive delete link more

Comments

This is no answer.

felix k gravatar image felix k  ( 2013-07-24 23:07:08 -0600 )edit
1

answered 2011-06-19 05:43:17 -0600

Lorenz gravatar image

For conversion, the python API for rosbag might help. Have a look here. Python should support introspection for (recorded) ROS messages which should make it possible to convert them to XML.

edit flag offensive delete link more

Comments

I really need the xml-like conversion at runtime (it does not need to be XML, I just need to be able to know all the attribute names, types and values of all messages received at runtime in a somewhat dynamic way). That's what the HTTP server is going to respond to any petition.
pparescasellas gravatar image pparescasellas  ( 2011-06-19 06:21:31 -0600 )edit
Are you suggesting that I record a rosbag for every message received, store it, open it and parse it using python? :P
pparescasellas gravatar image pparescasellas  ( 2011-06-19 06:22:25 -0600 )edit
Not necessarily :) With rospy you should be able to import the correct messages at runtime and subscribe to topics. You also should be able to introspect messages, i.e. you should be able to get a list of slots and to access the slots.
Lorenz gravatar image Lorenz  ( 2011-06-19 09:24:57 -0600 )edit
0

answered 2011-06-19 09:20:01 -0600

Bemfica gravatar image

Maybe I didn't get your point but if you need to comunicate Matlab with ros so one way is by using UDP. On simulink there is a "communication box" and on the ros-side you can use Transport Hints to change from TCP to UDP the comm. layer of the topics.

Another way is by using IPC-bridge. Here you can found how to do it. I've not tested yet. I think that write to or read from a file could be slow.

edit flag offensive delete link more

Comments

I just need to record logs in a format that can later be read by matlab without having a lot of trouble. The -p flag in "rostopic echo -p /any_topic/bleh > log.txt" does exactly that. I don't need to communicate with matlab at runtime through UDP :)
pparescasellas gravatar image pparescasellas  ( 2011-06-19 20:16:32 -0600 )edit
I just need to record logs in a format that can later be read by matlab without having a lot of trouble. The -p flag in:
pparescasellas gravatar image pparescasellas  ( 2011-06-19 20:16:33 -0600 )edit

Question Tools

Stats

Asked: 2011-06-15 03:35:42 -0600

Seen: 2,405 times

Last updated: Jun 19 '11