Attitude sensor calibration method and device, electronic equipment and storage medium

By acquiring the attitude sensor data in a static state and calculating the static deviation, the problem of inaccurate data in the dynamic state of the attitude sensor is solved, and the accurate calibration of the gyroscope and magnetometer data is achieved, and the measurement accuracy of the attitude sensor is improved.

CN120252783APending Publication Date: 2025-07-04XIAN ZHENTAI INTELLIGENT TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510395030.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

The attitude sensor is susceptible to environmental factors in electronic devices, resulting in inaccurate acquisition of attitude data. Especially in the motion state, the measurement error of the gyroscope and magnetometer is relatively large.

Method used

The attitude sensor data is obtained in a stationary state and the static deviation is calculated. The attitude data in the motion state is calibrated by the static deviation, and the data of the gyroscope and magnetometer are calibrated by the static deviation to reduce errors.

Benefits of technology

It improves the data accuracy of the attitude sensor in the motion state, reduces the measurement error of the gyroscope and magnetometer, and enhances the reliability of the attitude data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120252783A_ABST
    Figure CN120252783A_ABST
Patent Text Reader

Abstract

The invention discloses an attitude sensor calibration method and device, electronic equipment and a storage medium. The method comprises the following steps: in response to triggering of an attitude sensor calibration event, when the electronic equipment is in a static state, acquiring first attitude data detected by an attitude sensor in the electronic equipment, and determining a first sampling number of the first attitude data in real time; wherein the attitude sensor comprises a gyroscope; when it is detected that the electronic equipment is switched from the static state to the motion state, if the first sampling number is larger than a first preset sampling number threshold value, the static deviation of the attitude sensor is calculated according to the first sampling number of first attitude data; and calibrating second attitude data detected by the attitude sensor when the electronic equipment is in the motion state based on the static deviation. According to the scheme, the attitude data detected by the gyroscope in the electronic equipment in the motion state can be accurately calibrated, and the error of the attitude data detected by the attitude sensor is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of attitude sensors, and particularly to an attitude sensor calibration method, device, electronic device, and storage medium. Background Art

[0002] An electronic device is usually configured with an attitude sensor to detect the attitude of the electronic device in real time. Among them, the attitude sensor may include a gyroscope for detecting angular velocity, an accelerometer for detecting acceleration, and a magnetometer for detecting magnetic field strength. However, the attitude sensor is easily affected by various factors, resulting in the inability to accurately obtain the attitude data of the electronic device. Therefore, it is crucial to calibrate the attitude sensor. Summary of the Invention

[0003] The present invention provides an attitude sensor calibration method, device, electronic device, and storage medium, which can accurately calibrate the attitude data detected by the gyroscope in an electronic device in a moving state.

[0004] According to one aspect of the present invention, there is provided an attitude sensor calibration method applied to an electronic device, the method including:

[0005] In response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, obtain first attitude data detected by the attitude sensor in the electronic device, and determine the first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope;

[0006] When it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is greater than a first preset sampling number threshold, calculate the static deviation of the attitude sensor according to the first sampling number of the first attitude data;

[0007] Calibrate second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation.

[0008] According to another aspect of the present invention, there is provided an apparatus applied to an electronic device, the apparatus including:

[0009] An attitude data acquisition module, configured to, in response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, obtain first attitude data detected by the attitude sensor in the electronic device, and determine the first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope;

[0010] A static deviation calculation module, configured to calculate the static deviation of the attitude sensor according to the first attitude data of the first sampling number when it is detected that the electronic device switches from a stationary state to a moving state and the first sampling number is greater than a first preset sampling number threshold.

[0011] An attitude data calibration module, configured to calibrate the second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation.

[0012] According to another aspect of the present invention, there is provided an electronic device, including:

[0013] At least one processor; and

[0014] A memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the attitude sensor calibration method according to any embodiment of the present invention.

[0016] According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement the attitude sensor calibration method according to any embodiment of the present invention when executed.

[0017] The attitude sensor calibration solution according to the embodiments of the present invention, in response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, obtains the first attitude data detected by the attitude sensor in the electronic device, and determines the first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope; when it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is greater than a first preset sampling number threshold, calculates the static deviation of the attitude sensor according to the first attitude data of the first sampling number; and calibrates the second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation. Through the technical solution provided by the embodiments of the present invention, the attitude data detected by the gyroscope in the electronic device in a moving state can be accurately calibrated, and the error of the attitude data detected by the attitude sensor can be reduced.

