Browse Source

Plane: add a low pass filter to speed scaler

this is needed due to the filtering done on the target rate in
AC_PID. With a low filter rate in AC_PID a step in the speed scaler
results in a step in the FF output due to the mismatch in the
instantaneous SS and the filtered target rate
c415-sdk
Andrew Tridgell 3 years ago committed by Randy Mackay
parent
commit
4f61f4e3fa
  1. 8
      ArduPlane/Attitude.cpp
  2. 6
      ArduPlane/Plane.h
  3. 6
      ArduPlane/sensors.cpp

8
ArduPlane/Attitude.cpp

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
#include "Plane.h"
/*
get a speed scaling number for control surfaces. This is applied to
PIDs to change the scaling of the PID with speed. At high speed we
move the surfaces less, and at low speeds we move them more.
calculate speed scaling number for control surfaces. This is applied
to PIDs to change the scaling of the PID with speed. At high speed
we move the surfaces less, and at low speeds we move them more.
*/
float Plane::get_speed_scaler(void)
float Plane::calc_speed_scaler(void)
{
float aspeed, speed_scaler;
if (ahrs.airspeed_estimate(aspeed)) {

6
ArduPlane/Plane.h

@ -394,6 +394,9 @@ private: @@ -394,6 +394,9 @@ private:
// Difference between current altitude and desired altitude. Centimeters
int32_t altitude_error_cm;
// speed scaler for control surfaces, updated at 10Hz
float surface_speed_scaler = 1.0;
// Battery Sensors
AP_BattMonitor battery{MASK_LOG_CURRENT,
FUNCTOR_BIND_MEMBER(&Plane::handle_battery_failsafe, void, const char*, const int8_t),
@ -844,7 +847,8 @@ private: @@ -844,7 +847,8 @@ private:
void calc_throttle();
void calc_nav_roll();
void calc_nav_pitch();
float get_speed_scaler(void);
float calc_speed_scaler(void);
float get_speed_scaler(void) const { return surface_speed_scaler; }
bool stick_mixing_enabled(void);
void stabilize_roll(float speed_scaler);
void stabilize_pitch(float speed_scaler);

6
ArduPlane/sensors.cpp

@ -65,6 +65,12 @@ void Plane::read_airspeed(void) @@ -65,6 +65,12 @@ void Plane::read_airspeed(void)
if (ahrs.airspeed_estimate(aspeed)) {
smoothed_airspeed = smoothed_airspeed * 0.8f + aspeed * 0.2f;
}
// low pass filter speed scaler, with 1Hz cutoff, at 10Hz
const float speed_scaler = calc_speed_scaler();
const float cutoff_Hz = 2.0;
const float dt = 0.1;
surface_speed_scaler += calc_lowpass_alpha_dt(dt, cutoff_Hz) * (speed_scaler - surface_speed_scaler);
}
/*

Loading…
Cancel
Save