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

Warn instead of fail for non-Earth Dem's on 20.04 (#2828) #2882

Merged
merged 7 commits into from
Nov 24, 2020

Conversation

scpeters
Copy link
Member

A test failure related to the gazebo::common::Dem class on Ubuntu 20.04 was reported in #2828 and seems to be caused by loading Dem's that are based on a celestial body other than earth. The code doesn't fail like this in 18.04 (though I believe it computes Dem sizes incorrectly as reported in #2881) but it is now failing in 20.04 by returning a nullptr from OGRCreateCoordinateTransformation if the source and target coordinate reference systems refer to different celestial bodies. Since Dem::GetGeoReference returns void instead of bool, I've added a gzthrow to that function if the coordinate transformation is unsuccessful along with try / catch blocks that print gzwarn console messages in the two places that call this API:

  1. Dem::Load calls Dem::GetGeoReference for the corners of the Dem to compute the size
  2. HeightmapShape::LoadTerrainFile calls Dem::GetGeoReferenceOrigin in order to configure the SphericalCoordinates class used by the gazebo gui and the GpsSensor

The UNIT_Dem_TEST will still fail on 20.04 with these changes, but at least it won't crash.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Wrap calls to Dem::GetGeoReference and Dem::GetGeoReferenceOrigin
in a try/catch block and print error messages if exceptions are
caught. The Dem_TEST is still broken, but this prevents crashes.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Also reduce some whitespace in exception messages

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Copy link

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chapulina chapulina added the 11 Gazebo 11 label Nov 23, 2020
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I just have a couple of suggestions about the exception messages. Also, we should consider documenting that some functions may throw.

gazebo/physics/HeightmapShape.cc Outdated Show resolved Hide resolved
gazebo/common/Dem.cc Show resolved Hide resolved
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters merged commit d133984 into gazebosim:gazebo11 Nov 24, 2020
@scpeters scpeters deleted the issue_2828 branch November 24, 2020 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
11 Gazebo 11
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants