Skip to content

Commit cf4dd4e

Browse files
committed
APM_Control: FixedWing: add ahrs reset method
1 parent 81909b0 commit cf4dd4e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

libraries/APM_Control/AP_FW_Controller.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,10 @@ void AP_FW_Controller::get_input_shaping(float &angle, float &rate, float &accel
337337
rate = rate_target_deg;
338338
accel = accel_target_deg;
339339
}
340+
341+
// Reset the attitude target to such that a change in attitude due to a ahrs change is smooth
342+
void AP_FW_Controller::ahrs_reset()
343+
{
344+
// Update the target angle such that the angle error remains the same before and after the change in measured angle from the ahrs
345+
angle_target_deg = wrap_180(get_measured_angle() + angle_err_deg);
346+
}

libraries/APM_Control/AP_FW_Controller.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class AP_FW_Controller
5656
// Get the angle error in degrees
5757
float get_angle_error_deg() const { return angle_err_deg; }
5858

59+
// Reset the attitude target to such that a change in attitude due to a ahrs change is smooth
60+
void ahrs_reset();
61+
5962
protected:
6063
const AP_FixedWing &aparm;
6164
AP_AutoTune::ATGains gains;

0 commit comments

Comments
 (0)