0
$\begingroup$

Rosanswers logo

Actual Issue: I have a topic published with images from a camera and another topic with details of point cloud. When I plot these two topics, there is a time lag between the two plots. Is there any method to synchronize this time lag by adjusting the time stamp of point cloud message?

I am using rosbag play for the above mentioned purpose.

Re-creating the Scenario I tried to simulate the above scenario using the below mentioned points: i. Created a subscriber node which subscribe to the topic(/point_cloud) with point cloud data. ii. Inside the callback function, I copied the message to a new pointer variable of the same type (sensor_msgs::PointCloud2) and incremented the timestamp by 3sec (The debug print shows that the timestamp has been successfully updated). iii. Then I published the modified point cloud data in a new topic(/point_cloud_new). iv. Created two instances of rviz which subscribes to the two topics, /point_cloud and /point_cloud_new respectively. v. Since the timestamp of /point_cloud_new was incremented by 3sec, I expected a 3sec delay between the two plots in the rviz. But it is not happening.

Since I am new to ROS, I am not sure whether it is the correct method to approach this issue. Please comment on the actual issue and the scenario re-created.

Please help me to sort out this issue.


Originally posted by A G on ROS Answers with karma: 18 on 2016-05-13

Post score: 0


Original comments

Comment by Thomas D on 2016-05-13:
When you play the bag file are you setting the parameter use_sim_time to true? That will be a required step for time synchronization when using bag files.

Comment by A G on 2016-05-14:
Yes. I set use_sim_time to true and I am using --clock option while playing the rosbag.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Typically, you use a TimeSynchronizer for this issue. See the wiki for details.


Originally posted by mgruhler with karma: 12390 on 2016-05-13

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by A G on 2016-05-13:
Thanks, mig. I tried the above mentioned option. But it didn't work. Also i found a similar issue in the link mentioned below: http://answers.ros.org/question/146356/synchronise-point-cloud-and-rgb-image-from-the-same-camera/ I even tried with approximate time policy mentioned in the above link.

Comment by A G on 2016-05-15:
An addition to the above comment: When I tried with the TimeSynchronizer and ApproximateTimePolicy method , the behavior was like the callback function was never called.

Comment by A G on 2016-05-18:
Thanks @mig! Approximate time policy mentioned in your link worked. But I have to increment the timestamp of point cloud by 5sec using a subscriber node before passing it on to the TimeSynchronizer. Otherwise the callback function has never been called!

Comment by A G on 2016-05-18:
@mig @Thomas D New issue-If I play rosbag with the loop option,the 1st loop will work,but during 2nd loop,callback function is not called.similar to the issue mentioned in the link http://answers.ros.org/question/106436/usage-of-time-synchronizer-with-rosbag/ Please help me with your suggestions

Comment by mgruhler on 2016-05-18:
can't help you there. Also, for a new issue/question, please open a new one.

Comment by A G on 2016-05-18:
ok. Thanks mig!

Comment by Master_Matrix on 2023-07-21:
Did you find a solution ?

$\endgroup$

Your Answer

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