Switching to the betterGPS, HIL GPS as Primary and Real GPS Secondary

Hello @rmackay9. I have a question for you, because you and your team added the GPS blend capability (thank you!).

We are working on a drone that uses a primary HIL GPS (using a visual source) and a secondary Ublox GPS. We had the GPS_AUTO_SWITCH set to 1 for “usebest,” but that doens’t seem to be working. According to the comments in the code https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_GPS/AP_GPS.cpp#L747, the switching is done based on number of sats.

We played around with HIL GPS’s Nsat between 0 and 50, but it wasn’t switching. The ublox GPS had a HDOP was around 1-1.5 and the HIL GPS HDOP was at 0, sat artificially of course.

Can you please explain how we can make the GPS sources switch?

Thanks in advance!


I think it uses the GPS state (i.e. 3=GPS Lock, 4=DGPS, 5=RTK Float, 6=RTK Fixed) and then the number of satellites. So maybe it’s the state that is the issue?


I did not know that the GPS status can go up to 6 :slight_smile: we will play around with that.

I uploaded the log to my google drive and hopefully this can show you what was going on. This is a static test, in which we had GPS 1 as a Ublox and GPS 2 as HIL GPS. At around 3 min mark, both GPS sources had a status of 3. Even then, the HIL GPS with 50 sats did not get selected. Is there something we don’t realize?




Sorry to bother you like this, but it still didn’t work after we artificially set the HIL GPS status to 5.

You can see the log here under the file “NSAT and STATUS.”


Perhaps the right question to ask is, can we use a Mavlink command to select the GPS source during flight?

Thanks a lot!