diff --git a/src/lib/rate_control/rate_control.cpp b/src/lib/rate_control/rate_control.cpp index 77b776ba11..fca9b74268 100644 --- a/src/lib/rate_control/rate_control.cpp +++ b/src/lib/rate_control/rate_control.cpp @@ -47,13 +47,27 @@ void RateControl::setGains(const Vector3f &P, const Vector3f &I, const Vector3f _gain_d = D; } -void RateControl::setSaturationStatus(const Vector &saturation_positive, - const Vector &saturation_negative) +void RateControl::setSaturationStatus(const Vector3 &saturation_positive, + const Vector3 &saturation_negative) { _control_allocator_saturation_positive = saturation_positive; _control_allocator_saturation_negative = saturation_negative; } +void RateControl::setPositiveSaturationFlag(size_t axis, bool is_saturated) +{ + if (axis < 3) { + _control_allocator_saturation_positive(axis) = is_saturated; + } +} + +void RateControl::setNegativeSaturationFlag(size_t axis, bool is_saturated) +{ + if (axis < 3) { + _control_allocator_saturation_negative(axis) = is_saturated; + } +} + Vector3f RateControl::update(const Vector3f &rate, const Vector3f &rate_sp, const Vector3f &angular_accel, const float dt, const bool landed) { diff --git a/src/lib/rate_control/rate_control.hpp b/src/lib/rate_control/rate_control.hpp index 1db18ee092..353a03f17e 100644 --- a/src/lib/rate_control/rate_control.hpp +++ b/src/lib/rate_control/rate_control.hpp @@ -75,8 +75,16 @@ public: * Set saturation status * @param control saturation vector from control allocator */ - void setSaturationStatus(const matrix::Vector &saturation_positive, - const matrix::Vector &saturation_negative); + void setSaturationStatus(const matrix::Vector3 &saturation_positive, + const matrix::Vector3 &saturation_negative); + + /** + * Set individual saturation flags + * @param axis 0 roll, 1 pitch, 2 yaw + * @param is_saturated value to update the flag with + */ + void setPositiveSaturationFlag(size_t axis, bool is_saturated); + void setNegativeSaturationFlag(size_t axis, bool is_saturated); /** * Run one control loop cycle calculation