Skip to content

Commit 400dc16

Browse files
peterbarkertridge
authored andcommitted
ArduPlane: use get_roll_deg in place of roll_sensor (etc.)
1 parent fbce66e commit 400dc16

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

ArduPlane/Plane.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ void Plane::airspeed_ratio_update(void)
431431
return;
432432
}
433433
if (labs(ahrs.roll_sensor) > roll_limit_cd ||
434-
ahrs.pitch_sensor > aparm.pitch_limit_max*100 ||
435-
ahrs.pitch_sensor < pitch_limit_min*100) {
434+
ahrs.get_pitch_deg() > aparm.pitch_limit_max ||
435+
ahrs.get_pitch_deg() < pitch_limit_min) {
436436
// don't calibrate when going beyond normal flight envelope
437437
return;
438438
}

ArduPlane/VTOL_Assist.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ bool VTOL_Assist::should_assist(float aspeed, bool have_airspeed)
132132

133133
if (angle_error.update(!inside_envelope && !inside_angle_error, now_ms, tigger_delay_ms, clear_delay_ms)) {
134134
gcs().send_text(MAV_SEVERITY_WARNING, "Angle assist r=%d p=%d",
135-
(int)(plane.ahrs.roll_sensor/100),
136-
(int)(plane.ahrs.pitch_sensor/100));
135+
(int)plane.ahrs.get_roll_deg(),
136+
(int)plane.ahrs.get_pitch_deg());
137137
}
138138
}
139139

@@ -194,7 +194,7 @@ bool VTOL_Assist::check_VTOL_recovery(void)
194194
fabsf(gyro.x) > radians(30) &&
195195
fabsf(gyro.y) > radians(30) &&
196196
gyro.x * gyro.z < 0 &&
197-
plane.ahrs.pitch_sensor < -4500;
197+
plane.ahrs.get_pitch_deg() < -45;
198198
} else {
199199
quadplane.in_spin_recovery = false;
200200
}

ArduPlane/commands_logic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void Plane::do_continue_and_change_alt(const AP_Mission::Mission_Command& cmd)
500500
} else {
501501
// use yaw based bearing hold
502502
steer_state.hold_course_cd = wrap_360_cd(ahrs.yaw_sensor);
503-
bearing = ahrs.yaw_sensor * 0.01f;
503+
bearing = ahrs.get_yaw_deg();
504504
next_WP_loc.offset_bearing(bearing, 1000); // push it out 1km
505505
}
506506

