From 1f422c86c1b066fe35e88abc557a9bafcead653c Mon Sep 17 00:00:00 2001 From: Robert Lefebvre Date: Sat, 10 May 2014 08:22:06 -0400 Subject: [PATCH] Arducopter: Add independent rate roll and pitch P, I, D tuning options. Add rate feedforward tuning options for tradheli. --- ArduCopter/ArduCopter.pde | 36 ++++++++++++++++++++++++++++++++++++ ArduCopter/defines.h | 9 +++++++++ 2 files changed, 45 insertions(+) diff --git a/ArduCopter/ArduCopter.pde b/ArduCopter/ArduCopter.pde index b19f205b3d..44967d8af7 100644 --- a/ArduCopter/ArduCopter.pde +++ b/ArduCopter/ArduCopter.pde @@ -1507,6 +1507,18 @@ static void tuning(){ case CH6_HELI_EXTERNAL_GYRO: motors.ext_gyro_gain(g.rc_6.control_in); break; + + case CH6_RATE_PITCH_FF: + g.pid_rate_pitch.ff(tuning_value); + break; + + case CH6_RATE_ROLL_FF: + g.pid_rate_roll.ff(tuning_value); + break; + + case CH6_RATE_YAW_FF: + g.pid_rate_yaw.ff(tuning_value); + break; #endif case CH6_OPTFLOW_KP: @@ -1575,6 +1587,30 @@ static void tuning(){ // roll-pitch input smoothing g.rc_feel_rp = g.rc_6.control_in / 10; break; + + case CH6_RATE_PITCH_KP: + g.pid_rate_pitch.kP(tuning_value); + break; + + case CH6_RATE_PITCH_KI: + g.pid_rate_pitch.kI(tuning_value); + break; + + case CH6_RATE_PITCH_KD: + g.pid_rate_pitch.kD(tuning_value); + break; + + case CH6_RATE_ROLL_KP: + g.pid_rate_roll.kP(tuning_value); + break; + + case CH6_RATE_ROLL_KI: + g.pid_rate_roll.kI(tuning_value); + break; + + case CH6_RATE_ROLL_KD: + g.pid_rate_roll.kD(tuning_value); + break; } } diff --git a/ArduCopter/defines.h b/ArduCopter/defines.h index c54bce9579..09b241213e 100644 --- a/ArduCopter/defines.h +++ b/ArduCopter/defines.h @@ -144,6 +144,15 @@ #define CH6_EKF_HORIZONTAL_POS 43 // EKF's gps vs accel (higher rely on accels more, gps impact is reduced). Range should be 1.0 ~ 3.0? 1.5 is default #define CH6_EKF_ACCEL_NOISE 44 // EKF's accel noise (lower means trust accels more, gps & baro less). Range should be 0.02 ~ 0.5 0.5 is default (but very robust at that level) #define CH6_RC_FEEL_RP 45 // roll-pitch input smoothing +#define CH6_RATE_PITCH_KP 46 // body frame pitch rate controller's P term +#define CH6_RATE_PITCH_KI 47 // body frame pitch rate controller's I term +#define CH6_RATE_PITCH_KD 48 // body frame pitch rate controller's D term +#define CH6_RATE_ROLL_KP 49 // body frame roll rate controller's P term +#define CH6_RATE_ROLL_KI 50 // body frame roll rate controller's I term +#define CH6_RATE_ROLL_KD 51 // body frame roll rate controller's D term +#define CH6_RATE_PITCH_FF 52 // body frame pitch rate controller FF term +#define CH6_RATE_ROLL_FF 53 // body frame roll rate controller FF term +#define CH6_RATE_YAW_FF 54 // body frame yaw rate controller FF term // Acro Trainer types #define ACRO_TRAINER_DISABLED 0