Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AHRS: add pre-arm check that attitudes are consistent #10575

Merged
merged 5 commits into from
Feb 22, 2019

Conversation

rmackay9
Copy link
Contributor

@rmackay9 rmackay9 commented Feb 20, 2019

This PR adds and changes two pre-arm checks to resolve this issue which stems from a crash of a vehicle running Copter-3.6.6 where the backup EKF flipped over while the vehicle was disarmed (probably because the user ran a compass calibration but did not reboot the board because the pre-arm compass checks were disabled).

  • makes the compass calibration pre-arm checks mandatory (i.e. they cannot be turned off)
  • adds a new attitude check that all AHRSs (DCM, EKF2, EKF3) are close to the attitude from whichever of these is primary. The threshold is set to 5deg roll/pitch, 15deg yaw. This new check is part of the INS pre-arm checks.

This has been tested in SITL by adding some debug and then setting these parameters to throw off some of the attitude estimates.

To make the roll/pitch check fail I adjusted the accelerometer offsets as follows:

  • param set INS_ACCOFS_X 1

To make the yaw check fail I set the compass offsets as follows:

  • param set COMPASS_OFS_X 200
  • param set COMPASS_OFS_Y 200

Picture of some SITL testing
att-check-sitl

Copy link
Contributor

@khancyr khancyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
I just have a little concern about what append if we don't have DCM ? Will the check failed ?

libraries/AP_Arming/AP_Arming.cpp Outdated Show resolved Hide resolved
libraries/AP_AHRS/AP_AHRS_NavEKF.cpp Outdated Show resolved Hide resolved
@rmackay9
Copy link
Contributor Author

I've done some additional tests of the attitude check by manually creating pairs of quaternions (from eulers) and then comparing whether they pass or fail the tests. Below are the results.

To explain this screenshot:

  • x1,y1,z1 are the euler angles (in degrees) used to create the 1st quaternion
  • x2,y2,z2 are the euler angles for the 2nd quaternion
  • dx, dy, dz shows the angular difference (in degrees) of the comparison
  • rpOK, yOK say whether the test passed ("1") or failed ("0") the roll/pitch threshold (10deg) and yaw threshold (20deg)
    sitl-att-tests
    The results look OK to me although you can see in test 22 the yaw error (of 15deg) ends up appearing as 7.5deg in roll-pitch, 7.5deg in yaw. Still, I think this is OK.

@peterbarker
Copy link
Contributor

peterbarker commented Feb 21, 2019 via email

@rmackay9
Copy link
Contributor Author

I've made a minor fix to make DCM return true if it's the only AHRS. This was causing some example sketches to fail.

I've also done some more testing in which I've made it display the roll, pitch and yaw difference between the main EKF and a hard-coded fake EKF with roll/pitch/yaw of 0/0/0 and I'm convinced that this check will not incorrectly every say the attitudes match when they don't.

@rmackay9 rmackay9 merged commit b202270 into ArduPilot:master Feb 22, 2019
@rmackay9
Copy link
Contributor Author

Merged, thanks!

@rmackay9 rmackay9 deleted the ahrs-attitude-check2 branch February 22, 2019 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AHRS: add DCM/EKF attitude consistency pre-arm check
3 participants