-
Notifications
You must be signed in to change notification settings - Fork 39
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
DEM: Add support for GDAL vsicurl, vsizip support and avoid segfaults with huge VRT datasets #597
DEM: Add support for GDAL vsicurl, vsizip support and avoid segfaults with huge VRT datasets #597
Conversation
@ahcorde Would you be able to provide another round of feedback on the functionality of this PR. I'm looking for some direction on how to best contribute my time to Gazebo's support of terrain data. We can use Gazebo for outdoor 3D aerial robotics applications that the aerial working group is currently working on. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## gz-common5 #597 +/- ##
==============================================
- Coverage 83.65% 80.54% -3.11%
==============================================
Files 90 93 +3
Lines 10273 13617 +3344
==============================================
+ Hits 8594 10968 +2374
- Misses 1679 2649 +970 ☔ View full report in Codecov by Sentry. |
c001ba1
to
9d02aba
Compare
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.
Looks great! Thanks for the contribution. I have a few comments, but they should all be easy to address.
@@ -134,6 +146,8 @@ namespace gz | |||
gz::math::Angle &_latitude, | |||
gz::math::Angle &_longitude) const; | |||
|
|||
private: [[nodiscard]] bool ConfigureLoadedSize(); |
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.
Can this be placed in Dem::Implementation
instead? Also can you document the function?
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.
Yes, done! That made the code a lot cleaner too.
common::Dem dem; | ||
auto const path = common::testing::TestFile("data", "ap_srtm1.vrt"); | ||
// We expect not to be able to allocate the data, so ensure we throw instead of segfault. | ||
EXPECT_THROW(dem.Load(path), std::bad_alloc); |
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.
Is this actually causing Dem::Load
to allocate more memory than available? I'm not sure if we want to do this in a unit test if it might badly affect other things running on CI.
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.
Yes, it immediately throws on my machine, and then gtest catches it. I ran all the tests, and they seem reliable with it.
If you are concerned, what about a GTEST_SKIP
so it's still compiled and able to be run manually if you desire?
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.
CI is failing on macOS with a timeout so the behavior may not be the same on all platforms, so I'd prefer we use GTEST_SKIP
as you suggested.
Also, please merge from |
@Ryanf55 we are now in Feature freeze for Gazebo Ionic. Since PR is already open, I've applied the |
Thanks for the heads up, I'll do my best to make time over the next 2 days. |
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.
@azeey I've implemented all of your requests. This is ready for final approval, hopefully before the official release.
@@ -134,6 +146,8 @@ namespace gz | |||
gz::math::Angle &_latitude, | |||
gz::math::Angle &_longitude) const; | |||
|
|||
private: [[nodiscard]] bool ConfigureLoadedSize(); |
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.
Yes, done! That made the code a lot cleaner too.
common::Dem dem; | ||
auto const path = common::testing::TestFile("data", "ap_srtm1.vrt"); | ||
// We expect not to be able to allocate the data, so ensure we throw instead of segfault. | ||
EXPECT_THROW(dem.Load(path), std::bad_alloc); |
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.
Yes, it immediately throws on my machine, and then gtest catches it. I ran all the tests, and they seem reliable with it.
If you are concerned, what about a GTEST_SKIP
so it's still compiled and able to be run manually if you desire?
* Can now use GDAL vsicurl and GDAL vsizip features * There is a new API to set loaded size limits to prevent segfaults from loading too big of a raster terrain * For now, there is no configured way to change where in the large raster to load data from Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Ryan <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Ryan <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
* Add a VRT test file * Add a zipped VRT test file * Don't rely on internet for tests to pass Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
Co-authored-by: Addisu Z. Taddese <[email protected]> Signed-off-by: Ryan <[email protected]>
* Enforce linter and naming conventions * Add missing getters for size limits and test them * Enforce 80char column limit * Move ConfigureLoadedSize to the implementation * Document all functions * Fix lambda name case Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
5e03fc3
to
b722c57
Compare
Rebase complete. |
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 with green CI!
Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
🎉 New feature
Closes #596
Summary
vsizip
andvsicurl
that aren't true filepaths.Test it
I added a unit test which is self explanatory.
I also hacked a demo with one SRTMHGT file, and confirmed it can load. Gazebo does not perform well with this terrain size (3601 x 3601), but it does load. SDF needs ability to truncate the size of the heightmap in order to be usable, or perhaps decimate the data resolution.
Open Questions
How do we want the logs to look? Perhaps queue the errors and only report them if the DEM loading fails.
Do we need to solve user-configurable origin to load? The previous implementation loaded everything in the raster, so there was nothing to configure
Should we rely on ArduPilot's terrain server being up for the test, or generate a large in-memory dataset for testing large rasters?
Future Improvements
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.