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

McMillan Airfield GPS origin is not correct #43

Open
Jaeyoung-Lim opened this issue May 18, 2020 · 7 comments
Open

McMillan Airfield GPS origin is not correct #43

Jaeyoung-Lim opened this issue May 18, 2020 · 7 comments

Comments

@Jaeyoung-Lim
Copy link

When comparing to the map, the origin of the GPS coordinates are not correct and seems to be off a few hundred meters.

I tried fixing this comparing on google maps, but changing
https://github.com/PX4/sitl_gazebo/blob/12da9e6104aaf72a0c52bf802644310f0c5b1ee1/worlds/mcmillan_airfield.world#L18-L23

Didn't have an effect on setting the gps origins. It seems like https://github.com/PX4/sitl_gazebo/blob/master/src/gazebo_gps_plugin.cpp#L51 is not able to be modified.

@ahcorde Is there somewhere else that the world origins are set?

Cross posted from PX4/PX4-SITL_gazebo-classic#496

@issouker97
Copy link

Hi , unfortunately i don't have any reply for your question , in the other hand i want to add person_walking i clone it but i don't know how to launch it in gazebo , actually i need the command to launch it , i would be grateful if you could help me

@Jaeyoung-Lim
Copy link
Author

Jaeyoung-Lim commented Jul 25, 2020

@issouker97 I believe your issue is not related to your issue. Please don't hijack the topic of this thread

@Jaeyoung-Lim
Copy link
Author

@ahcorde Could you shed any light on this issue?

@ahcorde
Copy link
Contributor

ahcorde commented Aug 13, 2020

The tags that you mentioned are being readed in the Gazebo code ( in the world class ).

In the plugin you need to setup some env vars:

 // Use environment variables if set for home position.
  const char *env_lat = std::getenv("PX4_HOME_LAT");
  const char *env_lon = std::getenv("PX4_HOME_LON");
  const char *env_alt = std::getenv("PX4_HOME_ALT");

@Jaeyoung-Lim
Copy link
Author

Jaeyoung-Lim commented Aug 13, 2020

@ahcorde Without the environment variables, it reads from the worldfile with https://github.com/PX4/sitl_gazebo/blob/master/src/gazebo_gps_plugin.cpp#L105, However even if I change the spherical coordinates in https://github.com/PX4/sitl_gazebo/blob/master/worlds/mcmillan_airfield.world#L20 the returned value doesn't change

Therefore, the problem is that the return value from

  gazebo::common::SphericalCoordinatesPtr spherical_coords = world->SphericalCoords();

Doesn't seem to reflect the tag properly from the world file.

@Jaeyoung-Lim
Copy link
Author

@ahcorde I can confirm that when reading the spherical coordinates from the world object, it returns the origin set from the mcmillan_airfield.tif file and not the one that is defined in the .world file

@Jaeyoung-Lim
Copy link
Author

Jaeyoung-Lim commented Nov 17, 2020

@ahcorde 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.

If this is the default behavior, this would explain the issues that I have been seeing.

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;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants