0
$\begingroup$

Rosanswers logo

Hello

I would like to write to a text file different parameters obtained from different topics (scan, raw_imu, odom). I obtained some parameters in different CallBacks like scanCallback poseCallback, imuCallback. I would like to have those output parameters in on file but synchronized (with same frequency, like for example every 1 second.)

I know that can use the commands

myfile.open("/home/user/file.ttx");
myfile << "timestamp" << "....  "\n";

But I cant make it that all output parameters are written in same time stamp. Like for example

time in sec    parameter1   parameter2   parameter3
1                 value      value        value
2                 value      value        value
3                 value      value        value

I know that laser scaner and Imu publish with different frequencies.

Any help?


Originally posted by Astronaut on ROS Answers with karma: 330 on 2013-12-18

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You could try implementing one callback for all three messages using message_filters. You can either use an exact time policy if all topics are exactly in sync or an approximate time policy to allow small differences between their timestamps. An example and a more detailed description is given here:

http://wiki.ros.org/message_filters#Policy-Based_Synchronizer_.5BROS_1.1.2B-.5D

In the callback you could finally write the information you need from your three messages into one txt file.

Best

Tim


Originally posted by timster with karma: 396 on 2013-12-18

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Astronaut on 2013-12-19:
I cant implement one Callback as the ros topics are from different sensors( laser scan, Imu and Odom), So I need three Callbacks.Whats the option if I do not implement one Callback???

Comment by timster on 2014-01-01:
message_filters allow you to use one callback for multiple messages of any type, so it should not matter if the messages come from different sensors... Or did I miss something? Why do you think you have to use three callbacks?

$\endgroup$

Your Answer

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