AC_AttitudeControl: expose all functions via abstract class

this allows for a single class to be used for heli and multicopter
This commit is contained in:
Andrew Tridgell 2017-01-09 18:30:34 +11:00
parent 3df55b575f
commit 5cf1c0869d
3 changed files with 29 additions and 14 deletions

View File

@ -238,6 +238,26 @@ public:
// sanity check parameters. should be called once before take-off
virtual void parameter_sanity_check() {}
// return true if the rpy mix is at lowest value
virtual bool is_throttle_mix_min() const { return true; }
// control rpy throttle mix
virtual void set_throttle_mix_min() {}
virtual void set_throttle_mix_mid() {}
virtual void set_throttle_mix_max() {}
// enable use of flybass passthrough on heli
virtual void use_flybar_passthrough(bool passthrough, bool tail_passthrough) {}
// use_leaky_i - controls whether we use leaky i term for body-frame to motor output stage on heli
virtual void use_leaky_i(bool leaky_i) {}
// set_hover_roll_scalar - scales Hover Roll Trim parameter. To be used by vehicle code according to vehicle condition.
virtual void set_hover_roll_trim_scalar(float scalar) {}
// passthrough_bf_roll_pitch_rate_yaw - roll and pitch are passed through directly, body-frame rate target for yaw
virtual void passthrough_bf_roll_pitch_rate_yaw(float roll_passthrough, float pitch_passthrough, float yaw_rate_bf_cds) {};
// User settable parameters
static const struct AP_Param::GroupInfo var_info[];

View File

@ -60,13 +60,8 @@ public:
AC_PID& get_rate_pitch_pid() { return _pid_rate_pitch; }
AC_PID& get_rate_yaw_pid() { return _pid_rate_yaw; }
// same as above but allows accessing heli specific pid methods - used only by Copter's tuning.cpp
AC_HELI_PID& get_heli_rate_roll_pid() { return _pid_rate_roll; }
AC_HELI_PID& get_heli_rate_pitch_pid() { return _pid_rate_pitch; }
AC_HELI_PID& get_heli_rate_yaw_pid() { return _pid_rate_yaw; }
// passthrough_bf_roll_pitch_rate_yaw - roll and pitch are passed through directly, body-frame rate target for yaw
void passthrough_bf_roll_pitch_rate_yaw(float roll_passthrough, float pitch_passthrough, float yaw_rate_bf_cds);
void passthrough_bf_roll_pitch_rate_yaw(float roll_passthrough, float pitch_passthrough, float yaw_rate_bf_cds) override;
// Integrate vehicle rate into _att_error_rot_vec_rad
void integrate_bf_rate_error_to_angle_errors();
@ -82,11 +77,11 @@ public:
void update_althold_lean_angle_max(float throttle_in) override;
// use_leaky_i - controls whether we use leaky i term for body-frame to motor output stage
void use_leaky_i(bool leaky_i) { _flags_heli.leaky_i = leaky_i; }
void use_leaky_i(bool leaky_i) override { _flags_heli.leaky_i = leaky_i; }
// use_flybar_passthrough - controls whether we pass-through
// control inputs to swash-plate and tail
void use_flybar_passthrough(bool passthrough, bool tail_passthrough) {
void use_flybar_passthrough(bool passthrough, bool tail_passthrough) override {
_flags_heli.flybar_passthrough = passthrough;
_flags_heli.tail_passthrough = tail_passthrough;
}
@ -95,7 +90,7 @@ public:
void do_piro_comp(bool piro_comp) { _flags_heli.do_piro_comp = piro_comp; }
// set_hover_roll_scalar - scales Hover Roll Trim parameter. To be used by vehicle code according to vehicle condition.
void set_hover_roll_trim_scalar(float scalar) {_hover_roll_trim_scalar = constrain_float(scalar, 0.0f, 1.0f);}
void set_hover_roll_trim_scalar(float scalar) override {_hover_roll_trim_scalar = constrain_float(scalar, 0.0f, 1.0f);}
// Set output throttle
void set_throttle_out(float throttle_in, bool apply_angle_boost, float filt_cutoff) override;

View File

@ -63,12 +63,12 @@ public:
// set desired throttle vs attitude mixing (actual mix is slewed towards this value over 1~2 seconds)
// low values favour pilot/autopilot throttle over attitude control, high values favour attitude control over throttle
// has no effect when throttle is above hover throttle
void set_throttle_mix_min() { _throttle_rpy_mix_desired = _thr_mix_min; }
void set_throttle_mix_mid() { _throttle_rpy_mix_desired = AC_ATTITUDE_CONTROL_MID_DEFAULT; }
void set_throttle_mix_max() { _throttle_rpy_mix_desired = _thr_mix_max; }
void set_throttle_mix_min() override { _throttle_rpy_mix_desired = _thr_mix_min; }
void set_throttle_mix_mid() override { _throttle_rpy_mix_desired = AC_ATTITUDE_CONTROL_MID_DEFAULT; }
void set_throttle_mix_max() override { _throttle_rpy_mix_desired = _thr_mix_max; }
// get_throttle_rpy_mix - get low throttle compensation value
bool is_throttle_mix_min() const { return (_throttle_rpy_mix < 1.25f*_thr_mix_min); }
// are we producing min throttle?
bool is_throttle_mix_min() const override { return (_throttle_rpy_mix < 1.25f*_thr_mix_min); }
// run lowest level body-frame rate controller and send outputs to the motors
void rate_controller_run();