Open chapulina opened 3 years ago
it may be ok to just skip rendering if there are no listeners regardless of which mode it is in. We did that for CameraSensor in https://github.com/ignitionrobotics/ign-sensors/pull/37 so we maybe able to do the same for other rendering sensors.
Desired behavior
The most expensive action that rendering sensors take is generating data. So that should only be done when necessary, that is, when someone is listening to that sensor data.
It looks to me that the usual use case if to render the scene even if there are no listeners:
https://github.com/ignitionrobotics/ign-sensors/blob/3e486b404ff29b0a9360be9ce9308edc8cd576d9/src/RgbdCameraSensor.cc#L454-L458
However, Ignition Gazebo uses manual updates, so the scene is updated once for all sensors. Manual update is turned on, and rendering happens here. There's a check to see if it's time to update any sensors (according to their update rate), but I didn't see any checks for whether the sensor actually has subscribers. (did I miss anything?)
Implementation suggestion
My suggestion would be to:
I'm focusing on rendering sensors, but this could be beneficial for other sensors as well.
Alternatives considered
Instead of offering an API so that Gazebo can handle this,
ign-sensors
could handle it internally?