Open traversaro opened 10 months ago
Interestingly, the non-deterministic reading of sensors described in this issue is actually documented in https://gazebosim.org/api/gazebo/7.0/ardupilot.html , so it would be interesting to understand if it can be avoided.
Other related issues:
Indeed, I guess that https://github.com/gazebosim/gz-sim/issues/2268 is a prerequisite for this.
For what regards FT sensors, we could use https://github.com/gazebosim/gz-sensors/pull/449 on the gz-sensors/gz-sim versions that will support it.
We are experiencing many flaky errors in gz-sim-yarp-plugins tests:
To be honest, I did not looked a lot into those back in time when I opened the issue. However, as @xela-95 started working in the repo, I noticed that most sensor plugins are actually using the gz's gz-transport (i.e. ZeroMQ + ProtoBuf) functionality to actually access sensors. To give an example, let's look at the forcetorque plugin. Before the first step of simulation, a connection via gz-transport is established in the main physics thread of gz-sim by the following snippet of code (from https://github.com/robotology/gz-sim-yarp-plugins/blob/25216f1c90ed524a30b664e7cc327b368eb2d649/plugins/forcetorque/ForceTorque.cc#L139):
This will call the
ForceTorque::ftCb
callback once a message is received, that will actually just do:However, this will happen (from what I understand) in a thread different from the main physics thread.
Then, after the update of the physics, the following code again in the main physics thread reads the ft values (that are just ~6 doubles) from the buffer that was populated by
ftCb
:What is the problem here? The main problem for our use cases that after we after we run a given step N of simulation, we do not have any idea if
forceTorqueData.m_data
actually contains the FT readings of stepN
, or of some other stepN-m
. The actual value contained inforceTorqueData.m_data
depends on the operating system scheduled, and weather it actually scheduled the thread that is callingftCb
, so in general it is something non deterministic.This is effectively a regression w.r.t. to gazebo-yarp-plugins (the yarp plugins for Gazebo Classic), so ideally we would like to try to fix this somehow, at least for sensors whose simulations is lightweight (for example
forcetorque
andimu
, forcamera
andlaser
the situation may be more complex as the rendering itself could occur in a thread different from the main physics thread.First of all, we should understand if this is possible at all in Gazebo Harmonic, and if it is not we should explore how to modify Gazebo libraries upstream to permit this.