fix(FlightTaskManualAltitude): reset terrain hold state on activation

Flight tasks are statically allocated, so _terrain_hold and
_dist_to_ground_lock survive switching to another mode and back. On
reactivation with sticks centered and a valid distance to ground,
terrain following would resume on the old lock and command the height
above ground from before the mode switch, however long ago and far
away that was. Since no disengage or re-engage transition runs in
between, invalidating the lock on those transitions cannot cover this
path. Start every activation with terrain hold off and no lock; the
regular engage logic then re-latches at the current height above
ground when the conditions are met.
This commit is contained in:
Balduin authored and Balduin committed 2026-08-31 11:19:07 +02:00
1 parent a778a9de29
commit 89f81c0f2a
1 file changed
+2
@@ -64,6 +64,8 @@ bool FlightTaskManualAltitude::activate(const trajectory_setpoint_s &last_setpoi
_acceleration_setpoint = Vector3f(0.f, 0.f, NAN); // altitude is controlled from position/velocity
_position_setpoint(2) = _position(2);
_velocity_setpoint(2) = 0.f;
_terrain_hold = false;
_dist_to_ground_lock = NAN;
_stick_yaw.reset(_yaw, _unaided_yaw);
_setDefaultConstraints();