cyberbotics / webots

Webots Robot Simulator

Home Page:https://cyberbotics.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ROS sensor messages from the same update have slightly different timestamps

lucasw opened this issue · comments

Describe the Bug

Sensors all have slightly different timestamps even though their data is from the same sim update step. Perhaps this is desirable behavior, adds realistic noise to the system, so a fix could be made optional, though in my case I'm building an Odometry message out of gyro, gps, & inertial sensors so I'd like them to be exactly synchronized rather than approximately.

Using an approximate time sync message filter in ros is a workaround, but I'd rather synchronize right at the source.

Instead of assigning a new ros::Time::now() per sensor right before it publishes (https://github.com/cyberbotics/webots/blob/master/projects/default/controllers/ros/RosGyro.cpp#L40), set a single timestamp in the root sensor update method and pass it down to each sensor publish.

It looks easy enough so I'll do it myself in a few days, though it'll be a lot of 1-2 changes across many files to provide a stamp to every publish method.

Steps to Reproduce

Put multiple sensors on a vehicle and publish them to ros.

Expected behavior

Exact same timestamps from sensors with same update period.

Screenshots

None

System

  • Operating System: NA
  • Graphics Card: NA

Additional context

None

Yes, that seems to be a good default behavior. Please go ahead with the implementation and open a PR that we will review.