Skip to content

Commit

Permalink
Motors: fix thrust curve and add constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
lthall authored and rmackay9 committed Mar 3, 2015
1 parent 3e960df commit cf8c211
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/AP_Motors/AP_Motors_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ int16_t AP_Motors::apply_thrust_curve_and_volt_scaling(int16_t pwm_out, int16_t
if (_thrust_curve_expo > 0.0f){
temp_out = ((_thrust_curve_expo-1.0f) + safe_sqrt((1.0f-_thrust_curve_expo)*(1.0f-_thrust_curve_expo) + 4.0f*_thrust_curve_expo*_lift_max*temp_out))/(2.0f*_thrust_curve_expo*_batt_voltage_filt.get());
}
return (temp_out*(_thrust_curve_max*pwm_max-pwm_min)+pwm_min);
temp_out = constrain_float(temp_out*_thrust_curve_max*(pwm_max-pwm_min)+pwm_min, pwm_min, pwm_max);
return (int16_t)temp_out;
}

// update_lift_max from battery voltage - used for voltage compensation
Expand Down

0 comments on commit cf8c211

Please sign in to comment.