[0018] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0020] Figure 1 It is a flowchart of a method for calibrating an attitude sensor provided by an embodiment of the present invention;

[0021] Figure 2 It is a flowchart of another method for calibrating an attitude sensor provided by an embodiment of the present invention;

[0022] Figure 3a It is a schematic diagram of the soft iron effect provided by an embodiment of the present invention;

[0023] Figure 3b It is a schematic diagram of the hard iron effect provided by an embodiment of the present invention;

[0024] Figure 4 It is a schematic diagram for calibrating the magnetic field intensity data obtained by a magnetometer provided by an embodiment of the present invention;

[0025] Figure 5 It is a schematic diagram of the structure of an attitude sensor calibration device provided by an embodiment of the present invention;

[0026] Figure 6 It is a schematic diagram of the structure of an electronic device for implementing the attitude sensor calibration method of the embodiment of the present invention. Detailed implementation manners

[0027] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0028] It should be noted that the terms "first", "second", etc. in the description, claims and above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0029] When the electronic device is in a stationary state, the angular velocity detected by the gyroscope configured in the electronic device should be 0. However, due to the influence of environmental noise, the gyroscope data deviates, that is, the detected angular velocity of the gyroscope is not 0, and the error integral accumulates over time, which will affect the accuracy of the final gyroscope data. Therefore, it is crucial to calibrate the attitude data (i.e., gyroscope data) detected by the gyroscope.

[0030] Figure 1 The following is a flowchart of an attitude sensor calibration method provided in Embodiment 1 of the present invention. This embodiment is applicable to the situation of calibrating an attitude sensor. This method can be executed by an attitude sensor calibration device, which can be implemented in the form of hardware and / or software, and the attitude sensor calibration device can be configured in an electronic device. As Figure 1 shown, the method includes:

[0031] S110. In response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, obtain first attitude data detected by the attitude sensor in the electronic device, and determine the first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope.

[0032] In an embodiment of the present invention, when a posture sensor calibration instruction input by a user is received, it can be determined that a posture sensor calibration event is triggered. In response to the triggering of the posture sensor calibration event, when the electronic device is in a stationary state, posture data (which can also be referred to as gyroscope data) detected by a gyroscope in the electronic device is acquired at a preset sampling frequency (for example, the preset sampling frequency can be 1000 Hz), and the first sampling number N of the posture data is statistically counted in real time. For the convenience of description, the posture data detected by the posture sensor when the electronic device is in a stationary state is referred to as the first posture data. Among them, as the sampling time increases, the first sampling number N of the first posture data continuously increases. Among them, the first posture data includes posture data in three dimensions of the X, Y, and Z axes, that is, the angular velocities in three dimensions of the X, Y, and Z axes.

[0033] S120. When it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is greater than a first preset sampling number threshold, the static deviation of the posture sensor is calculated according to the first sampling number of the first posture data.

[0034] In an embodiment of the present invention, when it is detected that the electronic device switches from a stationary state to a moving state, it is determined whether the first sampling number N of the first posture data is greater than a first preset sampling number threshold (such as 5000). If so, the static deviation of the posture sensor is calculated according to N pieces of the first posture data. Exemplarily, the mean value of N pieces of the first posture data can be directly used as the static deviation of the posture sensor, or the opposite number of the mean value of N pieces of the first posture data can be used as the static deviation of the posture sensor. It should be noted that since the first posture data is the posture data in three dimensions of the X, Y, and Z axes (that is, the gyroscope data or the angular velocity), therefore, the static deviation of each dimension can be calculated according to N pieces of the first posture data of each dimension, or the static deviation of the total can be calculated after synthesizing N pieces of the first posture data of the three dimensions. Optionally, when it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is less than the first preset sampling number threshold, the static deviation may not be calculated first, but when the electronic device is in a stationary state again, the static deviation of the posture sensor is calculated according to the above method. The advantage of such a setting is that the static deviation of the posture sensor can be calculated based on a sufficient amount of the first posture data, improving the accuracy of the determined static deviation of the posture sensor, and thus effectively avoiding system errors and errors caused by frequent calibrations.

[0035] Optionally, detecting that the electronic device switches from a stationary state to a moving state includes: calculating in real time the attitude variance of the first sampling number of the first attitude data; if the attitude variance is greater than a preset variance threshold, determining that it is detected that the electronic device switches from a stationary state to a moving state. Exemplarily, calculate in real time the attitude variance of N first attitude data, and determine whether the attitude variance is less than the preset variance threshold. If so, it means that the first attitude data detected by the gyroscope is relatively stable, and it can be determined that the electronic device is still in a stationary state. If not, it means that the first attitude data detected by the gyroscope fluctuates greatly, and it can be determined that the electronic device switches from a stationary state to a moving state. It should be noted that since the first attitude data is the attitude data of the three dimensions of the X, Y, and Z axes (that is, the gyroscope data or the angular velocity), therefore, when the attitude variance of each dimension is greater than the preset variance threshold, it can be determined that it is detected that the electronic device switches from a stationary state to a moving state.

