Copter: use fabsf() instead of labs()

wrap_180_cd returns a float

substracting a float from an int32 returns a float
This commit is contained in:
Peter Barker 2018-10-03 11:47:58 +10:00 committed by Andrew Tridgell
parent 1b6ec1d5ad
commit e02a645354
3 changed files with 5 additions and 5 deletions

View File

@ -1748,7 +1748,7 @@ bool Copter::ModeAuto::verify_yaw()
}
// check if we are within 2 degrees of the target heading
return (labs(wrap_180_cd(ahrs.yaw_sensor-auto_yaw.yaw())) <= 200);
return (fabsf(wrap_180_cd(ahrs.yaw_sensor-auto_yaw.yaw())) <= 200);
}
// verify_nav_wp - check if we have reached the next way point

View File

@ -431,18 +431,18 @@ bool Copter::ModeAutoTune::check_level(const LEVEL_ISSUE issue, const float curr
bool Copter::ModeAutoTune::currently_level()
{
if (!check_level(LEVEL_ISSUE_ANGLE_ROLL,
labs(ahrs.roll_sensor - roll_cd),
fabsf(ahrs.roll_sensor - roll_cd),
AUTOTUNE_LEVEL_ANGLE_CD)) {
return false;
}
if (!check_level(LEVEL_ISSUE_ANGLE_PITCH,
labs(ahrs.pitch_sensor - pitch_cd),
fabsf(ahrs.pitch_sensor - pitch_cd),
AUTOTUNE_LEVEL_ANGLE_CD)) {
return false;
}
if (!check_level(LEVEL_ISSUE_ANGLE_YAW,
labs(wrap_180_cd(ahrs.yaw_sensor-(int32_t)desired_yaw)),
fabsf(wrap_180_cd(ahrs.yaw_sensor-(int32_t)desired_yaw)),
AUTOTUNE_LEVEL_ANGLE_CD)) {
return false;
}

View File

@ -227,7 +227,7 @@ void Copter::ModeRTL::loiterathome_run()
if ((millis() - _loiter_start_time) >= (uint32_t)g.rtl_loiter_time.get()) {
if (auto_yaw.mode() == AUTO_YAW_RESETTOARMEDYAW) {
// check if heading is within 2 degrees of heading when vehicle was armed
if (labs(wrap_180_cd(ahrs.yaw_sensor-copter.initial_armed_bearing)) <= 200) {
if (fabsf(wrap_180_cd(ahrs.yaw_sensor-copter.initial_armed_bearing)) <= 200) {
_state_complete = true;
}
} else {