POS message and Secondary GPS

From what I’ve heard, the POS message contains the most reliable estimate of the vehicle’s position which is calculated from GPS and Accelerometer data. The POS data is used in the CAM message whenever the signal is sent to the camera to take a picture.

My question is, does the POS message use just the GPS1 Data? If I use a secondary GPS, Can I make sure that the GPS2 Data is used instead for the POS messages?

Or, How exactly is the POS message calculated? Can I Do the same math later by analysing the logs?


1 Like

I’m not a dev, so I hope I have this right:

Short answer: POS is the estimate of position from the best available estimation-filter. It is difficult to reproduce this estimate by-math, but possible.

Longer answer: The POS message gets data from the call: ahrs.get_position(). What exactly the “ahrs” is depends on the available amount of computation and version of the firmware. On a fully-capable hardware platform (PixHawk) it’s the highest-complexity (read “best”) estimation filter, unless that filter hits some math error, in which case it’s second choice is the solution from a lower-complexity (simpler = not-as-good, but better than nothing!) estimation filter. I think with Plane 3.8 that NavEKF3 becomes the “best filter”, but with Plane 3.7 and earlier NavEKF2 was the best.

The GPS measurement is one of the key (arguably THE most important) measurement that drives the filter’s estimate. So the filter’s estimate will largely agree with GPS, but should not be identical. If you want the “2nd” GPS used instead of the first always, you need to make it GPS1, and make the other one GPS2. Alternatively, you can use GPS_AUTO_SWITCH to have the estimation filter use whichever GPS has the best quality solution.

If you want to reproduce the POS message by-math in post-processing, you’d need to implement the same Kalman Filter on the same data at the same timing. I expect that would be hard, although not impossible.

1 Like

Thanks for the reply.

GPS_AUTO_SWITCH seems to be a very useful feature. From what I see in the documentation, The switchover happens to the GPS that has a higher number of satellites. This seems off to me, as I intend to use a piksi RTK module as the secondary GPS. The Piksi GPS receiver seemed to track a lesser number of satellites than the ublox module that comes with the pixhawk. So, it seems like the pixhawk would switch to the ublox GPS even though the Piksi has a better solution if it solely relies on satellite count to make the switch.

1 Like

@Nihal It will switch to the GPS that has the best fix type (IE RTK > DGPS > 3D fix) then if there are 2 units that have the same fix type it will select the one with more satellites.

1 Like

That’s great, Thanks