-
Notifications
You must be signed in to change notification settings - Fork 72
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
Compass Alignment with Roll and Pitch Axes (DMP) #145
Comments
Hi @Gord1 , Welcome to the weird and wonderful world of the ICM20948 DMP! Agreed. I'm seeing the same thing. Looks like I've got a rotation in there. My setup: SparkFun ESP32 Thing Plus C, connected to a SparkFun ICM-20948 breakout via I2C; Arduino IDE 1.8.19; Espressif ESP32 boards 3.0.1. If I let Example11 run for a while, do the three rotations and six holds, the Yaw reports 0 degrees when the Accel/Gyro Y axis is pointing towards magnetic North. But, yes, roll and pitch are reversed. Also, Yaw goes negative when I rotate clockwise from North. IIRC, I used the conversion code from here (or a very similar source): https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Source_code_2 In the example code, I assumed Q0/1/2/3 mapped onto Qw/x/y/z. That appears to be untrue... I don't have time to dig into this right now. I will try and get to it ~soon. If you have time and can correct the sequence, please do and send us a Pull Request. Best wishes, |
Hi @PaulZC Many thanks for looking into this and confirming the issue.
The coordinate frame for the accelerometer and gyro are different than the magnetometer on the ICM20948. Do you have any information on the coordinate frame for the DMP and how it relates to the physical chip? There are a lot of combinations to start trying them randomly shooting in the dark. Thanks, |
Hi Gord, There are no clues about coordinate frames in the DMP application note... But this may help: Best, |
Hi @PaulZC, In the example 11 code the 4th quaternion is calculated by This is always taken as positive while it could be +/- as it is the square root. Depending on whether you take the positive q0 or negative, don't you get a different rotation? Regards, |
This seems to be the directions for both the Gyro and the Quaternion. If I tilt the board around the x-axis both the gx and q1 increase for +ve rotation. The same for the y and z axis. For the roll, pitch, yaw calculation equations in example 11, I'm guessing that the x-axis is defined as forward and not the y-axis as shown above. I'm not familiar with quats. I guess we should we switching q1,q2 and q3 around. Gord |
Hi @PaulZC, Here is the bit of code to swap the axis around so they work with the equations that are in standard aircraft dynamics form:
Now do conversion ... Regards, |
Hi Gord (@Gord1 ), Thank you. I went with the following, to avoid messing up the QUAT_ANIMATION: Lines 346 to 367 in 168c18b
I'll release these changes in a few minutes. Thanks again, |
Subject of the issue
I'm finding that the Compass (yaw) is 90 deg off from what I'm expecting with respect to the roll and pitch directions.
I'm using SparkFun Example11_DMP_Bias_Save_Restore_ESP32 that I have modified slightly for the ESP8266. This example takes the quaternion data and calculates roll, pitch and yaw. The angles are all good, except for the zero reference for the yaw angle. That seems to be rotated 90 deg.
If I set the board flat with 0 yaw, the "nose" of the board will point north. If I lift the nose up I would expect the pitch angle to change, but the roll changes.
issue #114 @texasfunambule may have made a comment about this > The quat9 example seems to work fine (except maybe for compass alignement)
Could the quaternion components be mixed in the roll, pitch, yaw equations?? That is beyond my pay grade.
The text was updated successfully, but these errors were encountered: