Copter: replace fabs() with fabsf()

This commit is contained in:
Tom Pittenger 2015-05-08 11:40:08 -07:00 committed by Andrew Tridgell
parent 1127b716c4
commit 2e191e5a3d
5 changed files with 11 additions and 11 deletions

View File

@ -127,17 +127,17 @@ static void get_pilot_desired_angle_rates(int16_t roll_in, int16_t pitch_in, int
rate_bf_level = rate_bf_level*acro_level_mix; rate_bf_level = rate_bf_level*acro_level_mix;
// Calculate rate limit to prevent change of rate through inverted // Calculate rate limit to prevent change of rate through inverted
rate_limit = fabs(fabs(rate_bf_request.x)-fabs(rate_bf_level.x)); rate_limit = fabsf(fabsf(rate_bf_request.x)-fabsf(rate_bf_level.x));
rate_bf_request.x += rate_bf_level.x; rate_bf_request.x += rate_bf_level.x;
rate_bf_request.x = constrain_float(rate_bf_request.x, -rate_limit, rate_limit); rate_bf_request.x = constrain_float(rate_bf_request.x, -rate_limit, rate_limit);
// Calculate rate limit to prevent change of rate through inverted // Calculate rate limit to prevent change of rate through inverted
rate_limit = fabs(fabs(rate_bf_request.y)-fabs(rate_bf_level.y)); rate_limit = fabsf(fabs(rate_bf_request.y)-fabsf(rate_bf_level.y));
rate_bf_request.y += rate_bf_level.y; rate_bf_request.y += rate_bf_level.y;
rate_bf_request.y = constrain_float(rate_bf_request.y, -rate_limit, rate_limit); rate_bf_request.y = constrain_float(rate_bf_request.y, -rate_limit, rate_limit);
// Calculate rate limit to prevent change of rate through inverted // Calculate rate limit to prevent change of rate through inverted
rate_limit = fabs(fabs(rate_bf_request.z)-fabs(rate_bf_level.z)); rate_limit = fabsf(fabsf(rate_bf_request.z)-fabsf(rate_bf_level.z));
rate_bf_request.z += rate_bf_level.z; rate_bf_request.z += rate_bf_level.z;
rate_bf_request.z = constrain_float(rate_bf_request.z, -rate_limit, rate_limit); rate_bf_request.z = constrain_float(rate_bf_request.z, -rate_limit, rate_limit);
} }

View File

@ -66,7 +66,7 @@ static void drift_run()
float pitch_vel = vel.y * ahrs.sin_yaw() + vel.x * ahrs.cos_yaw(); // body pitch vel float pitch_vel = vel.y * ahrs.sin_yaw() + vel.x * ahrs.cos_yaw(); // body pitch vel
// gain sceduling for Yaw // gain sceduling for Yaw
float pitch_vel2 = min(fabs(pitch_vel), 2000); float pitch_vel2 = min(fabsf(pitch_vel), 2000);
target_yaw_rate = ((float)target_roll/1.0f) * (1.0f - (pitch_vel2 / 5000.0f)) * g.acro_yaw_p; target_yaw_rate = ((float)target_roll/1.0f) * (1.0f - (pitch_vel2 / 5000.0f)) * g.acro_yaw_p;
roll_vel = constrain_float(roll_vel, -DRIFT_SPEEDLIMIT, DRIFT_SPEEDLIMIT); roll_vel = constrain_float(roll_vel, -DRIFT_SPEEDLIMIT, DRIFT_SPEEDLIMIT);

View File

@ -188,14 +188,14 @@ static void flip_run()
if (flip_roll_dir != 0) { if (flip_roll_dir != 0) {
// we are rolling // we are rolling
recovery_angle = fabs(flip_orig_attitude.x - (float)ahrs.roll_sensor); recovery_angle = fabsf(flip_orig_attitude.x - (float)ahrs.roll_sensor);
} else { } else {
// we are pitching // we are pitching
recovery_angle = fabs(flip_orig_attitude.y - (float)ahrs.pitch_sensor); recovery_angle = fabsf(flip_orig_attitude.y - (float)ahrs.pitch_sensor);
} }
// check for successful recovery // check for successful recovery
if (fabs(recovery_angle) <= FLIP_RECOVERY_ANGLE) { if (fabsf(recovery_angle) <= FLIP_RECOVERY_ANGLE) {
// restore original flight mode // restore original flight mode
if (!set_mode(flip_orig_control_mode)) { if (!set_mode(flip_orig_control_mode)) {
// this should never happen but just in case // this should never happen but just in case

View File

@ -247,7 +247,7 @@ static void poshold_run()
} }
// if velocity is very low reduce braking time to 0.5seconds // if velocity is very low reduce braking time to 0.5seconds
if ((fabs(vel_right) <= POSHOLD_SPEED_0) && (poshold.brake_timeout_roll > 50*LOOP_RATE_FACTOR)) { if ((fabsf(vel_right) <= POSHOLD_SPEED_0) && (poshold.brake_timeout_roll > 50*LOOP_RATE_FACTOR)) {
poshold.brake_timeout_roll = 50*LOOP_RATE_FACTOR; poshold.brake_timeout_roll = 50*LOOP_RATE_FACTOR;
} }
@ -341,7 +341,7 @@ static void poshold_run()
} }
// if velocity is very low reduce braking time to 0.5seconds // if velocity is very low reduce braking time to 0.5seconds
if ((fabs(vel_fw) <= POSHOLD_SPEED_0) && (poshold.brake_timeout_pitch > 50*LOOP_RATE_FACTOR)) { if ((fabsf(vel_fw) <= POSHOLD_SPEED_0) && (poshold.brake_timeout_pitch > 50*LOOP_RATE_FACTOR)) {
poshold.brake_timeout_pitch = 50*LOOP_RATE_FACTOR; poshold.brake_timeout_pitch = 50*LOOP_RATE_FACTOR;
} }

View File

@ -308,7 +308,7 @@ static bool pre_arm_checks(bool display_failure)
nav_filter_status filt_status = inertial_nav.get_filter_status(); nav_filter_status filt_status = inertial_nav.get_filter_status();
bool using_baro_ref = (!filt_status.flags.pred_horiz_pos_rel && filt_status.flags.pred_horiz_pos_abs); bool using_baro_ref = (!filt_status.flags.pred_horiz_pos_rel && filt_status.flags.pred_horiz_pos_abs);
if (using_baro_ref) { if (using_baro_ref) {
if (fabs(inertial_nav.get_altitude() - baro_alt) > PREARM_MAX_ALT_DISPARITY_CM) { if (fabsf(inertial_nav.get_altitude() - baro_alt) > PREARM_MAX_ALT_DISPARITY_CM) {
if (display_failure) { if (display_failure) {
gcs_send_text_P(SEVERITY_HIGH,PSTR("PreArm: Altitude disparity")); gcs_send_text_P(SEVERITY_HIGH,PSTR("PreArm: Altitude disparity"));
} }
@ -674,7 +674,7 @@ static bool arm_checks(bool display_failure, bool arming_from_gcs)
nav_filter_status filt_status = inertial_nav.get_filter_status(); nav_filter_status filt_status = inertial_nav.get_filter_status();
bool using_baro_ref = (!filt_status.flags.pred_horiz_pos_rel && filt_status.flags.pred_horiz_pos_abs); bool using_baro_ref = (!filt_status.flags.pred_horiz_pos_rel && filt_status.flags.pred_horiz_pos_abs);
if (((g.arming_check == ARMING_CHECK_ALL) || (g.arming_check & ARMING_CHECK_BARO)) && using_baro_ref) { if (((g.arming_check == ARMING_CHECK_ALL) || (g.arming_check & ARMING_CHECK_BARO)) && using_baro_ref) {
if (fabs(inertial_nav.get_altitude() - baro_alt) > PREARM_MAX_ALT_DISPARITY_CM) { if (fabsf(inertial_nav.get_altitude() - baro_alt) > PREARM_MAX_ALT_DISPARITY_CM) {
if (display_failure) { if (display_failure) {
gcs_send_text_P(SEVERITY_HIGH,PSTR("Arm: Altitude disparity")); gcs_send_text_P(SEVERITY_HIGH,PSTR("Arm: Altitude disparity"));
} }