Plane: replaced constrain() with constrain_float()

This commit is contained in:
Andrew Tridgell 2013-05-02 10:27:10 +10:00
parent 25c576cad7
commit 9584aa89d9
2 changed files with 6 additions and 6 deletions

View File

@ -19,7 +19,7 @@ static float get_speed_scaler(void)
} else { } else {
speed_scaler = 2.0; speed_scaler = 2.0;
} }
speed_scaler = constrain(speed_scaler, 0.5, 2.0); speed_scaler = constrain_float(speed_scaler, 0.5, 2.0);
} else { } else {
if (g.channel_throttle.servo_out > 0) { if (g.channel_throttle.servo_out > 0) {
speed_scaler = 0.5 + ((float)THROTTLE_CRUISE / g.channel_throttle.servo_out / 2.0); // First order taylor expansion of square root speed_scaler = 0.5 + ((float)THROTTLE_CRUISE / g.channel_throttle.servo_out / 2.0); // First order taylor expansion of square root
@ -28,7 +28,7 @@ static float get_speed_scaler(void)
speed_scaler = 1.67; speed_scaler = 1.67;
} }
// This case is constrained tighter as we don't have real speed info // This case is constrained tighter as we don't have real speed info
speed_scaler = constrain(speed_scaler, 0.6, 1.67); speed_scaler = constrain_float(speed_scaler, 0.6, 1.67);
} }
return speed_scaler; return speed_scaler;
} }
@ -377,7 +377,7 @@ static void calc_nav_roll()
* float roll_slew_limit(float servo) * float roll_slew_limit(float servo)
* { * {
* static float last; * static float last;
* float temp = constrain(servo, last-ROLL_SLEW_LIMIT * delta_ms_fast_loop/1000.f, last + ROLL_SLEW_LIMIT * delta_ms_fast_loop/1000.f); * float temp = constrain_float(servo, last-ROLL_SLEW_LIMIT * delta_ms_fast_loop/1000.f, last + ROLL_SLEW_LIMIT * delta_ms_fast_loop/1000.f);
* last = servo; * last = servo;
* return temp; * return temp;
* }*/ * }*/

View File

@ -1797,17 +1797,17 @@ mission_failed:
} else if (var_type == AP_PARAM_INT32) { } else if (var_type == AP_PARAM_INT32) {
if (packet.param_value < 0) rounding_addition = -rounding_addition; if (packet.param_value < 0) rounding_addition = -rounding_addition;
float v = packet.param_value+rounding_addition; float v = packet.param_value+rounding_addition;
v = constrain(v, -2147483648.0, 2147483647.0); v = constrain_float(v, -2147483648.0, 2147483647.0);
((AP_Int32 *)vp)->set_and_save(v); ((AP_Int32 *)vp)->set_and_save(v);
} else if (var_type == AP_PARAM_INT16) { } else if (var_type == AP_PARAM_INT16) {
if (packet.param_value < 0) rounding_addition = -rounding_addition; if (packet.param_value < 0) rounding_addition = -rounding_addition;
float v = packet.param_value+rounding_addition; float v = packet.param_value+rounding_addition;
v = constrain(v, -32768, 32767); v = constrain_float(v, -32768, 32767);
((AP_Int16 *)vp)->set_and_save(v); ((AP_Int16 *)vp)->set_and_save(v);
} else if (var_type == AP_PARAM_INT8) { } else if (var_type == AP_PARAM_INT8) {
if (packet.param_value < 0) rounding_addition = -rounding_addition; if (packet.param_value < 0) rounding_addition = -rounding_addition;
float v = packet.param_value+rounding_addition; float v = packet.param_value+rounding_addition;
v = constrain(v, -128, 127); v = constrain_float(v, -128, 127);
((AP_Int8 *)vp)->set_and_save(v); ((AP_Int8 *)vp)->set_and_save(v);
} else { } else {
// we don't support mavlink set on this parameter // we don't support mavlink set on this parameter