[0036] S130. Calibrate the second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation.

[0037] In the embodiment of the present invention, the static deviation can be stored in the Flash memory. When the electronic device is in a moving state, the static deviation is directly read from the Flash memory, and the second attitude data (that is, the gyroscope data) detected by the gyroscope when the electronic device is in a moving state is calibrated based on the static deviation. It can be understood that for the convenience of description, the attitude data detected by the gyroscope when the electronic device is in a moving state is called the second attitude data. Exemplarily, when the mean value of N first attitude data is used as the static deviation of the attitude sensor, the difference between the second attitude data and the static deviation can be used as the calibrated second attitude data; when the opposite number of the mean value of N first attitude data is used as the static deviation of the attitude sensor, the sum of the second attitude data and the static deviation can be used as the calibrated second attitude data.

[0038] It should be noted that the second attitude data can also be the attitude data of the three dimensions of the X, Y, and Z axes. When the static deviation is the static deviation of the three dimensions of the X, Y, and Z axes, the second attitude data of the corresponding dimension is calibrated according to the static deviation of each dimension; when the static deviation is the total static deviation synthesized from the three dimensions of the X, Y, and Z axes, first synthesize the second attitude data of the three dimensions of the X, Y, and Z axes, and then calibrate the synthesized second attitude data based on the synthesized total static deviation.

[0039] The attitude sensor calibration method according to an embodiment of the present invention, in response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, obtains first attitude data detected by the attitude sensor in the electronic device, and determines a first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope; when it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is greater than a first preset sampling number threshold, calculate a static deviation of the attitude sensor according to the first sampling number of the first attitude data; calibrate second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation. Through the technical solution provided by the embodiment of the present invention, the attitude data detected by the gyroscope in the electronic device in a moving state can be accurately calibrated, and the error of the attitude data detected by the attitude sensor can be reduced.

[0040] In some embodiments, when it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number N is greater than a first preset sampling number threshold, before calculating a static deviation of the attitude sensor according to the first sampling number N of the first attitude data, it further includes: when the first sampling number reaches a second preset sampling number threshold M, calculate a first mean value of the first M first attitude data, and calibrate the (M + 1)-th first attitude data based on the first mean value; wherein, the second preset sampling number threshold is less than the first preset sampling number threshold; determine whether the electronic device switches from a stationary state to a moving state based on the calibrated first M + 1 first attitude data, if not, calculate a second mean value of the second to (M + 1)-th calibrated first attitude data, and calibrate the (M + 2)-th first attitude data based on the second mean value, and so on, until it is detected that the electronic device switches from a stationary state to a moving state. The advantage of such a setting is that the attitude data detected by the gyroscope in the electronic device in a stationary state can be dynamically calibrated, the accuracy of the attitude data detected by the gyroscope in the electronic device in a stationary state can be improved, and thus it is helpful to further improve the accuracy of the attitude data detected by the gyroscope in the electronic device in a moving state.

[0041] In an embodiment of the present invention, during the process of obtaining first attitude data detected by an attitude sensor in an electronic device based on a preset sampling rate and determining the first sampling number of the first attitude data in real time, it is determined in real time whether the first sampling number reaches a second preset sampling number threshold M (e.g., M = 100), that is, it is determined whether the number of the first attitude data reaches the second preset sampling number threshold M. If so, the mean value of the first to the Mth first attitude data is calculated, and the (M + 1)th first attitude data is calibrated based on the mean value of the first to the Mth first attitude data. Among them, the difference between the (M + 1)th first attitude data and the first mean value (that is, the mean value of the first to the Mth first attitude data) is used as the calibrated (M + 1)th first attitude data. It is determined whether the electronic device switches from a stationary state to a moving state according to the calibrated first (M + 1) attitude data, that is, it is determined whether the electronic device switches from a stationary state to a moving state according to the first M attitude data and the (M + 1)th calibrated first attitude data. Among them, it can be determined whether the variance of the calibrated first (M + 1) attitude data is greater than a preset variance threshold. If so, it can be determined whether the electronic device switches from a stationary state to a moving state. When it is determined based on the calibrated first (M + 1) attitude data that the electronic device does not switch from a stationary state to a moving state (that is, the electronic device remains in a stationary state), the second mean value of the second to the (M + 1)th calibrated first attitude data is calculated, that is, the mean value of the second to the Mth first attitude data and the (M + 1)th calibrated first attitude data is calculated, and the (M + 2)th first attitude data is calibrated based on the second mean value. Among them, the difference between the (M + 2)th first attitude data and the second mean value is used as the calibrated (M + 2)th first attitude data. Similarly, it is determined whether the electronic device switches from a stationary state to a moving state based on the calibrated first (M + 2) attitude data. If not, the third mean value of the third to the (M + 2)th calibrated first attitude data (that is, the mean value of the third to the Mth first attitude data and the (M + 1)th to the (M + 2)th calibrated first attitude data) is calculated, and the (M + 3)th first attitude data is calibrated based on the third mean value, and so on, until it is detected that the electronic device switches from a stationary state to a moving state.

