flight_mode_manager: invalidate dist to bottom/ground on terrain reset

- this allows the terrain hold to simply reset on the next valid update
   rather than trying to adjust the setpoints
This commit is contained in:
Daniel Agar
2024-10-02 15:45:56 -04:00
parent 34ee097f02
commit ad28c5893b
3 changed files with 9 additions and 0 deletions
@@ -66,6 +66,8 @@ void FlightTask::_checkEkfResetCounters()
if (_sub_vehicle_local_position.get().dist_bottom_reset_counter != _reset_counters.hagl) {
_ekfResetHandlerHagl(_sub_vehicle_local_position.get().delta_dist_bottom);
_reset_counters.hagl = _sub_vehicle_local_position.get().dist_bottom_reset_counter;
_dist_to_bottom = NAN;
}
if (_sub_vehicle_local_position.get().vz_reset_counter != _reset_counters.vz) {
@@ -279,6 +279,11 @@ void FlightTaskManualAltitude::_ekfResetHandlerHeading(float delta_psi)
_stick_yaw.ekfResetHandler(delta_psi);
}
void FlightTaskManualAltitude::_ekfResetHandlerHagl(float delta_hagl)
{
_dist_to_ground_lock = NAN;
}
void FlightTaskManualAltitude::_updateSetpoints()
{
_stick_yaw.generateYawSetpoint(_yawspeed_setpoint, _yaw_setpoint, _sticks.getYawExpo(), _yaw, _deltatime, _unaided_yaw);
@@ -56,6 +56,8 @@ public:
protected:
void _ekfResetHandlerHeading(float delta_psi) override; /**< adjust heading setpoint in case of EKF reset event */
void _ekfResetHandlerHagl(float delta_hagl) override;
virtual void _updateSetpoints(); /**< updates all setpoints */
virtual void _scaleSticks(); /**< scales sticks to velocity in z */
bool _checkTakeoff() override;