CTUN.DAlt question

I’m thinking CTUN.DAlt is “desired” altitude. Is that correct? If so, I would think this, for an Auto mission, would be the altitude of my waypoints in my plan. Mine are 30m, but DAlt varies for every flight line, and in all cases is >30m. I didn’t plot, but Alt and BAlt match rather nicely to DAlt–not the 30m I planned. Can someone explain the error in my thinking?

I am also wondering how DAlt is calculated, but have not found much documentation on it. Did you ever figure out what was going on?

For the record, I am sure that it is the “desired” altitude. Just as Alt, It seems to be relative to EKF Origin, but takes more into consideration then just the waypoint altitude. I have seen it vary, even though I always set a constant altitude value to the waypoints.

I guess the waypoint altitude should be interpreted as “Height above ground level” which in OP’s case might result in a DAlt greater on 30m, depending on the EKF origin and the terrain. This post explains the HAGL Barometer has more weight than LidarLite, to calculate altitude

I would still like to understand DAlt and its calculation better, so if anyone could shed some light on this or point me to a resource, I’d be grateful.

Line 130 of Log.cpp shows that CTUN.DAlt logs the value of pos_control->get_target_alt() in different units

throttle_hover      : motors->get_throttle_hover(),
desired_alt         : pos_control->get_alt_target() / 100.0f,
inav_alt            : inertial_nav.get_altitude() / 100.0f,

Digging into AC_PosControl reveals that the position control system specifies a target position with-respect-to the home in units of [cm]. So I think CTUN.DAlt is the vertical position (altitude) in meters of the target altitude with-respect-to the home position.

Yes, CTUN.Alt and DAlt is EKF altitude, which may not match exactly with the waypoint altitude you set, as the EKF origin can be non-zero. You can see in his graph that his ground alt is 3m, and first waypoint is 33m.

The altitude drifting you and OP have observed are due to a feature that uses GPS to slowly adjust EKF origin altitude, which causes the copter to adjust altitude every time it goes to a new waypoint. It has since been decided that this feature is generally not helpful and can sometimes lead to dangerous altitude inaccuracies during long missions, so it is being turned off by default in future firmware releases. The relevant PR for this issue is here. It cannot be turned off in 3.5, but the option will be implemented in 3.6 with the EKF_OGN_HGT_MASK parameter.

Thanks a lot for the clarification, very helpful.

What I want to achieve is a constant height above ground, in uneven terrain, without using map data. I guess it is possible with terrain following, I just have not figured out how to send a waypoint with “terrain” altitude. Below it is described how to do it with Mission Planner, but I need it in dronekit-pyhton. But I guess that’s for a new thread.

Thanks again.