-
Notifications
You must be signed in to change notification settings - Fork 266
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
Optimize sensor updates #1480
Optimize sensor updates #1480
Conversation
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
|
@osrf-jenkins run tests please! |
Codecov Report
@@ Coverage Diff @@
## ign-gazebo6 #1480 +/- ##
============================================
Coverage 33.58% 33.58%
============================================
Files 44 44
Lines 2260 2260
============================================
Hits 759 759
Misses 1501 1501 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of minor comments.
Signed-off-by: Ian Chen <[email protected]>
@iche033 |
ok yeah I'll take a look |
Thanks! Yes, I think |
🦟 Bug fix
Depends on gazebosim/gz-sensors#222
Summary
This PR optimizes sensor updates by avoiding any unnecessary computation when:
For non-rendering sensors, before these changes, the sensors themselves are throttled correctly but we are still doing updates (copying data from sim to sensor object) every iteration in
PostUpdate
function.For rendering sensors, i.e. sensors system, I noticed that the
RGBDCameraSensor
andGpuLidarSensor
are still doing updates when there are no subscribers so I added the check in the sensors system.After these changes, the
sensors_demo.sdf
world gives me consistent ~9x% RTF after closing allImageDisplay
s. Before the changes, the RTF still fluctuates between 3x% to 8x% after closing theImageDisplay
s (becauseGpuLidarSensor
andRGBDCameraSensor
are still updating)I verified the behavior by enabling remotery in ign-sensors. Below are outputs from running
sensors_demo.sdf
world.The output below shows the sensor updates after the
sensors_demo.sdf
world is launched and running. We see thatGpuLidarSensor
is no longer updating because there are no subscribers. On the other hand, all the other rendering sensors are updating because there areImageDisplay
s connecting to the sensors.The output below shows the result after closing the RGBD cameras and thermal camera's
ImageDisplay
s. Now only the depth and regular camera are updating, which is the desired behavior.Alternatives considered
The alternative approach, which I implemented but then reverted, was to check for connection count inside the sensor classes in ign-sensors. The main reason I didn't go with this approach is because classes like
Lidar
(whichGpuLidarSensor
is derived from) also offers Ranges APIs to get range data directly. If I skipped updates when there are no connections,Ranges
returned invalid / empty data, and that broke integration tests.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.