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_AUTO_CONFIG 2
GPS_AUTO_SWITCH 1
GPS_TYPE 1
GPS_TYPE2 14
GPS_PRIMARY 0
FS_EKF_THRESH 0 (changed to 0 just to Off failsafe actions)
AHRS_GPS_USE 2
AHRS_EKF_TYPE 0
EK2_ENABLE 1
EK3_ENABLE 0
FS_EKF_ACTION 2
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.
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?
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.
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.
@rmackay9 hi,We are also doing image navigation, but image navigation can only provide GPS coordinates without velocity (vx vy v speed, all given as 0). Therefore, when doing mavGPS, we wrote the following output GPS coordinates with fixtype written as 3 and hdop written as 0.7. However, we found that in auto mode, the drone keeps flying in a straight line and cannot fly according to the planned route. What is the problem?