Way to change SITL starting GPS coordinates?

Hi, I’m looking for a convenient way to change the initial GPS coordinates of the firmware in SITL mode with Gazebo so it does not always begin in Zurich. Ideally, I’d like to be able to set a couple environment variables with my desired GPS coordinates that the sim will use to start with a custom GPS location. I’m no expert at the way the gps in the simulator is handled, but I did some digging in the code to see that the sim gps in PX4 is essentially getting HIL MAVLink messages from Gazebo’s MAVLink interface lib. Looking at PX4’s SITL Gazebo repo I noticed Zurich Irchel Park was hardcoded in there, when I changed that I was able to get my desired custom starting location. Is there a way to start the sim with a different latitude, longitude, and altitude without actually modifying this source code?

Thanks.

2 Likes

Read it from an SDF?

http://dev.px4.io/en/simulation/gazebo.html#set-custom-takeoff-location

@Geo where is this file located in the Gazebo. Mavlink interface lib to change the home location

Updated location of documentation: