diff --git a/ArduCopter/ArduCopter.pde b/ArduCopter/ArduCopter.pde index d4eaeca621..70aaa18374 100644 --- a/ArduCopter/ArduCopter.pde +++ b/ArduCopter/ArduCopter.pde @@ -1977,6 +1977,12 @@ void update_throttle_mode(void) if(ap.auto_armed) { // alt hold plus pilot input of climb rate pilot_climb_rate = get_pilot_desired_climb_rate(g.rc_3.control_in); + + // clear i term when we're taking off + if (pilot_climb_rate > 0 && ap.land_complete) { + set_throttle_takeoff(); + } + if( sonar_alt_health >= SONAR_ALT_HEALTH_MAX ) { // if sonar is ok, use surface tracking get_throttle_surface_tracking(pilot_climb_rate); // this function calls set_target_alt_for_reporting for us diff --git a/ArduCopter/Attitude.pde b/ArduCopter/Attitude.pde index d8618cdfe8..b15f1c8302 100644 --- a/ArduCopter/Attitude.pde +++ b/ArduCopter/Attitude.pde @@ -859,6 +859,14 @@ void throttle_accel_deactivate() throttle_accel_controller_active = false; } +// set_throttle_takeoff - allows parents to tell throttle controller we are taking off so I terms can be cleared +static void +set_throttle_takeoff() +{ + if (g.pid_throttle_accel.get_integrator() < 0) + g.pid_throttle_accel.reset_I(); +} + // get_throttle_accel - accelerometer based throttle controller // returns an actual throttle output (0 ~ 1000) to be sent to the motors static int16_t