CN119022905B - An automatic calibration method for electronic compass based on MEMS sensor - Google Patents
An automatic calibration method for electronic compass based on MEMS sensor Download PDFInfo
- Publication number
- CN119022905B CN119022905B CN202411517385.9A CN202411517385A CN119022905B CN 119022905 B CN119022905 B CN 119022905B CN 202411517385 A CN202411517385 A CN 202411517385A CN 119022905 B CN119022905 B CN 119022905B
- Authority
- CN
- China
- Prior art keywords
- axis
- magnetic field
- directions
- carrier
- electronic compass
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01C—MEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
- G01C17/00—Compasses; Devices for ascertaining true or magnetic north for navigation or surveying purposes
- G01C17/38—Testing, calibrating, or compensating of compasses
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01C—MEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
- G01C17/00—Compasses; Devices for ascertaining true or magnetic north for navigation or surveying purposes
- G01C17/02—Magnetic compasses
- G01C17/28—Electromagnetic compasses
- G01C17/32—Electron compasses
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01C—MEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
- G01C21/00—Navigation; Navigational instruments not provided for in groups G01C1/00 - G01C19/00
- G01C21/10—Navigation; Navigational instruments not provided for in groups G01C1/00 - G01C19/00 by using measurements of speed or acceleration
- G01C21/12—Navigation; Navigational instruments not provided for in groups G01C1/00 - G01C19/00 by using measurements of speed or acceleration executed aboard the object being navigated; Dead reckoning
- G01C21/16—Navigation; Navigational instruments not provided for in groups G01C1/00 - G01C19/00 by using measurements of speed or acceleration executed aboard the object being navigated; Dead reckoning by integrating acceleration or speed, i.e. inertial navigation
- G01C21/165—Navigation; Navigational instruments not provided for in groups G01C1/00 - G01C19/00 by using measurements of speed or acceleration executed aboard the object being navigated; Dead reckoning by integrating acceleration or speed, i.e. inertial navigation combined with non-inertial navigation instruments
- G01C21/1654—Navigation; Navigational instruments not provided for in groups G01C1/00 - G01C19/00 by using measurements of speed or acceleration executed aboard the object being navigated; Dead reckoning by integrating acceleration or speed, i.e. inertial navigation combined with non-inertial navigation instruments with electromagnetic compass
Landscapes
- Engineering & Computer Science (AREA)
- Radar, Positioning & Navigation (AREA)
- Remote Sensing (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Electromagnetism (AREA)
- Automation & Control Theory (AREA)
- Measuring Magnetic Variables (AREA)
Abstract
The invention discloses an electronic compass automatic calibration method based on an MEMS sensor. The method comprises the steps of collecting acceleration of a carrier in the directions of an X axis, a Y axis and a Z axis, calculating attitude angles of the carrier in the directions of the X axis and the Y axis, obtaining the current measured magnetic field intensity of a magnetometer of the electronic compass, calculating and updating the theoretical magnetic field intensity of the carrier in the directions of the X axis, the Y axis and the Z axis at regular time, calculating the attitude angles of the carrier in the directions of the Z axis according to the theoretical magnetic field intensity, calculating magnetic field errors of the electronic compass in the directions of the X axis, the Y axis and the Z axis according to the relation between quaternion and the attitude angles, calculating the comprehensive magnetic field errors, judging whether the comprehensive magnetic field errors exceed a set threshold, and correcting the magnetic field errors if the comprehensive magnetic field errors exceed the set threshold. The invention can automatically correct the integrated magnetic field error when the integrated magnetic field error exceeds the set threshold value, and solves the problem of inaccurate pointing of the electronic compass after long-time use or interference.
Description
Technical Field
The invention relates to the technical field of electronic compass automatic calibration, in particular to an electronic compass automatic calibration method based on an MEMS sensor.
Background
MEMS are becoming more and more popular in gesture detection applications due to their small size, low power consumption, low cost, etc. However, the problems of output noise, zero drift and the like exist, and the error of the output gesture is larger and larger along with the extension of the application time. The existing electronic compass generally adopts an IMU+magnetometer scheme, and utilizes the short-term precision of a gyroscope and the long-term precision of an accelerometer and a magnetometer to carry out fusion calculation. Because of the nature of MEMS, each sensor needs to be calibrated before use. Because of the complexity of calibration, calibration can be performed only once at the moment of delivery, and errors occur in the sensor along with the change of the applicable environment, particularly the change of temperature and geomagnetic field, so that the heading error of the electronic compass is overlarge.
Disclosure of Invention
The invention aims at overcoming the defects of the prior art and provides an electronic compass automatic calibration method based on an MEMS sensor.
In order to achieve the above object, the present invention provides an electronic compass automatic calibration method based on an MEMS sensor, comprising:
Collecting acceleration of the carrier in the directions of an X axis, a Y axis and a Z axis, and calculating attitude angles of the carrier in the directions of the X axis and the Y axis according to the acceleration of the carrier in the directions of the X axis, the Y axis and the Z axis, wherein the attitude angles are respectively as follows:
θx=atan2(-ax,az)
θy=atan2(ay,ax*sin(θx)+az*cos(θx))
wherein, thetax and thetay are the attitude angles of the carrier in the directions of the X axis and the Y axis respectively, and ax, ay and az are the accelerations of the carrier in the directions of the X axis, the Y axis and the Z axis respectively;
The current measured magnetic field intensity of the magnetometer of the electronic compass is obtained, and the theoretical magnetic field intensities of the update carrier in the X-axis, Y-axis and Z-axis directions under the current gesture are calculated at regular time as follows:
bx=cos(θx)*mx+sin(θx)*mz
by=cos(θy)*mx–sin(θx)*sin(θy)*my+cos(θx)*sin(θy)*mz
bz=sin(θy)*mx+sin(θx)*cos(θy)*my+cos(θx)*cos(θy)*mz
bx, by and bz are calculated theoretical magnetic field intensities of the updated carrier in the directions of an X axis, a Y axis and a Z axis under the current gesture respectively, and mx, my and mz are components of the measured magnetic field intensities of the electronic compass in the directions of the X axis, the Y axis and the Z axis;
calculating the attitude angle theta Z of the carrier in the Z-axis direction according to the theoretical magnetic field strengths bx and by, wherein the attitude angle theta Z is as follows:
θz=atan2(by,bx)
Calculating magnetic field errors eMx, eMy, eMz of the electronic compass in the directions of the X axis, the Y axis and the Z axis according to the relation between quaternions q1, q2, q3 and q4 and attitude angles theta X, theta Y and theta Z of the carrier in the directions of the X axis, the Y axis and the Z axis;
Calculating a comprehensive magnetic field error according to magnetic field errors eMx, eMy, eMz of the electronic compass in the X-axis, Y-axis and Z-axis directions, judging whether the comprehensive magnetic field error exceeds a set threshold, and if so, correcting the magnetic field deviation, wherein the magnetic field error is specifically as follows:
Wherein, 、、The corrected magnetic fields in the X-axis, Y-axis and Z-axis directions are respectively obtained.
Further, the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the directions of the X axis, the Y axis and the Z axis is as follows:
。
further, the calculation method of the magnetic field error eMx, eMy, eMz of the electronic compass in the directions of the X axis, the Y axis and the Z axis is as follows:
。
Further, acceleration of the carrier in the X-axis, Y-axis and Z-axis directions is acquired through a triaxial accelerometer arranged on the carrier.
Further, the calculation mode of the integrated magnetic field error is as follows:
Wherein, For the calculated integrated magnetic field error.
Further, the set threshold is 10.
Further, the theoretical magnetic field intensity of the carrier in the X-axis, Y-axis and Z-axis directions under the current gesture is updated every ten minutes.
The invention has the advantages that the three-axis acceleration of the carrier is collected, the pitching angle and the rolling angle of the carrier are calculated according to the three-axis acceleration of the carrier, the theoretical magnetic field intensity is calculated according to the current measured magnetic field intensity of the magnetometer and the pitching angle and the rolling angle of the carrier, the yaw angle is calculated according to the theoretical magnetic field intensity, the magnetic field error is calculated according to the relation between the quaternion and the attitude angle, when the integrated magnetic field error exceeds the set threshold value, the correction can be automatically carried out, the magnetometer can be calibrated at regular time in the use of the electronic compass, and the problem that the electronic compass is inaccurate in pointing after being used for a long time or being interfered is solved.
Drawings
FIG. 1 is a flow chart of an electronic compass automatic calibration method based on MEMS sensor according to an embodiment of the present invention;
FIG. 2 is a schematic illustration of the magnetic field strength acquired by its magnetometer prior to electronic compass calibration;
fig. 3 is a schematic diagram of the magnetic field strength obtained by its magnetometer after electronic compass calibration.
Detailed Description
The invention will be further illustrated by the following drawings and specific examples, which are carried out on the basis of the technical solutions of the invention, it being understood that these examples are only intended to illustrate the invention and are not intended to limit the scope of the invention.
As shown in fig. 1, an embodiment of the present invention provides an electronic compass automatic calibration method based on a MEMS sensor, including:
collecting acceleration of the carrier in the directions of an X axis, a Y axis and a Z axis, and calculating attitude angles of the carrier in the directions of the X axis and the Y axis according to the acceleration of the carrier in the directions of the X axis, the Y axis and the Z axis, wherein the attitude angles are respectively as follows:
θx=atan2(-ax,az)
θy=atan2(ay,ax*sin(θx)+az*cos(θx))
Wherein, θx and θy are the attitude angles of the carrier in the X-axis and Y-axis directions, and ax, ay and az are the accelerations of the carrier in the X-axis, Y-axis and Z-axis directions, respectively. The acceleration of the carrier in the X-axis, Y-axis and Z-axis directions can be acquired through a triaxial accelerometer arranged on the carrier, the attitude angle thetax is the pitching angle of the carrier, and the attitude angle thetay is the rolling angle of the carrier.
The current measured magnetic field intensity of the magnetometer of the electronic compass is obtained, and the theoretical magnetic field intensities of the update carrier in the X-axis, Y-axis and Z-axis directions under the current gesture are calculated at regular time as follows:
bx=cos(θx)*mx+sin(θx)*mz
by=cos(θy)*mx–sin(θx)*sin(θy)*my+cos(θx)*sin(θy)*mz
bz=sin(θy)*mx+sin(θx)*cos(θy)*my+cos(θx)*cos(θy)*mz
Wherein bx, by and bz are calculated theoretical magnetic field intensities of the updated carrier in the directions of the X axis, the Y axis and the Z axis under the current gesture respectively, and mx, my and mz are components of the measured magnetic field intensities of the electronic compass in the directions of the X axis, the Y axis and the Z axis. The theoretical magnetic field intensity of the carrier in the X-axis, Y-axis and Z-axis directions under the current gesture is preferably calculated and updated every ten minutes.
Calculating the attitude angle theta Z of the carrier in the Z-axis direction according to the theoretical magnetic field strengths bx and by, wherein the attitude angle theta Z is as follows:
θz=atan2(by,bx)
the attitude angle θz is the yaw angle of the carrier.
And calculating magnetic field errors eMx, eMy, eMz of the electronic compass in the X-axis, Y-axis and Z-axis directions according to the relation between quaternions q1, q2, q3 and q4 and attitude angles theta X, theta Y and theta Z of the carrier in the X-axis, Y-axis and Z-axis directions. Specifically, the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions is as follows:
based on the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions, the manner of calculating the magnetic field error eMx, eMy, eMz is specifically as follows:
。
After calculating the magnetic field errors eMx, eMy, eMz of the electronic compass in the X-axis, Y-axis and Z-axis directions, calculating the integrated magnetic field error according to the magnetic field errors eMx, eMy, eMz of the electronic compass in the X-axis, Y-axis and Z-axis directions, wherein the integrated magnetic field error is specifically as follows:
Wherein, For the calculated integrated magnetic field error.
Then judging whether the integrated magnetic field error exceeds a set threshold value, and if so, correcting the magnetic field error, wherein the method comprises the following steps:
Wherein, 、、The corrected magnetic field intensity values in the X-axis, Y-axis and Z-axis directions are respectively obtained. The threshold value set is preferably 10, i.e. when the integrated errorAfter >10, the magnetic field bias is corrected, otherwise no correction is performed.
Referring to fig. 2 and 3, the magnetic field strengths in the X-axis, Y-axis, and Z-axis directions are shown in fig. 2 and 3, respectively, in uT. In fig. 2, the magnetic field intensity obtained by the magnetometer before the electronic compass is calibrated is shown, and it can be seen that the distribution is not a sphere, and the sphere center is not at the zero point, so that the calculated yaw angle is wrong if the data is directly used. Referring to fig. 3, fig. 3 illustrates the corrected magnetic field strength after the automatic calibration according to the present invention, the center of the magnetic field is at the zero point position, and the point is also substantially on the spherical surface, and the use of the magnetometer to calculate the yaw angle is within the accuracy range.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that other parts not specifically described are within the prior art or common general knowledge to a person of ordinary skill in the art. Modifications and alterations may be made without departing from the principles of this invention, and such modifications and alterations should also be considered as being within the scope of the invention.
Claims (5)
1. An electronic compass automatic calibration method based on a MEMS sensor is characterized by comprising the following steps:
Collecting acceleration of the carrier in the directions of an X axis, a Y axis and a Z axis, and calculating attitude angles of the carrier in the directions of the X axis and the Y axis according to the acceleration of the carrier in the directions of the X axis, the Y axis and the Z axis, wherein the attitude angles are respectively as follows:
θx=atan2(-ax,az)
θy=atan2(ay,ax*sin(θx)+az*cos(θx))
wherein, thetax and thetay are the attitude angles of the carrier in the directions of the X axis and the Y axis respectively, and ax, ay and az are the accelerations of the carrier in the directions of the X axis, the Y axis and the Z axis respectively;
The current measured magnetic field intensity of the magnetometer of the electronic compass is obtained, and the theoretical magnetic field intensities of the update carrier in the X-axis, Y-axis and Z-axis directions under the current gesture are calculated at regular time as follows:
bx=cos(θx)*mx+sin(θx)*mz
by=cos(θy)*mx–sin(θx)*sin(θy)*my+cos(θx)*sin(θy)*mz
bz=sin(θy)*mx+sin(θx)*cos(θy)*my+cos(θx)*cos(θy)*mz
bx, by and bz are calculated theoretical magnetic field intensities of the updated carrier in the directions of an X axis, a Y axis and a Z axis under the current gesture respectively, and mx, my and mz are components of the measured magnetic field intensities of the electronic compass in the directions of the X axis, the Y axis and the Z axis;
calculating the attitude angle theta Z of the carrier in the Z-axis direction according to the theoretical magnetic field strengths bx and by, wherein the attitude angle theta Z is as follows:
θz=atan2(by,bx)
Calculating magnetic field errors eMx, eMy, eMz of the electronic compass in the directions of the X axis, the Y axis and the Z axis according to the relation between quaternions q1, q2, q3 and q4 and attitude angles theta X, theta Y and theta Z of the carrier in the directions of the X axis, the Y axis and the Z axis;
Calculating a comprehensive magnetic field error according to magnetic field errors eMx, eMy, eMz of the electronic compass in the X-axis, Y-axis and Z-axis directions, judging whether the comprehensive magnetic field error exceeds a set threshold, and if so, correcting the magnetic field deviation, wherein the magnetic field error is specifically as follows:
;
Wherein, 、、The corrected magnetic fields in the X-axis, Y-axis and Z-axis directions are respectively;
the relation between the quaternions q1, q2, q3 and q4 and the attitude angles theta X, theta Y and theta Z of the carrier in the directions of the X axis, the Y axis and the Z axis is as follows:
;
The calculation mode of the magnetic field error eMx, eMy, eMz of the electronic compass in the X-axis, Y-axis and Z-axis directions is as follows:
。
2. The automatic calibration method of electronic compass based on MEMS sensor according to claim 1, wherein the acceleration of the carrier in the X-axis, Y-axis and Z-axis directions is collected by a triaxial accelerometer arranged on the carrier.
3. The automatic calibration method of electronic compass based on MEMS sensor as claimed in claim 1, wherein the calculation mode of the integrated magnetic field error is as follows:
;
Wherein, For the calculated integrated magnetic field error.
4. The method for automatically calibrating an electronic compass based on a MEMS sensor according to claim 1, wherein the set threshold is 10.
5. The automatic calibration method of electronic compass based on MEMS sensor according to claim 1, wherein the theoretical magnetic field strength of the carrier in the X-axis, Y-axis and Z-axis directions in the current posture is updated every ten minutes.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411517385.9A CN119022905B (en) | 2024-10-29 | 2024-10-29 | An automatic calibration method for electronic compass based on MEMS sensor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411517385.9A CN119022905B (en) | 2024-10-29 | 2024-10-29 | An automatic calibration method for electronic compass based on MEMS sensor |
Publications (2)
Publication Number | Publication Date |
---|---|
CN119022905A CN119022905A (en) | 2024-11-26 |
CN119022905B true CN119022905B (en) | 2025-06-13 |
Family
ID=93529512
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202411517385.9A Active CN119022905B (en) | 2024-10-29 | 2024-10-29 | An automatic calibration method for electronic compass based on MEMS sensor |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN119022905B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101241009A (en) * | 2007-12-28 | 2008-08-13 | 北京科技大学 | A kind of magnetic electronic compass error compensation method |
CN106556384A (en) * | 2015-09-28 | 2017-04-05 | 高新兴科技集团股份有限公司 | A kind of compensation for calibrating errors method of the electronic compass in tubular video camera |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1152237C (en) * | 2001-03-30 | 2004-06-02 | 清华大学 | Micro-Navigation System Based on MEMS Technology |
KR100655937B1 (en) * | 2005-11-25 | 2006-12-11 | 삼성전자주식회사 | Geomagnetic sensor and method for calculating azimuth |
DE102012011632A1 (en) * | 2011-07-28 | 2013-01-31 | Memsic Inc. | Motion- and attitude-sensing system for use in e.g. cellular telephone, for sensing attitude of rigid object in space, has three-axis magnetic compass to provide signals associated with change in attitude of electronic device |
JP2020027108A (en) * | 2018-08-13 | 2020-02-20 | シャープ株式会社 | Information processing device, information processing method, data structure and recording medium |
CN109238262B (en) * | 2018-11-05 | 2020-10-30 | 珠海全志科技股份有限公司 | Anti-interference method for course attitude calculation and compass calibration |
CN115046539A (en) * | 2021-03-09 | 2022-09-13 | 北京大学 | Dynamic calibration method for MEMS electronic compass |
CN115507849B (en) * | 2022-11-22 | 2023-03-10 | 北京理工大学前沿技术研究院 | Magnetic sensor correction method and system based on INS/GNSS combined navigation assistance |
-
2024
- 2024-10-29 CN CN202411517385.9A patent/CN119022905B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101241009A (en) * | 2007-12-28 | 2008-08-13 | 北京科技大学 | A kind of magnetic electronic compass error compensation method |
CN106556384A (en) * | 2015-09-28 | 2017-04-05 | 高新兴科技集团股份有限公司 | A kind of compensation for calibrating errors method of the electronic compass in tubular video camera |
Also Published As
Publication number | Publication date |
---|---|
CN119022905A (en) | 2024-11-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105203098B (en) | Agricultural machinery all-attitude angle update method based on nine axis MEMS sensors | |
CN106647791B (en) | Three-dimensional attitude measurement and control device, mechanical equipment and three-dimensional attitude measurement and control method | |
CN109238262B (en) | Anti-interference method for course attitude calculation and compass calibration | |
CN105588567B (en) | A kind of attitude heading reference system and method for autoelectrinic compass calibration assist type | |
CN109579836B (en) | Indoor pedestrian orientation calibration method based on MEMS inertial navigation | |
CN106017459B (en) | A kind of method of diamagnetic interference | |
CN111121824B (en) | A kind of calibration method of MEMS sensor | |
CN107063254B (en) | Gesture resolving method for gyros and geomagnetic combination | |
CN106403952A (en) | Method for measuring combined attitudes of Satcom on the move with low cost | |
CN103712598B (en) | A method for determining the attitude of a small unmanned aerial vehicle | |
CN104880189B (en) | A kind of antenna for satellite communication in motion low cost tracking anti-interference method | |
CN108731676A (en) | A kind of posture fusion enhancing measurement method and system based on inertial navigation technology | |
CN110530397A (en) | A kind of magnetic field automatic calibration method based on nine axis IMU | |
CN107402007A (en) | A kind of method for improving miniature AHRS modules precision and miniature AHRS modules | |
Zhao et al. | Magnetometer-based phase shifting ratio method for high spinning projectile’s attitude measurement | |
CN110779514A (en) | Hierarchical Kalman fusion method and device for auxiliary attitude determination of bionic polarization navigation | |
CN117029810A (en) | Mahony gesture measurement method based on iterative EKF | |
CN109631939A (en) | A kind of rapid alignment method based on magnetometer and accelerometer | |
CN119022905B (en) | An automatic calibration method for electronic compass based on MEMS sensor | |
CN105509703B (en) | The calculation method of roll angle for rotating missile | |
CN115326062A (en) | GNSS INS (Global navigation satellite System for inertial navigation System) integrated navigation method, device and medium based on bionic flapping-wing flying robot | |
CN112179380B (en) | Rate gyroscope error compensation method under dynamic condition | |
CN112033405B (en) | A method and device for real-time correction and navigation of indoor environmental magnetic anomalies | |
CN116380054B (en) | Aircraft attitude calculation method | |
CN115235465A (en) | A method for combined magnetic force/GNSS measurement of attitude angle |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |