morse-simulator / morse

The Modular OpenRobots Simulation Engine
http://morse-simulator.github.io/
Other
350 stars 155 forks source link

Time drift between 'MORSE time' and 'ROS time' #783

Open warp1337 opened 6 years ago

warp1337 commented 6 years ago

When running MORSE for some time, like 1 hour (or so) I noticed that the time stamp of ROS images (e.g. video camera) differs from what the actual ROS time says.

Add a fakerobot and e.g. this snippet:

videocamera_top = VideoCamera()
videocamera_top.properties(cam_width=640,
                           cam_height=480,
                           capturing=True,
                           Vertical_Flip=True,
                           cam_near=0.01)
videocamera_top.frequency(CAM_FREQUENCY)
videocamera_top.add_interface("ros", topic="/pepper_robot/camera/front/",
                              topic_suffix='image_raw',
                              frame_id='CameraTop_optical_frame',
                              parent_frame_id='Head',
                              pub_tf=False)
fakerobot_topcam.append(videocamera_top)

This is a little hard to reproduce since I have vision pipeline that copies headers from one message to another and then computes diverse TF transforms. However, the basis time stamp is the one of the source image generated by MORSE --- the one that drifts over time.

I also believe I have found the problem:

https://github.com/morse-simulator/morse/blob/master/src/morse/middleware/ros/abstract_ros.py#L112

If you replace that line with rospy.Time.now() everything seems to be fine again. I am currently running a longer test, but it might be a good idea to reproduce this.

Cheers, Flo

warp1337 commented 6 years ago

Okay confirmed. Using rospy.Time.now() fixes the problem. At least for me. @severin-lemaignan @pierriko

adegroote commented 6 years ago

Who generate /clock ? Do you use /use_sim_time ? I check the code, and there is maybe some issue, but clock and sensors use the same source of infromation (parent.gettime()), so the information should be consistent (if you use simulated time generated by Morse).