0
$\begingroup$

Rosanswers logo

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?


Originally posted by robzz on ROS Answers with karma: 328 on 2013-06-24

Post score: 0


Original comments

Comment by lindzey on 2013-06-24:
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?

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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!


Originally posted by Johannes Mayr with karma: 81 on 2013-06-24

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by liborw with karma: 801 on 2013-06-24

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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