From fdf277428e7195cfac73d089645d4c5bbcda41b9 Mon Sep 17 00:00:00 2001 From: jasonshort Date: Thu, 10 Feb 2011 07:25:56 +0000 Subject: [PATCH] updated dual kp alt hold git-svn-id: https://arducopter.googlecode.com/svn/trunk@1627 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- ArduCopterMega/flight_control.pde | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ArduCopterMega/flight_control.pde b/ArduCopterMega/flight_control.pde index 10e4fcc22b..3596b59322 100644 --- a/ArduCopterMega/flight_control.pde +++ b/ArduCopterMega/flight_control.pde @@ -25,15 +25,17 @@ void calc_nav_throttle() long error = constrain(altitude_error, -300, 300); if(altitude_sensor == BARO) { + float t = pid_baro_throttle.kP(); + if(error > 0){ - pid_baro_throttle.kP(.25); + //pid_baro_throttle.kP(.25); }else{ - pid_baro_throttle.kP(.05); + pid_baro_throttle.kP(t/4.0); } - nav_throttle = pid_baro_throttle.get_pid(error, delta_ms_fast_loop, 1.0); // limit output of throttle control - nav_throttle = throttle_cruise + constrain(nav_throttle, -15, 70); - + nav_throttle = throttle_cruise + constrain(nav_throttle, -20, 70); + pid_baro_throttle.kP(t); + } else { // SONAR nav_throttle = pid_sonar_throttle.get_pid(error, delta_ms_fast_loop, 1.0);