Gazebo and SITL Map/World Synchronization


I’ve generated a .tif file of my college and created a world file on gazebo. My goal is to do simple missions with the Software In the Loop and/or Mission Planner, but I’m stuck in a problem that I couldn’t really find a solution.

To illustrate the problem, I’ve positioned the ArduCopter in a location in the Gazebo World that is basically the same one that the Software In The Loop is initializing, just like in the next two pictures:

But when I try to send the drone to a direction, like the drawn in the SITL picture, the drone in Gazebo moves towards a different direction. There is something that I can do to handle with it?

Gazebo uses a different XYZ ordering to ArduPilot. I believe you need to rotate the maps/terrian 270 degrees (in yaw) to have it line up with Aurdpilot.

I’ve tried to rotate the terrain itself, as you said, with the pose command in my SDF file, but looks like it doesn’t work with heightmaps…

Correct. Known issue with Gazebo.

You’ll need to find a software package to rotate it for you.

Here’s a script I made to rotate heightmaps (in tif format):

Thank you so much, @stephendade!

I was trying to use your script and I’m getting this error:

Traceback (most recent call last):
File “./”, line 42, in
dst_ds.GetRasterBand(1).WriteArray( array_rot270 )
File “/usr/lib/python3/dist-packages/osgeo/”, line 2547, in WriteArray
callback_data = callback_data )
File “/usr/lib/python3/dist-packages/osgeo/”, line 381, in BandWriteArray
raise ValueError(“array larger than output file, or offset off edge”)
ValueError: array larger than output file, or offset off edge

Does anything like that have ever happened to you?

I think the input heightmap needs to be an exact square (same number of rows and columns). It’s been a while since I’ve used the script.