Advanced usage of GPS_TYPE=MAV(14)

Hey, forum!


  • ArduCopter V4.3.3 (d68441d6) (-v ArduCopter -f airsim-copter)
  • AirSim environment
  • Algorithm for visual navigation by images (return global location by the image from copter)
  • 2xGPS: GPS_TYPE=1 (AUTO); GPS2_TYPE=14 (MAV)
  • Other related params that I’ve changed:
GPS_TYPE         1
GPS_TYPE2        14

FS_EKF_THRESH    0   (changed to 0 just to Off failsafe actions)
EK2_ENABLE       1
EK3_ENABLE       0

Idea: Fly a drone in RTL mode to the home position and send “fake coordinates” (output from the algorithm) to GPS2 without using base GPS (because of spoofing).

In short: I’m using visual navigation for the copter, which has to send global location to the GPS of the copter. It sends HIL_GPS messages to it, using mavlink protocol. Copter accepts it, I see a signal in the console output, but after switching to the best GPS signal copter writes: AP: GPS Glitch or Compass error. Does anyone have any idea how to do a smoother switch and fly without errors? In advance, Also, I’ve glitch error and now want to try to clear the glitch after every position change.

1 Like

@rmackay9 @Leonardthall Do you have any ideas? Can I fly using GPS_TYPE = 14 and use GPS_TYPE AUTO as proxy?

Hi @Chepa14,

Very interesting. This idea has come up a couple of times before so I’ve created an issue to capture some ideas.

In any case, instead of using a fake GPS, how about using the VISION_POSITION_ESTIMATE message and passing the position in through external navigation (aka AP_VisualOdometry)? The reason is that then you could separately see both the real GPS and picture-based-estimate and switch between them using the EKF transitions logic which would likely handle the change in position which is causing the “GPS glitch” message you’re seeing.

As mentioned in the issue the EKF requires position updates at 4hz or higher. If the camera and comparison algorithm can’t match this speed it might be necessary to augment somehow with a speed estimate (perhaps using high altitude optical flow).

P.S. I’ve moved this issue to the 4.3 category, hope that’s OK.


@rmackay9 Thanks for the answer
So using VISION_POSITION_ESTIMATE I’ll be able to point to the drone where he is located? Do I need to set up something else for it? (Like external camera or else)?
If yes, can I somehow run it virtually? :slightly_smiling_face:


SITL has a built-in virtual vicon. Setup instructions are here.

I guess you will need to enhance your, “Algorithm for visual navigation by images” so that it can output the VISUAL_POSITION_ESTIMATE mavlink messages and send them into ardupilot though a serial port somehow.

What you’re attempting to do is somewhat similar to how AP uses an Intel T265 or ModalAI VOXL camera.

Hope that helps…

@rmackay9 Do I have any chances to deal with GPS_TYPE = MAV instead of an additional camera? Because it’s not going by my plan (to add another camera) :upside_down_face:


If you set GPS_TYPE2 = MAV then the positions (and velocities if available) will need to be sent into AP using the GPS_INPUT message.

I would guess that next you could use GPS_AUTO_SWITCH = 0 (Use Primary) and then switch between the two by changing GPS_PRIMARY to 0 or 1 and I think the EKF will handle the switch without glitching (maybe).

Another possibility is to use sensor affinity to tie each GPS to a different EKF lane but then the issue becomes how to decide which EKF lane to fly with.

1 Like

@rmackay9 Hey. Do you have any ideas why my autopilot calculates these crazy coordinates (note that I’m passing another GPS coordinates):

Global Position Int: GLOBAL_POSITION_INT {time_boot_ms : 277991, lat : -137603452, lon : 1621121060, alt : 267000, relative_alt : 95070, vx : -10, vy : 9, vz : 0, hdg : 276}
* Sending new coordinates *
Global Frame: LocationGlobal:lat=-13.7603452,lon=162.112106,alt=267.0
Global Position Int: GLOBAL_POSITION_INT {time_boot_ms : 278243, lat : -137603452, lon : 714996490, alt : 266990, relative_alt : 95066, vx : -35, vy : -44, vz : 4, hdg : 61}

And in the following logs, I see only lon changes. It possibly can be a memory thrash, but I’m not sure - what do you think?

@rmackay9 Sorry for spamming, any ideas? :sweat: