ArduCopter: replaced abs with labs as required in a few places.

Also fixed a small bug in the get_stabilize_pitch function in which it was using the roll (instead of pitch) to decide whether it should let the i term build-up or not.
This commit is contained in:
rmackay9 2012-08-16 17:51:09 +09:00
parent 82954f823b
commit a72bf6ef57
4 changed files with 6 additions and 6 deletions

View File

@ -22,7 +22,7 @@ get_stabilize_roll(int32_t target_angle)
int32_t target_rate = g.pi_stabilize_roll.get_p(target_angle);
int16_t i_stab;
if(abs(ahrs.roll_sensor) < 500){
if(labs(ahrs.roll_sensor) < 500){
target_angle = constrain(target_angle, -500, 500);
i_stab = g.pi_stabilize_roll.get_i(target_angle, G_Dt);
}else{
@ -54,7 +54,7 @@ get_stabilize_pitch(int32_t target_angle)
int32_t target_rate = g.pi_stabilize_pitch.get_p(target_angle);
int16_t i_stab;
if(abs(ahrs.roll_sensor) < 500){
if(labs(ahrs.pitch_sensor) < 500){
target_angle = constrain(target_angle, -500, 500);
i_stab = g.pi_stabilize_pitch.get_i(target_angle, G_Dt);
}else{
@ -159,7 +159,7 @@ get_acro_yaw2(int32_t target_rate)
decel_boost = 1;
} else if (target_rate < 0 && last_target_rate < target_rate && rate_error > 0 ){
decel_boost = 1;
} else if (target_rate == 0 && abs(current_rate) > 1000){
} else if (target_rate == 0 && labs(current_rate) > 1000){
decel_boost = 1;
} else {
decel_boost = 0;

View File

@ -715,7 +715,7 @@ static bool verify_nav_roi()
// check if mount type requires us to rotate the quad
if( camera_mount.get_mount_type() == AP_Mount::k_tilt_roll ) {
// ensure yaw has gotten to within 2 degrees of the target
if( abs(wrap_180(ahrs.yaw_sensor-auto_yaw)) <= 200 ) {
if( labs(wrap_180(ahrs.yaw_sensor-auto_yaw)) <= 200 ) {
nav_yaw = auto_yaw; // ensure target yaw for YAW_HOLD is our desired yaw
return true;
}else{

View File

@ -81,7 +81,7 @@ static void update_commands()
}else{
int32_t temp = get_bearing_cd(&next_WP, &tmp_loc) - original_target_bearing;
temp = wrap_180(temp);
fast_corner = abs(temp) < 6000;
fast_corner = labs(temp) < 6000;
}
}
}else{

View File

@ -21,7 +21,7 @@ static bool check_missed_wp()
int32_t temp;
temp = target_bearing - original_target_bearing;
temp = wrap_180(temp);
return (abs(temp) > 9000); // we passed the waypoint by 100 degrees
return (labs(temp) > 9000); // we passed the waypoint by 100 degrees
}
// ------------------------------