-
Notifications
You must be signed in to change notification settings - Fork 28
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
Incorporate AHRS acc2q into zscilib as zsl_quat_from_accel #63
base: master
Are you sure you want to change the base?
Conversation
As per the comment in #62, can you create a PR in Zephyr that references this commit so that it can go through the normal test suite before being merged? Thanks for the changes, though ... much appreciated. |
Please also add some details in the commit messages and add a signed-off-by to make sure you get the proper credit for the work. |
f10cdd0
to
1ce505d
Compare
Add zsl_quat_from_accel header to quaternions.h Incorporate AHRS acc2q into zscilib as zsl_quat_from_accel Currently, the zscilib's Madgwick orientation filter starts with an orientation of <1, 0, 0, 0> regardless of the physical IMU's orientation. The filter then begins the slow/painful process of converging to the correct orientation which can take literally minutes. For an IMU running at 120Hz, the worst-case Madgwick convergence time is about 47 seconds (β * Dt = 0.033 * 1/120Hz). This is far too long for a warm-up; a Madgwick filter that has not yet converged will output spurious and confusing orientations and result in a bad user experience. A python implementation of Magwick, called AHRS, solves this bootstrapping problem with a non-iterative algorithm called acc2q (acceleration => quat) AHRS Implementation: https://github.com/Mayitzin/ahrs/blob/595ab9877c77f5960e39b352c0ef551d2d2efcb9/ahrs/common/orientation.py#L970 Reference: ([Trimpe et al] https://idsc.ethz.ch/content/dam/ethz/special-interest/mavt/dynamic-systems-n-control/idsc-dam/Research_DAndrea/Balancing%20Cube/ICRA10_1597_web.pdf This algorithm that relies only on the current accelerometer sample. The integration of the acc2q algorithm is highlighted in the below flow diagram (dotted red block). ![diagram](https://github.com/user-attachments/assets/6a32fe55-2233-4b40-bec4-85e4af0750a3) Computing q0 and feeing this into Madgwick results in a very reasonable q0 orientation and a much better overall experience. Signed-off-by: Ismail Degani <[email protected]>
1ce505d
to
925d63c
Compare
zscilib: fix computational errors This diff adds a top-level Zephyr PR for the zscilib enhancements described in detail here: zephyrproject-rtos/zscilib#63 Signed-off-by: Ismail Degani <[email protected]>
Thanks for the review. Please see my updates:
|
Ping @microbuilder |
As per some comments in the discord there are still quite a few issues with this preventing it from being it from being mergable. |
Currently, the zscilib's Madgwick orientation filter starts with an orientation of <1, 0, 0, 0> regardless of the physical IMU's orientation.
The filter then begins the slow/painful process of converging to the correct orientation which can take nearly a minute. For an IMU running at 120Hz, the worst-case Madgwick convergence time is about 47 seconds (β * Dt = 0.033 * 1/120Hz). This is far too long for a warm-up; a Madgwick filter that has not yet converged will output spurious and confusing orientations and result in a bad user experience.
A python implementation of Magwick, called AHRS, solves this bootstrapping problem with a non-iterative algorithm called acc2q (acceleration => quat)
AHRS Implementation:
https://github.com/Mayitzin/ahrs/blob/595ab9877c77f5960e39b352c0ef551d2d2efcb9/ahrs/common/orientation.py#L970
Reference:
([Trimpe et al] https://idsc.ethz.ch/content/dam/ethz/special-interest/mavt/dynamic-systems-n-control/idsc-dam/Research_DAndrea/Balancing%20Cube/ICRA10_1597_web.pdf
This algorithm that relies only on the current accelerometer sample. The integration of the acc2q algorithm is highlighted in the below flow diagram (dotted red block).
Computing q0 and feeding this into Madgwick results in a very reasonable q0 orientation and a much better overall experience.