[0042] Figure 2 FIG. 4 is a flowchart of another attitude sensor calibration method provided in Embodiment 1 of the present invention. As Figure 2 shown, the attitude sensor calibration method includes:

[0043] S210. In response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, obtain first attitude data detected by the attitude sensor in the electronic device, and determine the first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope.

[0044] S220. When the first number of samples reaches the second preset sampling number threshold M, calculate the first mean value of the first M attitude data from the 1st to the Mth, and calibrate the (M + 1)th first attitude data based on the first mean value.

[0045] S230. Based on the calibrated first M + 1 attitude data, determine whether the electronic device switches from a stationary state to a moving state. If not, calculate the second mean value of the calibrated first attitude data from the 2nd to the (M + 1)th, and calibrate the (M + 2)th first attitude data based on the second mean value, and so on, until it is detected that the electronic device switches from a stationary state to a moving state.

[0046] S240. When it is detected that the electronic device switches from a stationary state to a moving state, if the first number of samples is greater than the first preset sampling number threshold, calculate the static deviation of the attitude sensor according to the first number of samples of the first attitude data.

[0047] S250. Calibrate the second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation.

[0048] The attitude sensor calibration method provided by the embodiments of the present invention, on the one hand, can dynamically calibrate the attitude data detected by the gyroscope in the electronic device in a stationary state, improve the accuracy of the attitude data detected by the gyroscope in the electronic device in a stationary state, and thus help to further improve the accuracy of the attitude data detected by the gyroscope in the electronic device in a moving state. On the other hand, it can also accurately calibrate the attitude data detected by the gyroscope in the electronic device in a moving state, and reduce the error of the attitude data detected by the attitude sensor.

[0049] The magnetometer mainly calculates the direction of the magnetic north pole by sensing the existence of the earth's magnetic field. However, since the earth's magnetic field is generally only weakly 0.5 gauss, while an ordinary mobile phone speaker still has a magnetic field of about 4 gauss when it is 2 centimeters away, and a mobile phone motor has a magnetic field of about 6 gauss when it is 2 centimeters away, this characteristic makes the measurement of the earth's magnetic field on the surface of the electronic device easily affected by the electronic device itself, resulting in soft iron effect and hard iron effect. Among them, the soft iron effect refers to the interference of the magnetometer by the surrounding changing magnetic fields; these changing magnetic fields can come from wires through which current flows, electromagnetic waves, etc. Since the magnetometer has a certain response time, when the surrounding magnetic field changes rapidly, it will cause the delay and distortion of the output of the magnetometer, thus introducing errors. These interferences usually come from objects near the sensor, and these objects will distort the surrounding magnetic field, and will stretch the ideal sphere drawn according to the magnetic field intensity data collected by the XYZ three axes of the magnetometer. Figure 3aA schematic diagram of the soft iron effect provided by an embodiment of the present invention. The hard iron effect refers to the interference of the magnetometer by strong magnetic fields from surrounding permanent magnets and the like. These strong magnetic fields will have a significant impact on the measurement results of the magnetometer, causing errors. Its interference sources include nearby magnets, motors, solenoid valves, etc., which will generate static magnetic fields, and the magnetometer is very sensitive to static magnetic fields. These interferences change the origin of the ideal sphere. Figure 3b A schematic diagram of the hard iron effect provided by an embodiment of the present invention.

