GPS and POS diverge

I hope somene can explain this to me. Why does the GPS and POS readings diverge after the EKF3 starts using GPS data? See attached picture. I want to trust the actual GPS solutions since I’m using an RTK GPS system. But I also know that POS outputs a fused solution using IMU data. Which one should I trust for true absolute position? How can I make POS follow GPS readings more closely? Thanks!

Can you supply a .bin log?
Usually the IMU-calculated position varies from the GPS position when there are excessive vibrations

1 Like

@xfacta the readings you see in the plot is when the drone is sitting on the ground after boot up. The drone won’t let me take off until EKF3 starts using GPS.

Here is the log file: GPS_POS_diverge-anon.log

I still do know if I should trust the fused solution from POS over RTK GPS readings alone. Anyone please?

Sorry - I downloaded you log and started looking but got busy elsewhere.
I’ll try to get something to you later today

1 Like

This is my guess from what I can see in the code and your log - I could be very wrong and a more experienced person may say so and offer a better explanation.

To me it looks like while the GPS position is less trustworthy at the start, EKF allows the GPS position and IMU position to be merged, which seems a bit counter-intuitive but is still the best behaviour. As the GPS position gains accuracy the two positions diverge because the GPS has settled in a new location and the IMUs are still at the original location because no actual movement has been detected (accelerations).
From this point onwards I think the distance between GPS mast and flight controller IMUs plays a role, because both positions are now highly accurate and verifiably in different positions.
You wouldnt get this effect without an RTK system, the GPS position would never really be accurate enough for the EKF to believe such small differences in position. I’ve checked through a few of my non-RTK logs and there is never this same type of divergence.

If you can send a log with flight that would be interesting - to see if the EKF merges those two positions or continues to keep them separated.

If the copter is large it will be worth while setting the GPS offset positions

GPS_POS1_X,0
GPS_POS1_Y,0
GPS_POS1_Z,0

Note this measurement is in METERS ! so for a difference of 12cm between flight controller and GPS the value would be 0.12
EDIT: I see you did set these - good work!

1 Like

@xfacta yes, I also think this is how the EKF works. I wonder if this offset can be calculated based on the initial GPS position the EKF uses right after boot-up. I trust the absolute accuracy of the GPS but I also want the advantages of the position estimates of the EKF (like faster sampling). Let me know if you have an idea of how to compute the offset using data from the log file.

The EKF will give the faster highly accurate position - it extrapolates or predicts the position and changes between GPS data updates based on accel and gyro inputs.

You just measure and put those GPS position offsets manually. That way the position reported should be exactly where the flight controller is - not where the GPS antenna is.
Usually the flight controller is mounted more centrally than the GPS antenna, so this should better represent the position of the copter.
If you look at the GPS position in logs → that will be where the GPS antenna is.
I believe that is the effect we’re seeing in your provided log - the difference between the GPS antenna position and the calculated FC position.

So you should be relying on POS.lat and POS.lng

1 Like