Browse Source

Copter: compiler warning stuff

float to double promotion via fabs instead of fabsf
float to int via abs instead of fabsf
master
Tom Pittenger 10 years ago committed by Andrew Tridgell
parent
commit
44fd72cb1f
  1. 2
      ArduCopter/control_acro.pde
  2. 6
      ArduCopter/control_poshold.pde

2
ArduCopter/control_acro.pde

@ -132,7 +132,7 @@ static void get_pilot_desired_angle_rates(int16_t roll_in, int16_t pitch_in, int
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 = fabsf(fabs(rate_bf_request.y)-fabsf(rate_bf_level.y)); rate_limit = fabsf(fabsf(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);

6
ArduCopter/control_poshold.pde

@ -216,7 +216,7 @@ static void poshold_run()
poshold_update_pilot_lean_angle(poshold.pilot_roll, target_roll); poshold_update_pilot_lean_angle(poshold.pilot_roll, target_roll);
// switch to BRAKE mode for next iteration if no pilot input // switch to BRAKE mode for next iteration if no pilot input
if (is_zero(target_roll) && (abs(poshold.pilot_roll) < 2 * g.poshold_brake_rate)) { if (is_zero(target_roll) && (fabsf(poshold.pilot_roll) < 2 * g.poshold_brake_rate)) {
// initialise BRAKE mode // initialise BRAKE mode
poshold.roll_mode = POSHOLD_BRAKE; // Set brake roll mode poshold.roll_mode = POSHOLD_BRAKE; // Set brake roll mode
poshold.brake_roll = 0; // initialise braking angle to zero poshold.brake_roll = 0; // initialise braking angle to zero
@ -310,7 +310,7 @@ static void poshold_run()
poshold_update_pilot_lean_angle(poshold.pilot_pitch, target_pitch); poshold_update_pilot_lean_angle(poshold.pilot_pitch, target_pitch);
// switch to BRAKE mode for next iteration if no pilot input // switch to BRAKE mode for next iteration if no pilot input
if (is_zero(target_pitch) && (abs(poshold.pilot_pitch) < 2 * g.poshold_brake_rate)) { if (is_zero(target_pitch) && (fabsf(poshold.pilot_pitch) < 2 * g.poshold_brake_rate)) {
// initialise BRAKE mode // initialise BRAKE mode
poshold.pitch_mode = POSHOLD_BRAKE; // set brake pitch mode poshold.pitch_mode = POSHOLD_BRAKE; // set brake pitch mode
poshold.brake_pitch = 0; // initialise braking angle to zero poshold.brake_pitch = 0; // initialise braking angle to zero
@ -527,7 +527,7 @@ static void poshold_run()
static void poshold_update_pilot_lean_angle(float &lean_angle_filtered, float &lean_angle_raw) static void poshold_update_pilot_lean_angle(float &lean_angle_filtered, float &lean_angle_raw)
{ {
// if raw input is large or reversing the vehicle's lean angle immediately set the fitlered angle to the new raw angle // if raw input is large or reversing the vehicle's lean angle immediately set the fitlered angle to the new raw angle
if ((lean_angle_filtered > 0 && lean_angle_raw < 0) || (lean_angle_filtered < 0 && lean_angle_raw > 0) || (abs(lean_angle_raw) > POSHOLD_STICK_RELEASE_SMOOTH_ANGLE)) { if ((lean_angle_filtered > 0 && lean_angle_raw < 0) || (lean_angle_filtered < 0 && lean_angle_raw > 0) || (fabsf(lean_angle_raw) > POSHOLD_STICK_RELEASE_SMOOTH_ANGLE)) {
lean_angle_filtered = lean_angle_raw; lean_angle_filtered = lean_angle_raw;
} else { } else {
// lean_angle_raw must be pulling lean_angle_filtered towards zero, smooth the decrease // lean_angle_raw must be pulling lean_angle_filtered towards zero, smooth the decrease

Loading…
Cancel
Save