795 points out that EachNew should not be used in system plugin's PreUpdate function, because entities are created during PreUpdate, so depending on the order in which systems are run, calling EachNew in a system's PreUpdate method may result in missing newly created entities. However, there are several system plugins in the ign-gazebo repository that call EachNew in PreUpdate:
Buoyancy
Altimeter
Imu
Contact
Touch
LogicalCamera
AirPressure
LogRecord
Magnetometer
These systems should be updated so that EachNew is not being called in PreUpdate, and we should also probably add/update tests for these systems as needed that spawn entities after startup.
Steps to reproduce
For a concrete example of how/why this is problematic, launch sensors.sdf, which has the UserCommands system come after the Imu system. Then, add an imu sensor from the command line after startup. Since this is processed through UserCommands, which has its PreUpdate run afterImu's PreUpdate, the Imu will not register this sensor (thanks to @chapulina for providing this test case).
Here are the steps to test/reproduce this scenario:
Environment
Description
795 points out that
EachNew
should not be used in system plugin'sPreUpdate
function, because entities are created duringPreUpdate
, so depending on the order in which systems are run, callingEachNew
in a system'sPreUpdate
method may result in missing newly created entities. However, there are several system plugins in theign-gazebo
repository that callEachNew
inPreUpdate
:These systems should be updated so that
EachNew
is not being called inPreUpdate
, and we should also probably add/update tests for these systems as needed that spawn entities after startup.Steps to reproduce
For a concrete example of how/why this is problematic, launch sensors.sdf, which has the
UserCommands
system come after theImu
system. Then, add an imu sensor from the command line after startup. Since this is processed throughUserCommands
, which has itsPreUpdate
run afterImu
'sPreUpdate
, theImu
will not register this sensor (thanks to @chapulina for providing this test case).Here are the steps to test/reproduce this scenario:
sensors.sdf
:You'll then see the following error message: