ROS2 Lidar wrong tick source
The Ros2 lidar sensor is using TickBasedSource wich is not precise. Since the lidar only relies on physics it should use PhysicsBasedSource wich permits to publish at a precise frequency.
Results with TickBasedSource
class ROS2Lidar2DSensorComponent : public ROS2SensorComponentBase<TickBasedSource>
ceccocats@aron:~$ ros2 topic hz /scan -w 10
average rate: 9.123
min: 0.075s max: 0.121s std dev: 0.01262s window: 10
average rate: 10.161
min: 0.021s max: 0.116s std dev: 0.02784s window: 10
average rate: 8.629
min: 0.103s max: 0.130s std dev: 0.00799s window: 10
average rate: 8.747
min: 0.105s max: 0.128s std dev: 0.00662s window: 10
Results with PhysicsBasedSource
class ROS2Lidar2DSensorComponent : public ROS2SensorComponentBase<PhysicsBasedSource>
ceccocats@aron:~$ ros2 topic hz /scan -w 10
average rate: 10.000
min: 0.099s max: 0.101s std dev: 0.00054s window: 10
average rate: 10.009
min: 0.099s max: 0.100s std dev: 0.00038s window: 10
average rate: 9.999
min: 0.100s max: 0.100s std dev: 0.00007s window: 10
average rate: 9.999
min: 0.100s max: 0.100s std dev: 0.00012s window: 10
Im using main branch but i have checked also dev branch and it seems to also use TickBasedSource. https://github.com/o3de/o3de-extras/blob/f18a22fce5cc89095ca416a3839e37aa33d5eb79/Gems/ROS2/Code/Source/Lidar/ROS2Lidar2DSensorComponent.h#L28
Thank you for rising the issue and for checking both branches.
We are aware of some problems with the timing of the sensors, please see this PR: https://github.com/o3de/o3de-extras/pull/807 I will assign the author of the PR above to this task as related, so he can joint the conversation
Hello @ceccocats , PR https://github.com/o3de/o3de-extras/pull/807 will partially resolve this issue. With physics ticks triggering and physics ticks running clock would be no deviation caused by GPU frame time. Hover both implementation (RGL and scene queries) uses AZFramework API. This API provides us with data that is updated with GPU. It can give results that is exactly the same (especially when we require Lidar simulation with high frequency)
I will open PR set @ceccocats as co-athor (it will be one line):
class ROS2Lidar2DSensorComponent : public ROS2SensorComponentBase<PhysicsBasedSource>
and add all parties (O3DE side and RGL side) to review.
Lidar2d is not the only that use TickBasedSource, here is a list:
- ROS2GNSSSensorComponent
- ROS2LidarSensorComponent
- ROS2Lidar2DSensorComponent (tested and working)
- ROS2ContactSensorComponent
- ROS2CameraSensorComponent (is it possible or it needs to run at rendering frequency?)