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

Collecting data from multiple topics

asked 2013-06-24 19:07:56 -0600

robzz gravatar image

updated 2013-06-24 19:08:40 -0600

I'm designing a node in my system that needs to gather data from two topics (A and B), process it, and publish the results to another topic. I've considered a few implementation alternatives considering migrating to services, using fixed-rate loops, and retaining the data that a topic handler last received. Here are a few alternatives:

  1. Create a handler for each topic. In a loop running at a fixed rate, publish the results using the data that was last received for each topic.
  2. Create a handler for each topic. In handler A, publish results using the data from received in that handler with the data that was last received from handler B.
  3. Migrate topic A to be a getter service instead. In the handler for topic B, publish results using the data received in that handler and the data received from a call to the new service.

Which method is best? Is there a better way to do this?

edit retag flag offensive close merge delete

Comments

1

The best way to do this will depend on your requirements for the data - if you get three messages on topic B and one on A for a given time frame, do you want to publish a single message with the most recent from each, or 3 messages, one for each B? Does the output need to come at a given rate?

lindzey gravatar image lindzey  ( 2013-06-24 19:41:23 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-06-24 21:46:57 -0600

Johannes Mayr gravatar image

As lindzey wrote this strongly depends on your needs. Option (1) can result in messages from topic A or B which are not considered for the published topic if they are received faster than your loop sample time.

Option (3) does not really makes sense to me. The results should be the same as Option(2) when you use message B as trigger for publishing a new topic.

An other option would be to use two handlers and publishing a message if either A or B was received. But this would lead to many dublicated messages published. If you receive A and B directly after each other you would first publish with A and the old B and then with A and B.

The best solution depens stronly on your needs!

edit flag offensive delete link more
1

answered 2013-06-24 22:46:20 -0600

liborw gravatar image

If the data from A and B are timestamped and should be synced look into message_filters package on Time Synchronizer.

If time is not important I would make handler for each topic and handler for both. The topic handler will save message into temp var and if bot temp vars are filled call the aggregated handler and clear both temp vars.

Hope it is clear enough.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-24 19:07:56 -0600

Seen: 1,724 times

Last updated: Jun 24 '13