[0050] In some embodiments, it further includes: obtaining the magnetic field intensity data detected by the attitude sensor based on a preset sampling rate; wherein, the attitude sensor includes a magnetometer; respectively and dynamically establishing a maximum magnetic field intensity array and a minimum magnetic field intensity array with a preset length according to the magnetic field intensity data; wherein, the number of elements included in the maximum magnetic field intensity array is the same as that in the minimum magnetic field intensity array; when the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than a preset average threshold, calibrating the current magnetic field intensity data obtained by the attitude sensor based on the first average value and the second average value. The advantage of such a setting is that the magnetic field intensity data obtained by the magnetometer can be calibrated quickly and accurately.

[0051] In the embodiment of the present invention, the magnetic field intensity data detected by the magnetometer is obtained based on a preset sampling rate, and a maximum magnetic field intensity array and a minimum magnetic field intensity array with a preset length are respectively and dynamically established according to the magnetic field intensity data. Wherein, the preset length is the number of elements (i.e., magnetic field intensity data) included in the maximum magnetic field intensity array and the minimum magnetic field intensity array respectively. Since the magnetic field intensity data includes the magnetic field intensity data of three dimensions of the X, Y, and Z axes, therefore, a maximum magnetic field intensity array and a minimum magnetic field intensity array with a preset size are respectively and dynamically established according to the magnetic field intensity data of each dimension, that is, finally 3 maximum magnetic field intensity arrays and 3 minimum magnetic field intensity arrays can be dynamically established.

[0052] Optionally, respectively and dynamically establishing a maximum magnetic field intensity array and a minimum magnetic field intensity array according to the magnetic field intensity data includes: determining the second sampling number of the magnetic field intensity data in real time, and when the second sampling number is greater than or equal to the preset length, selecting the preset length of the largest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form the maximum magnetic field intensity array, and selecting the preset length of the smallest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form the minimum magnetic field intensity array. The advantage of such a setting is that the maximum magnetic field intensity array and the minimum magnetic field intensity array can be determined quickly.

[0053] Exemplarily, during the process of obtaining the magnetic field intensity data detected by the attitude sensor based on a preset sampling rate, the second sampling number of the magnetic field intensity data is determined in real time, that is, the number of the magnetic field intensity data is determined. It is judged whether the second sampling number is greater than or equal to a preset length. If so, a preset length of the largest magnetic field intensity data corresponding to each dimension is selected from the second sampling number of magnetic field intensity data in each dimension, and the preset length of the largest magnetic field intensity data corresponding to each dimension is used as array elements to form a maximum magnetic field intensity array. And a preset length of the smallest magnetic field intensity data corresponding to each dimension is selected from the second sampling number of magnetic field intensity data in each dimension, and the preset length of the smallest magnetic field intensity data corresponding to each dimension is used as array elements to form a minimum magnetic field intensity array.

[0054] Optionally, when the second sampling number reaches the preset length (for example, the preset length is 50), that is, when the number of the magnetic field intensity data is equal to 50, the 50 magnetic field intensity data in each dimension are directly used as the maximum magnetic field intensity array and the minimum magnetic field intensity array corresponding to each dimension. At this time, the maximum magnetic field intensity array and the minimum magnetic field intensity array are the same. After the 51st magnetic field intensity data is collected, it is judged whether the 51st magnetic field intensity data in each dimension is greater than the minimum value in the maximum magnetic field intensity array corresponding to the dimension. If so, the minimum value in the maximum magnetic field intensity array corresponding to the dimension is replaced based on the 51st magnetic field intensity data in the dimension to form a new maximum magnetic field intensity array corresponding to the dimension; if not, the maximum magnetic field intensity array corresponding to the dimension remains unchanged. Similarly, it is judged whether the 51st magnetic field intensity data in each dimension is less than the maximum value in the minimum magnetic field intensity array corresponding to the dimension. If so, the maximum value in the minimum magnetic field intensity array corresponding to the dimension is replaced based on the 51st magnetic field intensity data in the dimension to form a new minimum magnetic field intensity array corresponding to the dimension; if not, the minimum magnetic field intensity array corresponding to the dimension remains unchanged. After the 52nd magnetic field intensity data is collected, the maximum magnetic field intensity array and the minimum magnetic field intensity array are updated respectively in the above manner.

[0055] In the embodiment of the present invention, the difference between the first average value of the maximum magnetic field intensity array in each dimension and the second average value of the minimum magnetic field intensity array is calculated. If the difference between the first average value and the second average value corresponding to each dimension is greater than a preset average value threshold (for example, the preset average value threshold is 45 * 2 = 90 uT), the current magnetic field intensity data in the corresponding dimension obtained by the magnetometer is calibrated respectively based on the first average value and the second average value corresponding to each dimension.

