Hello, in line with my previous inquiries regarding altitude estimation, I am trying to figure out what the difference between EKF altitude (CTUN.Alt in the logs) and POS.Alt is, why they diverge, and what functions each one serves.
Here’s an example of an unexpected interaction between the two:
This is a 25 minute flight in Guided mode, where I send my copter to hover at 4 waypoints of the same altitude using the MAV_CMD_NAV_WAYPOINT Mavlink message from a companion computer. You can see the POS.Alt (green) drift downwards as the drone hovers. When the next waypoint message is sent, it sends the same target altitude, but the drone ascends, even though the CTUN.Alt (red) has remained constant. From this, I figure that the mavlink command uses POS.Alt for its waypoint altitudes, but the controller uses CTUN.Alt for altitude hold, and their divergence causes unreliable waypoint altitudes.
Log here: dropbox
So, my questions are:
- What is the (programmatic) difference between CTUN.Alt (EKF alt) and POS.Alt?
- What functions are each one used for? E.g., I find that POS.Alt is used for waypoints from Mavlink and precision landing calculations, and EKF is used for the actual altitude control.
2a. Why not use EKF altitude for everything?
- Why does POS.Alt have a downward trend that slowly goes away? I see this in multiple drones.
Would appreciate any insight or a point in the right direction.