Skip to content

Commit 08df142

Browse files
committed
use new get_roll_deg and friends
1 parent 6d36dd6 commit 08df142

File tree

21 files changed

+43
-45
lines changed

21 files changed

+43
-45
lines changed

AntennaTracker/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void Tracker::set_mode(Mode &newmode, const ModeReason reason)
190190
#endif
191191
gcs().send_message(MSG_HEARTBEAT);
192192

193-
nav_status.bearing = ahrs.yaw_sensor * 0.01f;
193+
nav_status.bearing = ahrs.get_yaw_deg();
194194
}
195195

196196
bool Tracker::set_mode(const uint8_t new_mode, const ModeReason reason)

ArduCopter/autoyaw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void Mode::AutoYaw::set_mode(Mode yaw_mode)
8181

8282
case Mode::LOOK_AHEAD:
8383
// Commanded Yaw to automatically look ahead.
84-
_look_ahead_yaw = copter.ahrs.yaw_sensor * 0.01; // cdeg -> deg
84+
_look_ahead_yaw = copter.ahrs.get_yaw_deg();
8585
break;
8686

8787
case Mode::RESETTOARMEDYAW:

ArduPlane/commands_logic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ void Plane::do_continue_and_change_alt(const AP_Mission::Mission_Command& cmd)
492492
} else {
493493
// use yaw based bearing hold
494494
steer_state.hold_course_cd = wrap_360_cd(ahrs.yaw_sensor);
495-
bearing = ahrs.yaw_sensor * 0.01f;
495+
bearing = ahrs.get_yaw_deg();
496496
next_WP_loc.offset_bearing(bearing, 1000); // push it out 1km
497497
}
498498

