Copter: update_thr_average uses 0 to 1 range

This commit is contained in:
Leonard Hall 2015-12-20 22:02:52 +10:30 committed by Randy Mackay
parent fd2509f6ed
commit f8d7b677d4

View File

@ -100,7 +100,7 @@ void Copter::update_thr_average()
{
// ensure throttle_average has been initialised
if( is_zero(throttle_average) ) {
throttle_average = g.throttle_mid;
throttle_average = 0.5f;
// update position controller
pos_control.set_throttle_hover(throttle_average);
}
@ -114,7 +114,7 @@ void Copter::update_thr_average()
float throttle = motors.get_throttle();
// calc average throttle if we are in a level hover
if (throttle > g.throttle_min && abs(climb_rate) < 60 && labs(ahrs.roll_sensor) < 500 && labs(ahrs.pitch_sensor) < 500) {
if (throttle > 0.0f && abs(climb_rate) < 60 && labs(ahrs.roll_sensor) < 500 && labs(ahrs.pitch_sensor) < 500) {
throttle_average = throttle_average * 0.99f + throttle * 0.01f;
// update position controller
pos_control.set_throttle_hover(throttle_average);