From 5cf1c0869dba2ba2f3add7249ea827fc7eef1287 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 9 Jan 2017 18:30:34 +1100 Subject: [PATCH] AC_AttitudeControl: expose all functions via abstract class this allows for a single class to be used for heli and multicopter --- .../AC_AttitudeControl/AC_AttitudeControl.h | 20 +++++++++++++++++++ .../AC_AttitudeControl_Heli.h | 13 ++++-------- .../AC_AttitudeControl_Multi.h | 10 +++++----- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/libraries/AC_AttitudeControl/AC_AttitudeControl.h b/libraries/AC_AttitudeControl/AC_AttitudeControl.h index de2bef937b..96781dba94 100644 --- a/libraries/AC_AttitudeControl/AC_AttitudeControl.h +++ b/libraries/AC_AttitudeControl/AC_AttitudeControl.h @@ -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[]; diff --git a/libraries/AC_AttitudeControl/AC_AttitudeControl_Heli.h b/libraries/AC_AttitudeControl/AC_AttitudeControl_Heli.h index f26b7b1347..4e1eb72af2 100644 --- a/libraries/AC_AttitudeControl/AC_AttitudeControl_Heli.h +++ b/libraries/AC_AttitudeControl/AC_AttitudeControl_Heli.h @@ -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; diff --git a/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.h b/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.h index 95246122e3..18c3977d33 100644 --- a/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.h +++ b/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.h @@ -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();