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

Don't generate sensor data if no one is listening #147

Open
chapulina opened this issue Jul 26, 2021 · 1 comment
Open

Don't generate sensor data if no one is listening #147

chapulina opened this issue Jul 26, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed performance Runtime performance

Comments

@chapulina
Copy link
Contributor

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:

  1. When not in manual mode, don't render sensors unless there are listeners
  2. For manual mode, add API that allows applications like Gazebo check if a sensor currently has listeners or not, and use that on the Sensors system to skip unnecessary renders

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?

@chapulina chapulina added enhancement New feature or request performance Runtime performance labels Jul 26, 2021
@iche033
Copy link
Contributor

iche033 commented Jul 26, 2021

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 #37 so we maybe able to do the same for other rendering sensors.

@chapulina chapulina added the help wanted Extra attention is needed label Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed performance Runtime performance
Projects
None yet
Development

No branches or pull requests

3 participants