[0056] Optionally, when the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than a preset average threshold, calibrate the current magnetic field intensity data obtained by the attitude sensor based on the first average value and the second average value, including: when the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than a preset average threshold, perform hard iron calibration on the current magnetic field intensity data obtained by the attitude sensor based on the first average value and the second average value; calculate a soft iron scale factor based on the first average value and the second average value, and perform soft iron calibration on the current magnetic field intensity data after hard iron calibration based on the soft iron scale factor.

[0057] In an embodiment of the present invention, when the difference between the first average value of the maximum magnetic field intensity array of each dimension and the second average value of the minimum magnetic field intensity array is greater than a preset average threshold, perform hard iron calibration on the current magnetic field intensity data of the corresponding dimension obtained by the magnetometer based on the first average value and the second average value corresponding to each dimension. Among them, the current magnetic field intensity data obtained by the magnetometer is calibrated for hard iron in the following manner: the current magnetic field intensity data after hard iron calibration = the current magnetic field intensity data - (the first average value + the second average value) / 2. Then calculate the soft iron scale factor of the corresponding dimension based on the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array of each dimension, and perform soft iron calibration on the current magnetic field intensity data of the corresponding dimension after hard iron calibration based on the soft iron scale factor. Among them, the soft iron scale factor = (the first average value - the second average value) / (2 * preset parameter); the current magnetic field intensity data after soft iron calibration = the current magnetic field intensity data after hard iron calibration / the soft iron scale factor. Among them, the preset parameter is the magnetic field intensity unit uT (microtesla) at the position where the magnetometer is located.

[0058] It can be understood that soft iron calibration of the magnetic field intensity data turns the sphere drawn based on the magnetic field intensity data into an ellipsoid, which is a process of correcting it into a standard sphere; hard iron calibration of the magnetic field intensity data is a process of shifting the center of the sphere drawn based on the magnetic field intensity data and correcting the center of the sphere back to the origin.

[0059] It should be noted that when the difference between the first average value of the maximum magnetic field intensity array in each dimension and the second average value of the minimum magnetic field intensity array is greater than the preset average threshold, the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array in each dimension can be written into the Flash memory. Writing to the Flash includes unlocking the Flash, setting the erase page method, erasing the page, writing to the Flash, locking the flash, reading the written address, and verifying that the Flash read and write are consistent to ensure successful and correct writing. Among them, once the first average value and the second average value are written into the Flash, even if the power is off and restarted later, when directly powering on at different places, the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array in each dimension can be read from the Flash, so as to calibrate the current magnetic field intensity data obtained by the magnetometer. Among them, when recalibration is required or the surrounding magnetic field changes too much, it is necessary to resend the calibration instruction to rewrite the first average value of the new maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array in each dimension into the Flash again.

[0060] Exemplarily, Figure 4 is a schematic diagram for calibrating the magnetic field intensity data obtained by the magnetometer provided by the embodiment of the present invention. With reference to the description of the above embodiments, Figure 4 can be understood and will not be elaborated here.

[0061] S410. Obtain the magnetic field intensity data detected by the attitude sensor based on a preset sampling rate; wherein, the attitude sensor is a magnetometer.

[0062] S420. Determine the second sampling number of the magnetic field intensity data in real time, and when the second sampling number is greater than or equal to the preset length, select the preset length of the largest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form a maximum magnetic field intensity array, and select the preset length of the smallest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form a minimum magnetic field intensity array.

[0063] S430. When the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than the preset average threshold, perform hard iron calibration on the current magnetic field intensity data obtained by the attitude sensor based on the first average value and the second average value.

[0064] S440. Calculate the soft iron scale factor based on the first average value and the second average value, and perform soft iron calibration on the current magnetic field intensity data after hard iron calibration based on the soft iron scale factor.

[0065] Figure 5Schematic structural diagram of an attitude sensor calibration device provided by an embodiment of the present invention.

[0066] As Figure 5 shown, the device includes:

[0067] An attitude data acquisition module 510, configured to, in response to an attitude sensor calibration event being triggered, when the electronic device is in a stationary state, acquire first attitude data detected by the attitude sensor in the electronic device, and determine a first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope;

[0068] A static deviation calculation module 520, configured to, when it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is greater than a first preset sampling number threshold, calculate a static deviation of the attitude sensor according to the first sampling number of the first attitude data;

[0069] An attitude data calibration module 530, configured to calibrate second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation.

[0070] Optionally, it further includes:

