Fix sensor update rate throttling when new sensors are spawned #2784
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is an issue with sensor manager's update loop throttling. When a world is loaded, the sensor manager figures out the max update rate from all the sensors in the world. However, when a new sensor is spawned after the world is loaded, this max update rate is never updated. This causes a problem for example when later spawning a sensor with an update rate higher than all the existing sensors in the world, this new sensor would never hit its target update rate.
This PR adds a flag (global variable,
g_sensorsDirty
, to avoid breaking ABI) to detect when sensors are added or removed, and recalcuates the sensor manager's max update rate when the flag is dirty.The bug only affects non-rendering sensors, e.g. imu, ray sensor, etc
To manually test this, you can:
hokuyo
model from gazebo model database, e.g. by inserting it from gazebo's Insert tab on the left~/.gazebo/models/hokuyo
to~/.gazebo/models/hokuyo_new
and change the update rate inmodel.sdf
and also remember to give it a new name inmodel.config
LaserStamped
msg typeSigned-off-by: Ian Chen [email protected]