Repository navigation
(Updated) Implement Mahony filter for attitude estimation- #142 - #156
NArmistead merged 53 commits into
Conversation
|
I still need to fix a bunch of unit tests because everything broke |
|
@NArmistead Please rebase the base of this stack as too many intermediate revisions have been picked up for me to review. |
ETSells
left a comment
There was a problem hiding this comment.
Let's do a rebase before I can pick this up. There's too many intermediate revs since the base of this stack is too far back.
Alternatively, merge main into both branches (or just the base) to take out all of these intermediate revs.
This reverts commit 4fe0097.
This reverts commit 4fe0097.
935e1c6 to
b7dce3f
Compare
|
that was horrible and it probably broke something |
There was a problem hiding this comment.
shouldnt be needed, test framework gitignore should handle this
| @@ -0,0 +1,311 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file : mahony.h | |||
| */ | ||
| MAHONY_STATUS mahony_init | ||
| ( | ||
| MAHONY_FILTER *filter, |
There was a problem hiding this comment.
this is so based alexa play despacito
this is a phenomenal example of what we should do for libraries
| } | ||
|
|
||
| if ( !isfinite(proportional_gain) | ||
| || !isfinite(integral_gain) ) |
There was a problem hiding this comment.
nit: my pref for conditionals is to have each predicate start at the same column UNLESS its nested
| */ | ||
| if ( apply_accel && vector_normalize(&accel_body) ) | ||
| { | ||
| /* |
|
|
||
| /* | ||
| * Accelerometer feedback is optional. If the measurement is invalid or has | ||
| * zero magnitude, continue with gyroscope-only propagation. |
| * Converted gyro data is in degrees per second. Mahony requires radians per | ||
| * second. | ||
| */ | ||
| gyro_body_rad_s.x = deg_to_rad(imu_converted->gyro_x); |
There was a problem hiding this comment.
is there a reason why our internal unit is not consistent across APIs?
There was a problem hiding this comment.
we get degrees per sec from gyro, but honestly we should just convert it to radians and use that consistently
|
Just tested it and it works, so im gonna ship it. Most of the actual work here was done by @bjornhbengtsson so credit to him This will break CI for a bit though |
|
actually this is breaking the emulator build somehow |
This description is from @bjornhbengtsson's PR
My changes were to flip the sign on z-axis gravity in a lot of places and disable yaw correction.
Child: FCF
Description
Implements the Mahony attitude filter for quaternion based attitude estimation.
The filter maintains a body-to-world attitude quaternion using body frame gyroscope propagation with proportional and integral accelerometer feedback.
Made with assistance of ChatGPT 5.6.
Changes include:
Issue Link
Depends on #138
#138
Closes #141
#141
Testing
Mahony unit test results:

-------------Test Complete--------------
Passes: 140
Fails: 0
Result: PASS
Math test results:
-------------Test Complete--------------
Passes: 26
Fails: 0
Result: PASS
Other
Accelerometer correction is only applied when:
When accelerometer feedback is disabled or rejected, the filter continues using gyroscope only propagation.
The current accelerometer thresholds, proportional gain, integral gain, and integral limit are initial software values. Final tuning should be performed using hardware characterization, vibration testing, and flight data.
Deferred work includes:
Reviewer Checklist
Standards
Error Handling
Memory
Performance