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

IMU heading #262

Open
tremblin opened this issue Sep 8, 2024 · 4 comments
Open

IMU heading #262

tremblin opened this issue Sep 8, 2024 · 4 comments

Comments

@tremblin
Copy link

tremblin commented Sep 8, 2024

IMU code for heading is missing (see TODO).

double heading = 0.0; // TODO

Please complete the code for heading.

@tremblin
Copy link
Author

i've tried to calculate this on my own in LUA based on the frame.imu.raw() data. however the reading from the magnetometer seems to be wrong. it should read -|B| µT or +|B| µT if an axis is aligned to magnetic north (see https://eu.mouser.com/datasheet/2/821/MC6470_Datasheet_APS_048_0033v1_7_1-3003085.pdf, page 6), but i never get negative values from the readings!?

further your frame's coordinate system is a bit odd: i would envision the x-axis is pointing from the nose forward (direction of sight), y-axis to the right and z-axis down. in your case it seems the x-axis points left, y-axis backwards and z-axis downwards.

a good readup on axis + pcb placement and pitch/roll/yaw calculation can be found at https://www.mikrocontroller.net/attachment/292888/AN4248.pdf.

@sshipman
Copy link

sshipman commented Nov 2, 2024

The AN4248 paper is an excellent resource for the algorithm, but it kind of makes hard iron estimation seem way more complex than it needs to be. Basically, you can just move the device around in all sorts of orientations while recording min and max magnetic field ratings in all 3 dimensions, then the hard iron offsets are just the average in each dimension.
another resource:

https://github.com/kriswiner/MPU6050/wiki/Simple-and-Effective-Magnetometer-Calibration

@CitizenOneX
Copy link

Just in relation to the raw data readings from the magnetometer - they don't seem to be calibrated and adjusted with offsets in the sensor itself, but we can calibrate the values ourselves in the application and offset them - e.g. after calibration I used (-1112.50, -450.50, -6855.00) to be added to the raw values to get values ranging around 0 and sensible heading values.
Example app

In terms of implementing heading on Frame itself, it would seem that it would technically be possible to perform calibration (out of band with the request for heading, presumably!) and tilt-adjustment to calculate a heading value, but adjustments for declination would presumably need to take place in a connected app with a GPS and internet connection? Or, maybe all of it is done in-app if the preference is to keep Frame code lean?

@zachary-kaelan
Copy link

Page 27 of the datasheet mentions "offset calibration" for the magnetometer, but has minimal information on how it works. Regardless, the offsets can be placed into registers manually and supposedly will be used when compensating the readings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants