PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <RateControl.hpp>
Public Member Functions | |
RateControl ()=default | |
~RateControl ()=default | |
void | setGains (const matrix::Vector3f &P, const matrix::Vector3f &I, const matrix::Vector3f &D) |
Set the rate control gains. More... | |
void | setIntegratorLimit (const matrix::Vector3f &integrator_limit) |
Set the mximum absolute value of the integrator for all axes. More... | |
void | setDTermCutoff (const float loop_rate, const float cutoff, const bool force) |
Set update frequency and low-pass filter cutoff that is applied to the derivative term. More... | |
void | setFeedForwardGain (const matrix::Vector3f &FF) |
Set direct rate to torque feed forward gain. More... | |
void | setSaturationStatus (const MultirotorMixer::saturation_status &status) |
Set saturation status. More... | |
matrix::Vector3f | update (const matrix::Vector3f &rate, const matrix::Vector3f &rate_sp, const float dt, const bool landed) |
Run one control loop cycle calculation. More... | |
void | resetIntegral () |
Set the integral term to 0 to prevent windup. More... | |
void | getRateControlStatus (rate_ctrl_status_s &rate_ctrl_status) |
Get status message of controller for logging/debugging. More... | |
Private Member Functions | |
void | updateIntegral (matrix::Vector3f &rate_error, const float dt) |
Private Attributes | |
matrix::Vector3f | _gain_p |
rate control proportional gain for all axes x, y, z More... | |
matrix::Vector3f | _gain_i |
rate control integral gain More... | |
matrix::Vector3f | _gain_d |
rate control derivative gain More... | |
matrix::Vector3f | _lim_int |
integrator term maximum absolute value More... | |
matrix::Vector3f | _gain_ff |
direct rate to torque feed forward gain only useful for helicopters More... | |
matrix::Vector3f | _rate_prev |
angular rates of previous update More... | |
matrix::Vector3f | _rate_prev_filtered |
low-pass filtered angular rates of previous update More... | |
matrix::Vector3f | _rate_int |
integral term of the rate controller More... | |
math::LowPassFilter2pVector3f | _lp_filters_d {0.f, 0.f} |
low-pass filters for D-term (roll, pitch & yaw) More... | |
bool | _mixer_saturation_positive [3] {} |
bool | _mixer_saturation_negative [3] {} |
Definition at line 48 of file RateControl.hpp.
|
default |
|
default |
void RateControl::getRateControlStatus | ( | rate_ctrl_status_s & | rate_ctrl_status | ) |
Get status message of controller for logging/debugging.
rate_ctrl_status | status message to fill with internal states |
Definition at line 128 of file RateControl.cpp.
References rate_ctrl_status_s::pitchspeed_integ, rate_ctrl_status_s::rollspeed_integ, and rate_ctrl_status_s::yawspeed_integ.
Referenced by resetIntegral(), and MulticopterRateControl::Run().
|
inline |
Set the integral term to 0 to prevent windup.
Definition at line 103 of file RateControl.hpp.
References _rate_int, getRateControlStatus(), updateIntegral(), and matrix::Matrix< Type, M, N >::zero().
Referenced by MulticopterRateControl::Run().
void RateControl::setDTermCutoff | ( | const float | loop_rate, |
const float | cutoff, | ||
const bool | force | ||
) |
Set update frequency and low-pass filter cutoff that is applied to the derivative term.
loop_rate | [Hz] rate with which update function is called |
cutoff | [Hz] cutoff frequency for the low-pass filter on the dervative term |
force | flag to force an expensive update even if the cutoff didn't change |
Definition at line 50 of file RateControl.cpp.
References f().
Referenced by MulticopterRateControl::parameters_updated(), MulticopterRateControl::Run(), and setIntegratorLimit().
|
inline |
Set direct rate to torque feed forward gain.
FF | 3D vector of feed forward gains for body x,y,z axis |
Definition at line 81 of file RateControl.hpp.
References _gain_ff, dt, setSaturationStatus(), status, and update().
Referenced by MulticopterRateControl::parameters_updated().
void RateControl::setGains | ( | const matrix::Vector3f & | P, |
const matrix::Vector3f & | I, | ||
const matrix::Vector3f & | D | ||
) |
Set the rate control gains.
P | 3D vector of proportional gains for body x,y,z axis |
I | 3D vector of integral gains |
D | 3D vector of derivative gains |
Definition at line 43 of file RateControl.cpp.
References P.
Referenced by MulticopterRateControl::parameters_updated().
|
inline |
Set the mximum absolute value of the integrator for all axes.
integrator_limit | limit value for all axes x, y, z |
Definition at line 66 of file RateControl.hpp.
References _lim_int, and setDTermCutoff().
Referenced by MulticopterRateControl::parameters_updated().
void RateControl::setSaturationStatus | ( | const MultirotorMixer::saturation_status & | status | ) |
Set saturation status.
status | message from mixer reporting about saturation |
Definition at line 59 of file RateControl.cpp.
References MultirotorMixer::saturation_status::flags, MultirotorMixer::saturation_status::pitch_neg, MultirotorMixer::saturation_status::pitch_pos, MultirotorMixer::saturation_status::roll_neg, MultirotorMixer::saturation_status::roll_pos, MultirotorMixer::saturation_status::yaw_neg, and MultirotorMixer::saturation_status::yaw_pos.
Referenced by MulticopterRateControl::Run(), and setFeedForwardGain().
Vector3f RateControl::update | ( | const matrix::Vector3f & | rate, |
const matrix::Vector3f & | rate_sp, | ||
const float | dt, | ||
const bool | landed | ||
) |
Run one control loop cycle calculation.
rate | estimation of the current vehicle angular rate |
rate_sp | desired vehicle angular rate setpoint |
dt | desired vehicle angular rate setpoint |
Definition at line 69 of file RateControl.cpp.
References matrix::Matrix< Type, M, N >::emult(), and FLT_EPSILON.
Referenced by MulticopterRateControl::Run(), setFeedForwardGain(), and TEST().
|
private |
Definition at line 96 of file RateControl.cpp.
References math::constrain(), dt, f(), math::max(), math::min(), and math::radians().
Referenced by resetIntegral().
|
private |
rate control derivative gain
Definition at line 117 of file RateControl.hpp.
|
private |
direct rate to torque feed forward gain only useful for helicopters
Definition at line 119 of file RateControl.hpp.
Referenced by setFeedForwardGain().
|
private |
rate control integral gain
Definition at line 116 of file RateControl.hpp.
|
private |
rate control proportional gain for all axes x, y, z
Definition at line 115 of file RateControl.hpp.
|
private |
integrator term maximum absolute value
Definition at line 118 of file RateControl.hpp.
Referenced by setIntegratorLimit().
|
private |
low-pass filters for D-term (roll, pitch & yaw)
Definition at line 125 of file RateControl.hpp.
|
private |
Definition at line 127 of file RateControl.hpp.
|
private |
Definition at line 126 of file RateControl.hpp.
|
private |
integral term of the rate controller
Definition at line 124 of file RateControl.hpp.
Referenced by resetIntegral().
|
private |
angular rates of previous update
Definition at line 122 of file RateControl.hpp.
|
private |
low-pass filtered angular rates of previous update
Definition at line 123 of file RateControl.hpp.