ArduPlane/is_flying.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ void Plane::crash_detection_update(void)
232232
// Declare a crash if we are oriented more that 60deg in pitch or roll
233233
if (!crash_state.checkedHardLanding && // only check once
234234
been_auto_flying &&
235-
(labs(ahrs.roll_sensor) > 6000 || labs(ahrs.pitch_sensor) > 6000)) {
236-
235+
(fabsf(ahrs.get_roll_deg()) > 60 || fabsf(ahrs.get_pitch_deg()) > 60)) {
237236
crashed = true;
238237

239238
// did we "crash" within 75m of the landing location? Probably just a hard landing

ArduPlane/mode_autoland.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ bool ModeAutoLand::landing_lined_up(void)
301301
void ModeAutoLand::arm_check(void)
302302
{
303303
if (plane.ahrs.use_compass() && autoland_option_is_set(ModeAutoLand::AutoLandOption::AUTOLAND_DIR_ON_ARM)) {
304-
set_autoland_direction(plane.ahrs.yaw_sensor * 0.01);
304+
set_autoland_direction(plane.ahrs.get_yaw_deg());
305305
}
306306
}
307307

ArduPlane/pullup.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,26 @@ bool GliderPullup::verify_pullup(void)
115115
switch (stage) {
116116
case Stage::WAIT_AIRSPEED: {
117117
float aspeed;
118-
if (ahrs.airspeed_estimate(aspeed) && (aspeed > airspeed_start || ahrs.pitch_sensor*0.01 > pitch_start)) {
118+
if (ahrs.airspeed_estimate(aspeed) && (aspeed > airspeed_start || ahrs.get_pitch_deg() > pitch_start)) {
119119
gcs().send_text(MAV_SEVERITY_INFO, "Pullup airspeed %.1fm/s alt %.1fm AMSL", aspeed, current_loc.alt*0.01);
120120
stage = Stage::WAIT_PITCH;
121121
}
122122
return false;
123123
}
124124

125125
case Stage::WAIT_PITCH: {
126-
if (ahrs.pitch_sensor*0.01 > pitch_start && fabsf(ahrs.roll_sensor*0.01) < 90) {
126+
if (ahrs.get_pitch_deg() > pitch_start && fabsf(ahrs.get_roll_deg()) < 90) {
127127
gcs().send_text(MAV_SEVERITY_INFO, "Pullup pitch p=%.1f r=%.1f alt %.1fm AMSL",
128-
ahrs.pitch_sensor*0.01,
129-
ahrs.roll_sensor*0.01,
128+
ahrs.get_pitch_deg(),
129+
ahrs.get_roll_deg(),
130130
current_loc.alt*0.01);
131131
stage = Stage::WAIT_LEVEL;
132132
}
133133
return false;
134134
}
135135

136136
case Stage::PUSH_NOSE_DOWN: {
137-
if (fabsf(ahrs.roll_sensor*0.01) < aparm.roll_limit) {
137+
if (fabsf(ahrs.get_roll_deg()) < aparm.roll_limit) {
138138
stage = Stage::WAIT_LEVEL;
139139
}
140140
return false;
@@ -143,21 +143,21 @@ bool GliderPullup::verify_pullup(void)
143143
case Stage::WAIT_LEVEL: {
144144
// When pitch has raised past lower limit used by speed controller, wait for airspeed to approach
145145
// target value before handing over control of pitch demand to speed controller
146-
bool pitchup_complete = ahrs.pitch_sensor*0.01 > MIN(0, aparm.pitch_limit_min);
146+
bool pitchup_complete = ahrs.get_pitch_deg() > MIN(0, aparm.pitch_limit_min);
147147
const float pitch_lag_time = 1.0f * sqrtf(ahrs.get_EAS2TAS());
148148
float aspeed;
149149
const float aspeed_derivative = (ahrs.get_accel().x + GRAVITY_MSS * ahrs.get_DCM_rotation_body_to_ned().c.x) / ahrs.get_EAS2TAS();
150150
bool airspeed_low = ahrs.airspeed_estimate(aspeed) ? (aspeed + aspeed_derivative * pitch_lag_time) < 0.01f * (float)plane.target_airspeed_cm : true;
151-
bool roll_control_lost = fabsf(ahrs.roll_sensor*0.01) > aparm.roll_limit;
151+
bool roll_control_lost = fabsf(ahrs.get_roll_deg()) > aparm.roll_limit;
152152
if (pitchup_complete && airspeed_low && !roll_control_lost) {
153153
gcs().send_text(MAV_SEVERITY_INFO, "Pullup level r=%.1f p=%.1f alt %.1fm AMSL",
154-
ahrs.roll_sensor*0.01, ahrs.pitch_sensor*0.01, current_loc.alt*0.01);
154+
ahrs.get_roll_deg(), ahrs.get_pitch_deg(), current_loc.alt*0.01);
155155
break;
156156
} else if (pitchup_complete && roll_control_lost) {
157157
// push nose down and wait to get roll control back
158158
gcs().send_text(MAV_SEVERITY_ALERT, "Pullup level roll bad r=%.1f p=%.1f",
159-
ahrs.roll_sensor*0.01,
160-
ahrs.pitch_sensor*0.01);
159+
ahrs.get_roll_deg(),
160+
ahrs.get_pitch_deg());
161161
stage = Stage::PUSH_NOSE_DOWN;
162162
}
163163
return false;

ArduPlane/servos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ bool Plane::suppress_throttle(void)
114114
if (is_flying() &&
115115
millis() - started_flying_ms > MAX(launch_duration_ms, 5000U) && // been flying >5s in any mode
116116
adjusted_relative_altitude_cm() > 500 && // are >5m above AGL/home
117-
labs(ahrs.pitch_sensor) < 3000 && // not high pitch, which happens when held before launch
117+
fabsf(ahrs.get_pitch_deg()) < 30 && // not high pitch, which happens when held before launch
118118
gps_movement) { // definite gps movement
119119
// we're already flying, do not suppress the throttle. We can get
120120
// stuck in this condition if we reset a mission and cmd 1 is takeoff

0 commit comments

Comments
 (0)