Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gazebo system plugins use EntityComponentManager::EachNew in PreUpdate #797

Open
adlarkin opened this issue Apr 29, 2021 · 2 comments
Open
Labels
bug Something isn't working

Comments

@adlarkin
Copy link
Contributor

Environment

  • OS Version: Ubuntu Bionic
  • Source build, Citadel

Description

#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 after Imu'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:

  1. Start a running simulation using sensors.sdf:
ign gazebo sensors.sdf -r
  1. Create an imu sensor from the command line
ign service -s /world/sensors/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 300 --req 'sdf: ''"<?xml version=\"1.0\" ?>''<sdf version=\"1.6\">''<model name=\"spawned_model\">''<link name=\"link\"><sensor name=\"imu\" type=\"imu\"><topic>test_imu</topic></sensor></link>''</model>''</sdf>" ''pose: {position: {z: 10}}'

You'll then see the following error message:

[Err] [Imu.cc:224] Failed to update IMU: 19. Entity not found.
@adlarkin adlarkin added the bug Something isn't working label Apr 29, 2021
@adlarkin
Copy link
Contributor Author

The following issue could also be related: #83

@chapulina
Copy link
Contributor

mjcarroll added a commit that referenced this issue Jul 21, 2022
Split from #1471 to address force-torque sensor incrementally.
Partially addresses #797
Not all sensor system implementations were updated as part of #1281, one of which being the ForceTorqueSensor. This makes the reset behavior incorrect and the sensor won't be respawned.

Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Louise Poubel <[email protected]>
Co-authored-by: Louise Poubel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants