From a5c3e6ef45bc88388de358781511194745c35f52 Mon Sep 17 00:00:00 2001 From: Leonard Hall Date: Tue, 27 Oct 2015 22:44:41 +0900 Subject: [PATCH] AC_PosControl: allow desired vel z to be above speed limit --- .../AC_AttitudeControl/AC_PosControl.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/AC_AttitudeControl/AC_PosControl.cpp b/libraries/AC_AttitudeControl/AC_PosControl.cpp index ce9a00595f..ab85e88974 100644 --- a/libraries/AC_AttitudeControl/AC_PosControl.cpp +++ b/libraries/AC_AttitudeControl/AC_PosControl.cpp @@ -351,6 +351,19 @@ void AC_PosControl::pos_to_rate_z() // calculate _vel_target.z using from _pos_error.z using sqrt controller _vel_target.z = AC_AttitudeControl::sqrt_controller(_pos_error.z, _p_pos_z.kP(), _accel_z_cms); + // check speed limits + // To-Do: check these speed limits here or in the pos->rate controller + _limit.vel_up = false; + _limit.vel_down = false; + if (_vel_target.z < _speed_down_cms) { + _vel_target.z = _speed_down_cms; + _limit.vel_down = true; + } + if (_vel_target.z > _speed_up_cms) { + _vel_target.z = _speed_up_cms; + _limit.vel_up = true; + } + // add feed forward component _vel_target.z += _vel_desired.z; @@ -365,19 +378,6 @@ void AC_PosControl::rate_to_accel_z() const Vector3f& curr_vel = _inav.get_velocity(); float p; // used to capture pid values for logging - // check speed limits - // To-Do: check these speed limits here or in the pos->rate controller - _limit.vel_up = false; - _limit.vel_down = false; - if (_vel_target.z < _speed_down_cms) { - _vel_target.z = _speed_down_cms; - _limit.vel_down = true; - } - if (_vel_target.z > _speed_up_cms) { - _vel_target.z = _speed_up_cms; - _limit.vel_up = true; - } - // reset last velocity target to current target if (_flags.reset_rate_to_accel_z) { _vel_last.z = _vel_target.z;