PX4_HOME_LAT and PX4_HOME_LON not correct when using a heightmap in Gazebo

I’m currently trying to implement a heightmap in Gazebo to have realistic collisions for my drone. However, after exporting PX4_HOME_LAT, PX4_HOME_LON and PX4_HOME_ALT corresponding to the desired position, the drone does not spawn where it should.


Above is the situation without the heightmap, and PX4 working correctly, the drone in in the middle of the bridge.
Below, this is what happen when the heightmap is loaded in Gazebo. The bridge is the red dot on the right. The center of the heightmap is where Gazebo have its origin and also where the drone is.

I’ve tried to correct this by modifying the drone position in the file sitl_run.sh
It’s better but the position is not exact (see below)

To achieve that, I’ve extracted the center coordinates from the geotiff file used to generate the heightmap and after a re-projection (WGS84 to a local North-East-Up Cartesian axis used in Gazebo) I calculate the distance in the x-axis and y-axis. For this I use a python code translated to python from this and based on this paper.

Then, I export PX4_HOME_LAT, PX4_HOME_LON and PX4_HOME_ALT as the coordinates of the center of the heightmap.

The issue lies in these two steps however I have no idea how to proceed to have something differently.

I’ve tried to change the spherical coordinates as specified in the official tutorial here.
However it seems that it does not works with a heightmap, the spherical coordinates are ignored.

I’ve also tried to move the map instead of the drone, to avoid setting PX4_HOME_LAT, PX4_HOME_LON and PX4_HOME_ALT wrong.
However, there is an old bug in Gazebo that create an offset between the visual and the collision model. I tried to get rid of it, without success.

Do you have any idea for me ? I’ll be glad to test them and also add any details needed to understand my issue.

Thanks !

1 Like

Hey @Jaeyoung-Lim, @Benja do you have any idea how to help?

Hello @Benja @Jaeyoung-Lim Did you have the time to have a look at this ?

Hi @A_W , I’m sorry but I cannot help you with this issue.

@A_W This is a bug on Gazebo side: DEM origin overrides spherical coordinate flags defined in .world · Issue #2884 · gazebosim/gazebo-classic · GitHub

1 Like

Thanks ! I’ll try to revive it.