[0071] A first dynamic calibration module, configured to, when it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number N is greater than a first preset sampling number threshold, before calculating a static deviation of the attitude sensor according to the first sampling number N of the first attitude data, when the first sampling number reaches a second preset sampling number threshold M, calculate a first mean of the first M first attitude data, and calibrate the (M + 1)-th first attitude data based on the first mean; wherein, the second preset sampling number threshold is less than the first preset sampling number threshold;

[0072] A second dynamic calibration module, configured to determine whether the electronic device switches from a stationary state to a moving state based on the first M + 1 calibrated first attitude data. If not, calculate a second mean of the second to (M + 1)-th calibrated first attitude data, and calibrate the (M + 2)-th first attitude data based on the second mean, and so on, until it is detected that the electronic device switches from a stationary state to a moving state.

[0073] Optionally, the static deviation calculation module is configured to:

[0074] Calculate an attitude variance of the first sampling number of the first attitude data in real time;

[0075] If the attitude variance is greater than a preset variance threshold, it is determined that the electronic device switches from a stationary state to a moving state.

[0076] Optionally, the device further includes:

[0077] A magnetic field intensity data acquisition module, configured to acquire magnetic field intensity data detected by the attitude sensor based on a preset sampling rate; wherein, the attitude sensor includes a magnetometer;

[0078] A magnetic field intensity array establishment module, configured to dynamically establish a maximum magnetic field intensity array and a minimum magnetic field intensity array with a preset length respectively according to the magnetic field intensity data; wherein, the number of elements included in the maximum magnetic field intensity array is the same as that included in the minimum magnetic field intensity array;

[0079] A magnetic field intensity data calibration module, configured to calibrate the current magnetic field intensity data acquired by the attitude sensor based on the first average value and the second average value when the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than a preset average threshold.

[0080] Optionally, the magnetic field intensity array establishment module is configured to:

[0081] Determine the second sampling number of the magnetic field intensity data in real time, and when the second sampling number is greater than or equal to the preset length, select the preset length of the largest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form a maximum magnetic field intensity array, and select the preset length of the smallest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form a minimum magnetic field intensity array.

[0082] Optionally, the magnetic field intensity data calibration module includes:

[0083] A hard iron calibration unit, configured to perform hard iron calibration on the current magnetic field intensity data acquired by the attitude sensor based on the first average value and the second average value when the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than a preset average threshold;

[0084] A soft iron calibration unit, configured to calculate a soft iron scale factor based on the first average value and the second average value, and perform soft iron calibration on the current magnetic field intensity data after hard iron calibration based on the soft iron scale factor.

[0085] Optionally, the hard iron calibration unit is configured to:

[0086] Perform hard iron calibration on the current magnetic field intensity data acquired by the attitude sensor in the following manner:

[0087] The current magnetic field intensity data after hard iron calibration = the current magnetic field intensity data - (the first average value + the second average value) / 2;

[0088] The soft iron calibration unit is used for:

[0089] Performing soft iron calibration on the current magnetic field intensity data after hard iron calibration in the following manner:

[0090] Soft iron scale factor = (first average value - second average value) / (2 * preset parameter);

[0091] The current magnetic field intensity data after soft iron calibration = the current magnetic field intensity data after hard iron calibration / soft iron scale factor.

[0092] The attitude sensor calibration device provided by the embodiments of the present invention can execute the attitude sensor calibration method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method.

[0093] Figure 6 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0094] As Figure 6 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by at least one processor, and the processor 11 can execute various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0095] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0096] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the attitude sensor calibration method.

[0097] In some embodiments, the attitude sensor calibration method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the attitude sensor calibration method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the attitude sensor calibration method by any other suitable means (e.g., by means of firmware).

[0098] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGA), application-specific integrated circuits (ASIC), application-specific standard products (ASSP), systems-on-chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: implemented in one or more computer programs, the one or more computer programs can be executed and / or interpreted on a programmable system including at least one programmable processor, the programmable processor can be a special or general-purpose programmable processor, can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.

[0099] A computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing device, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0100] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0101] In order to provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0102] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected with each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.

[0103] A computing system can include a client and a server. The client and the server are generally far from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.

[0104] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.

[0105] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for calibrating an attitude sensor, characterized in that, Applied to an electronic device, the method includes: In response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, acquiring first attitude data detected by the attitude sensor in the electronic device, and determining a first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope; When it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is greater than a first preset sampling number threshold, calculating a static deviation of the attitude sensor according to the first sampling number of the first attitude data; Calibrating second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation.

