gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.19k stars 480 forks source link

DEM origin overrides spherical coordinate flags defined in .world #2884

Open Jaeyoung-Lim opened 3 years ago

Jaeyoung-Lim commented 3 years ago

Problem Description When using DEM models that have the global origin in the meta data, it is not possible to override the world location using the spherical_coordinates tag in the sdf file(world).

Even if the spherical_coordinates are modified, the world->SphericalCoords() returns the origin of the DEM file, not the origin defined with the spherical_coordinates flag.

It seems like gazebo overrides the spherical coordinate defined in the world file and uses the origin of the DEM if I understand correctly the following.

https://github.com/osrf/gazebo/blob/063d7386ed5499c2883de48e19ff5fb9dec01dff/gazebo/physics/HeightmapShape.cc#L109-L131

    // Modify the reference geotedic latitude/longitude.
    // A GPS sensor will use the real georeferenced coordinates of the terrain.
    common::SphericalCoordinatesPtr sphericalCoordinates;
    sphericalCoordinates = this->world->SphericalCoords();

    if (sphericalCoordinates)
    {
      ignition::math::Angle latitude, longitude;
      double elevation;

      this->dem.GetGeoReferenceOrigin(latitude, longitude);
      elevation = this->dem.GetElevation(0.0, 0.0);

      sphericalCoordinates->SetLatitudeReference(latitude);
      sphericalCoordinates->SetLongitudeReference(longitude);
      sphericalCoordinates->SetElevationReference(elevation);
      sphericalCoordinates.reset();
    }
    else
      gzerr << "Unable to get a valid SphericalCoordinates pointer\n";

    return 0;
  }

Expected behavior

@ahcorde FYI

Additional Context

Jaeyoung-Lim commented 3 years ago

@chapulina @ahcorde @tfoote Would any one know how to move forward regarding this issue?

Vicidel commented 1 year ago

Hello all. I know this issue is quite old, but the bug seems to be still happening. See for example this issue in PX4 forum. Pinging recent contributors @chapulina @scpeters @iche033, anything you can do would help me.

tfoote commented 1 year ago

The best way to push this forward would be to open a PR with the expected behavior.