flight mode manager: fix terrain hold

This commit is contained in:
alexklimaj
2023-11-07 12:00:14 -05:00
committed by Daniel Agar
parent 94d4dc85f8
commit de0910c767
6 changed files with 29 additions and 7 deletions
@@ -171,5 +171,15 @@ void FlightTaskManualPositionSmoothVel::_setOutputStateZ()
_jerk_setpoint(2) = _smoothing_z.getCurrentJerk();
_acceleration_setpoint(2) = _smoothing_z.getCurrentAcceleration();
_velocity_setpoint(2) = _smoothing_z.getCurrentVelocity();
_position_setpoint(2) = _smoothing_z.getCurrentPosition();
if (!_terrain_hold) {
if (_terrain_hold_previous) {
// Reset position setpoint to current position when switching from terrain hold to non-terrain hold
_smoothing_z.setCurrentPosition(_position(2));
}
_position_setpoint(2) = _smoothing_z.getCurrentPosition();
}
_terrain_hold_previous = _terrain_hold;
}
@@ -87,4 +87,6 @@ private:
ManualVelocitySmoothingXY _smoothing_xy; ///< Smoothing in x and y directions
ManualVelocitySmoothingZ _smoothing_z; ///< Smoothing in z direction
bool _terrain_hold_previous{false}; /**< true when vehicle was controlling height above a static ground position in the previous iteration */
};