2. The method according to claim 1, wherein When it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number N is greater than a first preset sampling number threshold, before calculating the static deviation of the attitude sensor according to the first sampling number N of the first attitude data, it further includes: When the first sampling number reaches a second preset sampling number threshold M, calculating a first mean value of the first M first attitude data, and calibrating the (M + 1)-th first attitude data based on the first mean value; wherein, the second preset sampling number threshold is less than the first preset sampling number threshold; Judging whether the electronic device switches from a stationary state to a moving state based on the calibrated first M + 1 first attitude data. If not, calculating a second mean value of the second to (M + 1)-th calibrated first attitude data, and calibrating the (M + 2)-th first attitude data based on the second mean value, and so on, until it is detected that the electronic device switches from a stationary state to a moving state.

3. The method according to claim 1, characterized in that, Detecting that the electronic device switches from a stationary state to a moving state includes: Calculating an attitude variance of the first sampling number of the first attitude data in real time; If the attitude variance is greater than a preset variance threshold, determining that it is detected that the electronic device switches from a stationary state to a moving state.

4. The method according to claim 1, wherein It further includes: Acquiring magnetic field intensity data detected by the attitude sensor based on a preset sampling rate; wherein, the attitude sensor includes a magnetometer; Dynamically establishing a maximum magnetic field intensity array and a minimum magnetic field intensity array with a preset length according to the magnetic field intensity data respectively; wherein, the number of elements included in the maximum magnetic field intensity array is the same as that in the minimum magnetic field intensity array; When the difference between a first average value of the maximum magnetic field intensity array and a second average value of the minimum magnetic field intensity array is greater than a preset average value threshold, calibrating the current magnetic field intensity data acquired by the attitude sensor based on the first average value and the second average value.

5. The method according to claim 4, characterized in that, Dynamically establishing a maximum magnetic field intensity array and a minimum magnetic field intensity array with a preset length according to the magnetic field intensity data respectively includes: Determine the second sampling number of the magnetic field intensity data in real time, and when the second sampling number is greater than or equal to the preset length, select the preset length of the largest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form a maximum magnetic field intensity array, and select the preset length of the smallest magnetic field intensity data from the second sampling number of the magnetic field intensity data to form a minimum magnetic field intensity array.

6. The method according to claim 4, characterized in that, When the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than the preset average threshold, calibrate the current magnetic field intensity data obtained by the attitude sensor based on the first average value and the second average value, including: When the difference between the first average value of the maximum magnetic field intensity array and the second average value of the minimum magnetic field intensity array is greater than the preset average threshold, perform hard iron calibration on the current magnetic field intensity data obtained by the attitude sensor based on the first average value and the second average value; Calculate a soft iron scale factor based on the first average value and the second average value, and perform soft iron calibration on the current magnetic field intensity data after hard iron calibration based on the soft iron scale factor.

7. The method according to claim 6, wherein Performing hard iron calibration on the current magnetic field intensity data obtained by the attitude sensor based on the first average value and the second average value includes: Perform hard iron calibration on the current magnetic field intensity data obtained by the attitude sensor in the following manner: Current magnetic field intensity data after hard iron calibration = current magnetic field intensity data - (first average value + second average value) / 2; Calculating a soft iron scale factor based on the first average value and the second average value, and performing soft iron calibration on the current magnetic field intensity data after hard iron calibration based on the soft iron scale factor includes: Perform soft iron calibration on the current magnetic field intensity data after hard iron calibration in the following manner: Soft iron scale factor = (first average value - second average value) / (2 * preset parameter); Current magnetic field intensity data after soft iron calibration = current magnetic field intensity data after hard iron calibration / soft iron scale factor.

8. An attitude sensor calibration device, characterized in that Applied to an electronic device, the device includes: An attitude data acquisition module, configured to, in response to the triggering of an attitude sensor calibration event, when the electronic device is in a stationary state, acquire first attitude data detected by an attitude sensor in the electronic device, and determine the first sampling number of the first attitude data in real time; wherein, the attitude sensor includes a gyroscope; A static deviation calculation module, configured to, when it is detected that the electronic device switches from a stationary state to a moving state, if the first sampling number is greater than a first preset sampling number threshold, calculate the static deviation of the attitude sensor according to the first sampling number of the first attitude data; An attitude data calibration module, configured to calibrate second attitude data detected by the attitude sensor when the electronic device is in a moving state based on the static deviation.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the attitude sensor calibration method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for implementing the attitude sensor calibration method according to any one of claims 1-7 when the computer instructions are executed by a processor.

Citation Information

Cited By

  • Magnetic azimuth angle correction method and device of measurement-while-drilling system and computing equipment

    CN121382171A