Copter: clear thr accel I term on take-off

This commit is contained in:
Randy Mackay 2013-07-26 21:43:09 +09:00
parent 05248738e2
commit 24d15517ff
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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