0
$\begingroup$

Rosanswers logo

I set up a minimum ROS package that demonstrates my issue.

Consider a robot that has two sensors, each sensor publishes to the same topic (i.e. /sensorData) but each sensor populates a different subset of the message.

For example the .msg might be:

int64 sensorAout1
int64 sensorAout2
int64 sensorBout1
int64 sensorBout2

Where sensorA populates the first two fields, and sensorB the last two fields. When a listener node subscribes to this topic, then at any one instant the topic is never fully populated with values from both sensors, instead it switches between the two. For example, the output from the listener node contains the sensorA data but blanks for sensorB and then vice versa.

Is there a way to resolve this? perhaps setting up the sensors as services and a seperate node that packages it all into one topic /sensorData?


Originally posted by vtug2012 on ROS Answers with karma: 21 on 2012-06-08

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

In you setup you don't have any change to detect what data is valid unless it's visible from the data. You could include a flag that says if A or B are valid.

But it seems to me that your setup just isn't properly suited to what you want to do. The better solution would be to only have one message type that contains (out1, out2) and both sensors publish these to topics (sensorA, sensorB) of the same message type. The listener can now match the data sources properly. That obviously also works for different message types (like odom and laser).

Merging those two to one matching data set should then happen by whoever needs these. Depending on how you want to match the data sets, e.g. by timestamp, there are some nice tools in the message_filters package.


Originally posted by dornhege with karma: 31395 on 2012-06-08

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by joq on 2012-06-08:
This is the "standard" ROS solution, and well-supported by the tools.

Comment by SivamPillai on 2012-09-05:
Hi I had a similar situation and I tried by adding the timestamp using ros::Time::now() into my messages. However, the output from synchronization stops after 1 or 2 messages. What can I use for my Timestamp?

$\endgroup$

Your Answer

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