Skip to content
Snippets Groups Projects
Commit 1f253c52 authored by rmackay9's avatar rmackay9
Browse files

ArduCopter - altitude hold - ensure throttle_avg is initialised from g.throttle_cruise parameter

parent 19981d48
No related branches found
Tags ArduCopter-2.5.2
No related merge requests found
......@@ -1580,7 +1580,7 @@ void update_throttle_mode(void)
int16_t throttle_out;
#if AUTO_THROTTLE_HOLD != 0
static float throttle_avg = THROTTLE_CRUISE;
static float throttle_avg = 0; // this is initialised to g.throttle_cruise later
#endif
switch(throttle_mode){
......@@ -1598,6 +1598,10 @@ void update_throttle_mode(void)
#endif
#if AUTO_THROTTLE_HOLD != 0
// ensure throttle_avg has been initialised
if( throttle_avg == 0 ) {
throttle_avg = g.throttle_cruise;
}
// calc average throttle
if ((g.rc_3.control_in > MINIMUM_THROTTLE) && abs(climb_rate) < 60){
throttle_avg = throttle_avg * .98 + (float)g.rc_3.control_in * .02;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment