2016-02-17 21:24:42 -04:00
# pragma once
2015-07-13 02:59:48 -03:00
/// @file AC_AttitudeControl_Multi.h
/// @brief ArduCopter attitude control library
2015-08-11 03:28:41 -03:00
# include "AC_AttitudeControl.h"
# include <AP_Motors/AP_MotorsMulticopter.h>
2015-07-13 02:59:48 -03:00
2016-02-15 02:25:41 -04:00
// default rate controller PID gains
# ifndef AC_ATC_MULTI_RATE_RP_P
2016-02-17 06:58:44 -04:00
# define AC_ATC_MULTI_RATE_RP_P 0.135f
2016-02-15 02:25:41 -04:00
# endif
# ifndef AC_ATC_MULTI_RATE_RP_I
2016-02-17 06:58:44 -04:00
# define AC_ATC_MULTI_RATE_RP_I 0.090f
2016-02-15 02:25:41 -04:00
# endif
# ifndef AC_ATC_MULTI_RATE_RP_D
2016-02-17 06:58:44 -04:00
# define AC_ATC_MULTI_RATE_RP_D 0.0036f
2016-02-15 02:25:41 -04:00
# endif
# ifndef AC_ATC_MULTI_RATE_RP_IMAX
2017-05-31 22:08:38 -03:00
# define AC_ATC_MULTI_RATE_RP_IMAX 0.5f
2016-02-15 02:25:41 -04:00
# endif
# ifndef AC_ATC_MULTI_RATE_RP_FILT_HZ
# define AC_ATC_MULTI_RATE_RP_FILT_HZ 20.0f
# endif
# ifndef AC_ATC_MULTI_RATE_YAW_P
2016-02-17 06:58:44 -04:00
# define AC_ATC_MULTI_RATE_YAW_P 0.180f
2016-02-15 02:25:41 -04:00
# endif
# ifndef AC_ATC_MULTI_RATE_YAW_I
2016-02-17 06:58:44 -04:00
# define AC_ATC_MULTI_RATE_YAW_I 0.018f
2016-02-15 02:25:41 -04:00
# endif
# ifndef AC_ATC_MULTI_RATE_YAW_D
# define AC_ATC_MULTI_RATE_YAW_D 0.0f
# endif
# ifndef AC_ATC_MULTI_RATE_YAW_IMAX
2017-05-31 22:08:38 -03:00
# define AC_ATC_MULTI_RATE_YAW_IMAX 0.5f
2016-02-15 02:25:41 -04:00
# endif
# ifndef AC_ATC_MULTI_RATE_YAW_FILT_HZ
2017-05-31 22:08:38 -03:00
# define AC_ATC_MULTI_RATE_YAW_FILT_HZ 2.5f
2016-02-15 02:25:41 -04:00
# endif
2015-07-13 02:59:48 -03:00
class AC_AttitudeControl_Multi : public AC_AttitudeControl {
public :
2017-02-11 04:14:23 -04:00
AC_AttitudeControl_Multi ( AP_AHRS_View & ahrs , const AP_Vehicle : : MultiCopter & aparm , AP_MotorsMulticopter & motors , float dt ) ;
2015-07-13 02:59:48 -03:00
// empty destructor to suppress compiler warning
virtual ~ AC_AttitudeControl_Multi ( ) { }
2016-02-15 02:25:41 -04:00
// pid accessors
2018-11-07 06:57:10 -04:00
AC_PID & get_rate_roll_pid ( ) override { return _pid_rate_roll ; }
AC_PID & get_rate_pitch_pid ( ) override { return _pid_rate_pitch ; }
AC_PID & get_rate_yaw_pid ( ) override { return _pid_rate_yaw ; }
2016-02-15 02:25:41 -04:00
2016-05-23 12:12:14 -03:00
// Update Alt_Hold angle maximum
void update_althold_lean_angle_max ( float throttle_in ) override ;
2016-03-21 07:57:39 -03:00
// Set output throttle
void set_throttle_out ( float throttle_in , bool apply_angle_boost , float filt_cutoff ) override ;
2015-07-13 02:59:48 -03:00
// calculate total body frame throttle required to produce the given earth frame throttle
2016-03-21 08:01:17 -03:00
float get_throttle_boosted ( float throttle_in ) ;
2015-07-13 02:59:48 -03:00
2016-06-09 06:39:29 -03:00
// 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
2017-01-09 03:30:34 -04:00
void set_throttle_mix_min ( ) override { _throttle_rpy_mix_desired = _thr_mix_min ; }
2017-01-04 01:19:00 -04:00
void set_throttle_mix_man ( ) override { _throttle_rpy_mix_desired = _thr_mix_man ; }
2017-01-09 03:30:34 -04:00
void set_throttle_mix_max ( ) override { _throttle_rpy_mix_desired = _thr_mix_max ; }
2017-04-18 09:24:48 -03:00
void set_throttle_mix_value ( float value ) override { _throttle_rpy_mix_desired = _throttle_rpy_mix = value ; }
float get_throttle_mix ( void ) const override { return _throttle_rpy_mix ; }
2016-06-09 06:39:29 -03:00
2017-01-09 03:30:34 -04:00
// are we producing min throttle?
bool is_throttle_mix_min ( ) const override { return ( _throttle_rpy_mix < 1.25f * _thr_mix_min ) ; }
2016-06-09 06:39:29 -03:00
2016-05-23 02:03:38 -03:00
// run lowest level body-frame rate controller and send outputs to the motors
2018-11-07 06:57:10 -04:00
void rate_controller_run ( ) override ;
2016-06-09 06:39:29 -03:00
2016-09-01 08:31:49 -03:00
// sanity check parameters. should be called once before take-off
2018-11-07 06:57:10 -04:00
void parameter_sanity_check ( ) override ;
2016-09-01 08:31:49 -03:00
2016-02-15 02:25:41 -04:00
// user settable parameters
static const struct AP_Param : : GroupInfo var_info [ ] ;
2015-07-13 02:59:48 -03:00
protected :
2016-06-09 06:39:29 -03:00
// update_throttle_rpy_mix - updates thr_low_comp value towards the target
void update_throttle_rpy_mix ( ) ;
2016-06-09 05:31:59 -03:00
// get maximum value throttle can be raised to based on throttle vs attitude prioritisation
float get_throttle_avg_max ( float throttle_in ) ;
2015-07-13 02:59:48 -03:00
AP_MotorsMulticopter & _motors_multi ;
2016-02-15 02:25:41 -04:00
AC_PID _pid_rate_roll ;
AC_PID _pid_rate_pitch ;
AC_PID _pid_rate_yaw ;
2016-06-09 06:39:29 -03:00
2017-01-04 01:19:00 -04:00
AP_Float _thr_mix_man ; // throttle vs attitude control prioritisation used when using manual throttle (higher values mean we prioritise attitude control over throttle)
2016-06-09 06:39:29 -03:00
AP_Float _thr_mix_min ; // throttle vs attitude control prioritisation used when landing (higher values mean we prioritise attitude control over throttle)
AP_Float _thr_mix_max ; // throttle vs attitude control prioritisation used during active flight (higher values mean we prioritise attitude control over throttle)
2015-07-13 02:59:48 -03:00
} ;