math: more abs() fixes
abs() is 16 bit
This commit is contained in:
parent
e2c3149b2f
commit
50e2458df0
@ -358,7 +358,7 @@ static void set_servos(void)
|
||||
*/
|
||||
if (
|
||||
(control_mode == CIRCLE || control_mode >= FLY_BY_WIRE_B) &&
|
||||
(abs(home.alt - current_loc.alt) < 1000) &&
|
||||
(labs(home.alt - current_loc.alt) < 1000) &&
|
||||
((airspeed.use()? airspeed.get_airspeed_cm() : g_gps->ground_speed) < 500 ) &&
|
||||
!(control_mode==AUTO && takeoff_complete == false)
|
||||
) {
|
||||
|
@ -435,7 +435,7 @@ static void do_wait_delay()
|
||||
|
||||
static void do_change_alt()
|
||||
{
|
||||
condition_rate = abs((int)next_nonnav_command.lat);
|
||||
condition_rate = labs((int)next_nonnav_command.lat);
|
||||
condition_value = next_nonnav_command.alt;
|
||||
if(condition_value < current_loc.alt) condition_rate = -condition_rate;
|
||||
target_altitude_cm = current_loc.alt + (condition_rate / 10); // Divide by ten for 10Hz update
|
||||
|
@ -104,7 +104,7 @@ static void test_one_offset(struct Location &loc,
|
||||
brg_error += 360;
|
||||
}
|
||||
|
||||
if (abs(dist - dist2) > 1.0 ||
|
||||
if (fabs(dist - dist2) > 1.0 ||
|
||||
brg_error > 1.0) {
|
||||
Serial.printf("Failed offset test brg_error=%f dist_error=%f\n",
|
||||
brg_error, dist-dist2);
|
||||
|
@ -117,7 +117,7 @@ void
|
||||
Navigation::calc_long_scaling(int32_t lat)
|
||||
{
|
||||
// this is used to offset the shrinking longitude as we go towards the poles
|
||||
float rads = (abs(lat) / T7) * 0.0174532925;
|
||||
float rads = (fabs(lat) / T7) * 0.0174532925;
|
||||
_scaleLongDown = cos(rads);
|
||||
_scaleLongUp = 1.0f / cos(rads);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user