ArduPlane/mode_takeoff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void ModeTakeoff::update()
8282
const float dist = target_dist;
8383
if (!takeoff_mode_setup) {
8484
const uint16_t altitude = plane.relative_ground_altitude(false,true);
85-
const float direction = degrees(ahrs.get_yaw_rad());
85+
const float direction = ahrs.get_yaw_deg();
8686
// see if we will skip takeoff as already flying
8787
if (plane.is_flying() && (millis() - plane.started_flying_ms > 10000U) && ahrs.groundspeed() > 3) {
8888
if (altitude >= alt) {

ArduPlane/quadplane.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,7 +2547,7 @@ void QuadPlane::vtol_position_controller(void)
25472547
target_speed_xy_cms = diff_wp_norm * target_speed * 100;
25482548
target_accel_cms = diff_wp_norm * (-target_accel*100);
25492549
target_yaw_deg = degrees(diff_wp_norm.angle());
2550-
const float yaw_err_deg = wrap_180(target_yaw_deg - degrees(plane.ahrs.get_yaw_rad()));
2550+
const float yaw_err_deg = wrap_180(target_yaw_deg - plane.ahrs.get_yaw_deg());
25512551
bool overshoot = (closing_groundspeed < 0 || fabsf(yaw_err_deg) > 60);
25522552
if (overshoot && !poscontrol.overshoot) {
25532553
gcs().send_text(MAV_SEVERITY_INFO,"VTOL Overshoot d=%.1f cs=%.1f yerr=%.1f",
@@ -2996,7 +2996,7 @@ void QuadPlane::assign_tilt_to_fwd_thr(void) {
29962996
*/
29972997
float QuadPlane::get_scaled_wp_speed(float target_bearing_deg) const
29982998
{
2999-
const float yaw_difference = fabsf(wrap_180(degrees(plane.ahrs.get_yaw_rad()) - target_bearing_deg));
2999+
const float yaw_difference = fabsf(wrap_180(plane.ahrs.get_yaw_deg() - target_bearing_deg));
30003000
const float wp_speed = wp_nav->get_default_speed_xy() * 0.01;
30013001
if (yaw_difference > 20) {
30023002
// this gives a factor of 2x reduction in max speed when

ArduPlane/takeoff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void Plane::takeoff_calc_pitch(void)
211211
// increase the robustness of hand launches, particularly
212212
// in cross-winds. If we start to roll over then we reduce
213213
// pitch demand until the roll recovers
214-
float roll_error_rad = radians(constrain_float(labs(nav_roll_cd - ahrs.roll_sensor) * 0.01, 0, 90));
214+
float roll_error_rad = radians(constrain_float(labs(nav_roll_cd*0.01 - ahrs.get_roll_deg()), 0, 90));
215215
float reduction = sq(cosf(roll_error_rad));
216216
nav_pitch_cd *= reduction;
217217
}

ArduSub/turn_counter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ void Sub::update_turn_counter()
88
// Determine state
99
// 0: 0-90 deg, 1: 90-180 deg, 2: -180--90 deg, 3: -90--0 deg
1010
uint8_t turn_state;
11-
if (ahrs.get_yaw_rad() >= 0.0f && ahrs.get_yaw_rad() < radians(90)) {
11+
if (ahrs.get_yaw_rad() >= 0.0f && ahrs.get_yaw_deg() < 90) {
1212
turn_state = 0;
13-
} else if (ahrs.get_yaw_rad() > radians(90)) {
13+
} else if (ahrs.get_yaw_deg() > 90) {
1414
turn_state = 1;
15-
} else if (ahrs.get_yaw_rad() < -radians(90)) {
15+
} else if (ahrs.get_yaw_deg() < -90) {
1616
turn_state = 2;
1717
} else {
1818
turn_state = 3;

libraries/AC_AttitudeControl/AC_AttitudeControl_Multi_6DoF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ void AC_AttitudeControl_Multi_6DoF::rate_controller_run() {
2020
// if 6DoF control, always point directly up
2121
// this stops horizontal drift due to error between target and true attitude
2222
if (lateral_enable) {
23-
roll_deg = degrees(AP::ahrs().get_roll_rad());
23+
roll_deg = AP::ahrs().get_roll_deg();
2424
}
2525
if (forward_enable) {
26-
pitch_deg = degrees(AP::ahrs().get_pitch_rad());
26+
pitch_deg = AP::ahrs().get_pitch_deg();
2727
}
2828
_motors.set_roll_pitch(roll_deg,pitch_deg);
2929

libraries/AC_Avoidance/AC_Avoidance_Logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void AP_OABendyRuler::Write_OABendyRuler(const uint8_t type, const bool active,
2020
type : type,
2121
active : active,
2222
target_yaw : (uint16_t)wrap_360(target_yaw),
23-
yaw : (uint16_t)wrap_360(AP::ahrs().yaw_sensor * 0.01f),
23+
yaw : (uint16_t)wrap_360(AP::ahrs().get_yaw_deg()),
2424
target_pitch: (uint16_t)target_pitch,
2525
resist_chg : resist_chg,
2626
margin : margin,

libraries/AC_Avoidance/AP_OABendyRuler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ bool AP_OABendyRuler::update(const Location& current_loc, const Location& destin
114114
float ground_course_deg;
115115
if (ground_speed_vec.length_squared() < OA_BENDYRULER_LOW_SPEED_SQUARED) {
116116
// with zero ground speed use vehicle's heading
117-
ground_course_deg = AP::ahrs().yaw_sensor * 0.01f;
117+
ground_course_deg = AP::ahrs().get_yaw_deg();
118118
} else {
119119
ground_course_deg = degrees(ground_speed_vec.angle());
120120
}

libraries/AP_AHRS/AP_AHRS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ float AP_AHRS::wind_alignment(const float heading_deg) const
847847
*/
848848
float AP_AHRS::head_wind(void) const
849849
{
850-
const float alignment = wind_alignment(yaw_sensor*0.01f);
850+
const float alignment = wind_alignment(get_yaw_deg());
851851
return alignment * wind_estimate().xy().length();
852852
}
853853

libraries/AP_AHRS/AP_AHRS.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,9 @@ class AP_AHRS {
561561
float get_yaw_rad() const { return yaw; }
562562

563563
// roll/pitch/yaw euler angles, all in radians
564-
float get_roll_deg() const { return roll_deg; }
565-
float get_pitch_deg() const { return pitch_deg; }
566-
float get_yaw_deg() const { return yaw_deg; }
564+
float get_roll_deg() const { return rpy_deg[0]; }
565+
float get_pitch_deg() const { return rpy_deg[1]; }
566+
float get_yaw_deg() const { return rpy_deg[2]; }
567567

568568
// helper trig value accessors
569569
float cos_roll() const {
@@ -586,9 +586,7 @@ class AP_AHRS {
586586
}
587587

588588
// floating point Euler angles (Degrees)
589-
float roll_deg;
590-
float pitch_deg;
591-
float yaw_deg;
589+
float rpy_deg[3];
592590

593591
// integer Euler angles (Degrees * 100)
594592
int32_t roll_sensor;

libraries/AP_AHRS/AP_AHRS_Backend.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ void AP_AHRS::update_trig(void)
151151
*/
152152
void AP_AHRS::update_cd_values(void)
153153
{
154-
roll_deg = degrees(roll);
155-
pitch_deg = degrees(pitch);
156-
yaw_deg = degrees(yaw);
157-
if (yaw_deg < 0) {
158-
yaw_deg += 360;
154+
rpy_deg[0] = degrees(roll);
155+
rpy_deg[1] = degrees(pitch);
156+
rpy_deg[2] = degrees(yaw);
157+
if (rpy_deg[2] < 0) {
158+
rpy_deg[2] += 360;
159159
}
160160

161-
roll_sensor = roll_deg * 100;
162-
pitch_sensor = pitch_deg * 100;
163-
yaw_sensor = yaw_deg * 100;
161+
roll_sensor = rpy_deg[0] * 100;
162+
pitch_sensor = rpy_deg[1] * 100;
163+
yaw_sensor = rpy_deg[2] * 100;
164164
}
165165

166166
/*

libraries/AP_Compass/Compass_learn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void CompassLearn::update(void)
4343
// no GSF available
4444
return;
4545
}
46-
if (degrees(fabsf(ahrs.get_pitch_rad())) > 50) {
46+
if (fabsf(ahrs.get_pitch_deg()) > 50) {
4747
// we don't want to be too close to nose up, or yaw gets
4848
// problematic. Tailsitters need to wait till they are in
4949
// forward flight

libraries/AP_DroneCAN/AP_DroneCAN.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ void AP_DroneCAN::notify_state_send()
10471047
#endif // HAL_BUILD_AP_PERIPH
10481048

10491049
msg.aux_data_type = ARDUPILOT_INDICATION_NOTIFYSTATE_VEHICLE_YAW_EARTH_CENTIDEGREES;
1050-
uint16_t yaw_cd = (uint16_t)(360.0f - degrees(AP::ahrs().get_yaw_rad()))*100.0f;
1050+
uint16_t yaw_cd = (uint16_t)(360.0f - AP::ahrs().get_yaw_deg())*100.0f;
10511051
const uint8_t *data = (uint8_t *)&yaw_cd;
10521052
for (uint8_t i=0; i<2; i++) {
10531053
msg.aux_data.data[i] = data[i];

libraries/AP_LTM_Telem/AP_LTM_Telem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ void AP_LTM_Telem::send_Aframe(void)
181181
{
182182
AP_AHRS &ahrs = AP::ahrs();
183183
WITH_SEMAPHORE(ahrs.get_semaphore());
184-
pitch = roundf(ahrs.pitch_sensor * 0.01); // attitude pitch in degrees
185-
roll = roundf(ahrs.roll_sensor * 0.01); // attitude roll in degrees
186-
heading = roundf(ahrs.yaw_sensor * 0.01); // heading in degrees
184+
pitch = roundf(ahrs.get_pitch_deg()); // attitude pitch in degrees
185+
roll = roundf(ahrs.get_roll_deg()); // attitude roll in degrees
186+
heading = roundf(ahrs.get_yaw_deg()); // heading in degrees
187187
}
188188
#else
189189
pitch = 0;

libraries/AP_MSP/AP_MSP_Telem_Backend.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,9 +905,9 @@ MSPCommandResult AP_MSP_Telem_Backend::msp_process_out_attitude(sbuf_t *dst)
905905
int16_t pitch;
906906
int16_t yaw;
907907
} attitude {
908-
roll : int16_t(ahrs.roll_sensor * 0.1), // centidegress to decidegrees
909-
pitch : int16_t(ahrs.pitch_sensor * 0.1), // centidegress to decidegrees
910-
yaw : int16_t(ahrs.yaw_sensor * 0.01) // centidegress to degrees
908+
roll : int16_t(ahrs.get_roll_deg() * 10), // degress to decidegrees
909+
pitch : int16_t(ahrs.get_pitch_deg() * 10), // degress to decidegrees
910+
yaw : int16_t(ahrs.get_yaw_deg())
911911
};
912912

913913
sbuf_write_data(dst, &attitude, sizeof(attitude));

libraries/AP_Mount/AP_Mount_Backend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void AP_Mount_Backend::calculate_poi()
554554
// iteratively move test_loc forward until its alt-above-sea-level is below terrain-alt-above-sea-level
555555
const float dist_increment_m = MAX(terrain->get_grid_spacing(), 10);
556556
const float mount_pitch_deg = degrees(quat.get_euler_pitch());
557-
const float mount_yaw_ef_deg = wrap_180(degrees(quat.get_euler_yaw()) + degrees(ahrs.get_yaw_rad()));
557+
const float mount_yaw_ef_deg = wrap_180(degrees(quat.get_euler_yaw()) + ahrs.get_yaw_deg());
558558
float total_dist_m = 0;
559559
bool get_terrain_alt_success = true;
560560
float prev_terrain_amsl_m = terrain_amsl_m;

libraries/AP_Mount/AP_Mount_Viewpro.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,16 +681,16 @@ bool AP_Mount_Viewpro::send_m_ahrs()
681681
uint16_t gps_vdop = AP::gps().get_vdop();
682682

683683
// get vehicle yaw in the range 0 to 360
684-
const uint16_t veh_yaw_deg = wrap_360(degrees(AP::ahrs().get_yaw_rad()));
684+
const uint16_t veh_yaw_deg = wrap_360(AP::ahrs().get_yaw_deg());
685685

686686
// fill in packet
687687
const M_AHRSPacket mahrs_packet {
688688
.content = {
689689
frame_id: FrameId::M_AHRS,
690690
data_type: 0x07, // Bit0: Attitude, Bit1: GPS, Bit2 Gyro
691691
unused2to8 : {0, 0, 0, 0, 0, 0, 0},
692-
roll_be: htobe16(degrees(AP::ahrs().get_roll_rad()) * AP_MOUNT_VIEWPRO_DEG_TO_OUTPUT), // vehicle roll angle. 1bit=360deg/65536
693-
pitch_be: htobe16(-degrees(AP::ahrs().get_pitch_rad()) * AP_MOUNT_VIEWPRO_DEG_TO_OUTPUT), // vehicle pitch angle. 1bit=360deg/65536
692+
roll_be: htobe16(AP::ahrs().get_roll_deg() * AP_MOUNT_VIEWPRO_DEG_TO_OUTPUT), // vehicle roll angle. 1bit=360deg/65536
693+
pitch_be: htobe16(-AP::ahrs().get_pitch_deg() * AP_MOUNT_VIEWPRO_DEG_TO_OUTPUT), // vehicle pitch angle. 1bit=360deg/65536
694694
yaw_be: htobe16(veh_yaw_deg * AP_MOUNT_VIEWPRO_DEG_TO_OUTPUT), // vehicle yaw angle. 1bit=360deg/65536
695695
date_be: htobe16(date), // bit0~6:year, bit7~10:month, bit11~15:day
696696
seconds_utc: {uint8_t((second_hundredths & 0xFF0000ULL) >> 16), // seconds * 100 MSB. 1bit = 0.01sec

libraries/AP_NMEA_Output/AP_NMEA_Output.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ void AP_NMEA_Output::update()
251251
#if AP_AHRS_ENABLED
252252
if ((_message_enable_bitmask.get() & static_cast<int16_t>(Enabled_Messages::PASHR)) != 0) {
253253
// get roll, pitch, yaw
254-
const float roll_deg = wrap_180(degrees(ahrs.get_roll_rad()));
255-
const float pitch_deg = wrap_180(degrees(ahrs.get_pitch_rad()));
256-
const float yaw_deg = wrap_360(degrees(ahrs.get_yaw_rad()));
254+
const float roll_deg = wrap_180(ahrs.get_roll_deg());
255+
const float pitch_deg = wrap_180(ahrs.get_pitch_deg());
256+
const float yaw_deg = wrap_360(ahrs.get_yaw_deg());
257257
const float heave_m = 0; // instantaneous heave in meters
258258
const float roll_deg_accuracy = 0; // stddev of roll_deg;
259259
const float pitch_deg_accuracy = 0; // stddev of pitch_deg;

libraries/AR_WPNav/AR_PivotTurn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void AR_PivotTurn::check_activation(float desired_heading_deg, bool force_active
9494
}
9595

9696
// calc yaw error in degrees
97-
const float yaw_error = fabsf(wrap_180(desired_heading_deg - (AP::ahrs().yaw_sensor * 0.01f)));
97+
const float yaw_error = fabsf(wrap_180(desired_heading_deg - (AP::ahrs().get_yaw_deg())));
9898

9999
// if error is larger than _pivot_angle start pivot steering
100100
if (yaw_error > _angle || force_active) {

0 commit comments

Comments
 (0)