Attitude angle estimation method of Android equipment
By designing an attitude angle estimation method based on complementary filtering on Android devices, combining sensor error calibration and quaternary conversion, the problem of low pose angle estimation accuracy in the existing technology is solved, and more accurate and stable real-time update of attitude angles is achieved. .
Patent Information
- Application Number
- CN202411106557.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-13
AI Technical Summary
The attitude angle estimation method of the existing Android system is susceptible to the surrounding environment, has poor accuracy, and is unable to effectively combine accelerometer, magnetometer and gyroscope data for accurate attitude angle estimation.
A pose angle estimation method based on complementary filtering is designed. By determining the rotation order of Euler angles, establishing the conversion relationship between quaternions and Euler angles, combining sensor error calibration and complementary filtering technology, real-time estimation of attitude angles of Android devices is realized. .
It improves the accuracy and stability of pose angle estimation, avoids the singularity problem in Euler angle representation, ensures real-time update capabilities in dynamic environments, and meets the real-time performance requirements of mobile devices.
Smart Images

Figure CN119063762A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of indoor positioning, and in particular to a method for estimating an attitude angle of an Android device. Background Art
[0002] With the development of science and technology, location-based services (LBS) have brought many conveniences to people's lives. Domestic and foreign scholars have developed many positioning methods based on Wi-Fi, Bluetooth, Pedestrian Dead Reckoning (PDR), ultra-wideband (UWB), visible light communication, computer vision, geomagnetism, infrared and other technologies. Among them, since PDR does not require the deployment of additional equipment, hybrid positioning methods based on PDR have been widely used. PDR positioning mainly consists of three parts: gait detection, step length estimation, and heading estimation. Equipment posture estimation is the basis of route estimation, and the accuracy of heading estimation plays a vital role in PDR positioning.
[0003] According to the latest report from market research firm Counterpoint, Android is currently the largest system with a global market share of 39%. The underlying Android system provides a simple attitude angle estimation method, which combines only accelerometer data and magnetometer data to estimate the attitude of Android devices. It is easily affected by the surrounding environment and has poor accuracy. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] In view of the deficiencies in the prior art, the present invention provides a method for estimating the attitude angle of an Android device, which has the advantages of determining the Euler angle rotation order and the conversion relationship between Euler angles and quaternions according to the characteristics of Android devices, establishing an attitude angle estimation model based on complementary filtering, designing an attitude angle estimation process, and realizing real-time estimation of the attitude angle of an Android device, thereby solving the problems of the above-mentioned technologies.
[0006] (II) Technical solution
[0007] To achieve the above object, the present invention provides the following technical solution: a method for estimating an attitude angle of an Android device, comprising the following steps:
[0008] Step 1: Determine the Euler angle rotation order of the Android device and establish the conversion relationship between the carrier coordinate system and the geographic coordinate system;
[0009] Step 2: Establish the conversion relationship between quaternion and Euler angle based on rotation matrix;
[0010] Step 3: Design a real-time Android device attitude angle estimation process based on sensor error calibration and complementary filter estimation;
[0011] Step 4: According to the designed attitude angle estimation process, use the Android smartphone to collect data for real-time update of the attitude angle.
[0012] Preferably, the detailed steps in step 1 are:
[0013] S1.1. When an Android device undergoes a posture change, from the perspective of Euler angle transformation, the Android device first undergoes γ (roll angle) transformation, θ (pitch angle) transformation, and ψ (heading angle) transformation;
[0014] The rotation matrix from the carrier coordinate system to the geographic coordinate system is The Euler angle expression is:
[0015]
[0016] S1.2, device coordinates [vx, vy, vz] after rotation matrix Transform to geographic coordinates [vx′, vy′, vz′];
[0017]
[0018] S1.3. The transformation from geographic coordinates [vx′, vy′, vz′] to device coordinates is the rotation matrix The inverse transformation of
[0019]
[0020] S1.4. Due to the rotation matrix is an orthogonal matrix, its inverse matrix With the transposed matrix equal;
[0021] Rotation matrix from geographic coordinate system to carrier coordinate system The expression is:
[0022]
[0023] Preferably, step 2 establishes the rotation relationship between the quaternion based on the rotation matrix and the Euler angle as follows:
[0024] S2.1. On Android devices, use the rotation matrix represented by the quaternion [q0, q1, q2, q3] The expression is as follows:
[0025]
[0026] S2.2 Rotation Matrix Represented by Euler angles and quaternions respectively, the corresponding items are equal.
[0027] The preferred expression for the conversion relationship between the quaternion and the Euler angle is:
[0028] The conversion relationship expression from quaternion to Euler angle is:
[0029]
[0030] The conversion relationship expression from Euler angle to quaternion is:
[0031]
[0032] The above conversion relationship is used as the basis for real-time estimation of the attitude angle of Android devices.
[0033] Preferably, the step three is based on real-time Android device attitude angle estimation based on sensor error calibration and complementary filtering estimation.
[0034] Preferably, the attitude angle estimation step in step three is:
[0035] S3.1, the built-in sensors of the Android device, accelerometer, magnetometer, and gyroscope, are used to estimate the attitude angle of the device, and the aforementioned sensors are calibrated before estimation;
[0036] S3.2. A heading angle estimation model based on complementary filtering uses a complementary filtering model to estimate the heading angle and corrects the gyroscope using acceleration data and magnetic field strength data.
[0037] Preferably, the calibration method of the accelerometer, magnetometer and gyroscope sensor is:
[0038] S3.1.1. First, place the Android device on a horizontal desktop, design N static postures, and measure the accelerometer axis readings {Acc i ∈R n×3 , i∈N}, where Acc i Represents the three-axis and velocity data collected in the i-th posture, constructs an ellipsoid model, and uses the least squares method to solve the ellipsoid center C based on the data collected in N postures a And the length of each axis S a ;
[0039] Finally, when performing device attitude estimation, the collected acceleration data needs to be processed by the following formula to obtain unbiased data for attitude estimation:
[0040]
[0041] S3.1.2, firstly, the Android device is placed in a certain location in various postures, such as holding an Android smartphone in a hand and performing a digital circle, and then the magnetometer axis reading data {Mag i ∈R n×3 , i∈N}, where Mag i Represents the triaxial and magnetometer data collected in the i-th posture, constructs an ellipsoid model, and uses the least square method to solve the ellipsoid center C based on the data collected in N postures m And the length of each axis S m ;
[0042] Finally, when performing device attitude estimation, the collected acceleration data needs to be processed by the following formula to obtain unbiased data for attitude estimation:
[0043]
[0044] S3.1.3, first, keep the Android device still at a certain location, keep the device from rotating, and record the gyroscope three-axis data {Gyr i ∈R n×3 , i∈N}, where Gyr i represents the three-axis and gyroscope data collected in the i-th posture. The N-times data is averaged according to each axis to calculate the zero bias error C gyr ;
[0045] Finally, when performing device attitude estimation, the collected gyroscope data needs to be processed by the following formula to obtain unbiased data for attitude estimation:
[0046] {Gyr i =Gyr i -C gyr ∈R n×3 , i∈N}.
[0047] Preferably, the amendment in S3.2 includes:
[0048] Assume that the gyroscope data is ω g =[ω gx ω gy ω gz ] T , the normalized data ω=[ω x ω y ω z ] T , the deviation in the heading estimation process is recorded as e = [e x e y e z ] T, is obtained from the acceleration and magnetic field strength data, so the value after gyroscope data error compensation is:
[0049] ω=ω g +K P e+K I ∫e
[0050] Where K P =0.1, K i =0.0001;
[0051] The heading angle estimation model based on complementary filtering is as follows:
[0052] Update the gyroscope data using error compensation:
[0053] ω=ω g +K P e+K I ∫e
[0054] Update the quaternion using the gyroscope data:
[0055]
[0056] Preferably, the expression for solving the attitude angle by using the conversion relationship between quaternion and attitude angle in S3.2 is:
[0057]
[0058] Preferably, the step 4 uses an Android smartphone to collect data and perform real-time update of the attitude angle according to a designed attitude angle estimation process, and the update process is:
[0059] According to the designed process, write Android code, including sensor data collection, model calculation, real-time update and output of device posture.
[0060] Compared with the prior art, the present invention provides a method for estimating the attitude angle of an Android device, which has the following beneficial effects:
[0061] 1. In step 1, the present invention describes in detail the rotation matrix from the carrier coordinate system to the geographic coordinate system, covering the order and transformation relationship of the roll angle (γ), pitch angle (θ), and heading angle (ψ). Through the inverse transformation of the rotation matrix, the transformation relationship from the Android device geographic coordinate system to the carrier coordinate system is established, ensuring the correct mapping of the attitude angle between different coordinate systems. Step 2 introduces the transformation relationship between the quaternion and the Euler angle based on the rotation matrix. The quaternion is used to effectively represent the attitude angle, and its corresponding relationship with the rotation matrix is clearly explained through a specific mathematical formula. A conversion formula from the quaternion to the Euler angle and from the Euler angle to the quaternion is provided, ensuring the mathematical accuracy and stability in the attitude angle estimation process, obtaining the correct conversion result between the Euler angle and the quaternion, and realizing the real-time update of the attitude angle.
[0062] 2. The present invention establishes the rotation relationship between the carrier coordinate system and the geographic coordinate system through detailed mathematical derivation and matrix operations, ensures the correct mapping of the attitude angle conversion between different coordinate systems, thereby improving the accuracy of attitude estimation, and ensures the stability and mathematical accuracy of the attitude angle in the calculation and sensor fusion process through the clear conversion relationship between the rotation matrix and the quaternion. Quaternions can effectively avoid the singularity problem that may occur in the Euler angle representation, and in step three, by obtaining accurate sensor data, the accuracy of attitude angle estimation is improved. In particular, the application of complementary filtering technology effectively integrates the information of different sensors, making the attitude angle estimation more stable and accurate, and achieving the beneficial effect of more accurate attitude estimation.
[0063] 3. The present invention ensures that the data obtained from the accelerometer, magnetometer and gyroscope are accurate by introducing complementary filtering and sensor error calibration technology. These technologies not only improve the accuracy of attitude angle estimation, but also enable it to be updated in real time in a dynamic environment, meeting the requirements of real-time performance of mobile devices, and avoiding common Euler angle representation problems such as universal lock through the stable representation of quaternions. The clear conversion relationship between quaternions and rotation matrices ensures the mathematical stability of attitude angle calculation, so that it can maintain accuracy during long-term use, achieving the beneficial effect of real-time estimation of attitude angle of Android devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 A schematic diagram of a method for estimating an attitude angle of an Android device according to the present invention;
[0065] Figure 2 A schematic diagram of the posture angle estimation process of an Android device of the present invention;
[0066] Figure 3 It is a schematic diagram of the experimental scene of the present invention;
[0067] Figure 4 It is a schematic diagram of the heading angle of the mobile phone of the present invention. DETAILED DESCRIPTION
[0068] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] Embodiment 1
[0070] A method for estimating an attitude angle of an Android device, a schematic diagram of the method for estimating an attitude angle is shown in FIG. Figure 1 As shown, the following steps are included:
[0071] Step 1: Determine the Euler angle rotation order of the Android device, and calculate the rotation matrix based on the Euler angle and quaternion. According to the principle that corresponding items of the same matrix are equal, calculate the conversion relationship between the Euler angle and the quaternion.
[0072] Step 2: Establish an attitude angle estimation model based on complementary filtering.
[0073] Step 3: First calibrate the sensor error, and then use complementary filtering to estimate the Android device attitude angle.
[0074] Step 1: Determine the Euler angle rotation order of the Android device, and calculate the rotation matrix based on the Euler angle and the quaternion. According to the principle that corresponding items of the same matrix are equal, the process of calculating the conversion relationship between the Euler angle and the quaternion is as follows.
[0075] (1.1) When an Android device undergoes a posture transformation, from the perspective of Euler angle transformation, the Android device first undergoes γ (roll angle) transformation, θ (pitch angle) transformation, and ψ (heading angle) transformation. The rotation matrix from the carrier coordinate system to the geographic coordinate system The Euler angle is expressed as follows:
[0076]
[0077] (1.2) On Android devices, use the rotation matrix represented by the quaternion [q0, q1, q2, q3] The expression is as follows:
[0078]
[0079] Rotation Matrix They can be represented by Euler angles and quaternions respectively, and the corresponding items are equal. Therefore, the conversion relationship between quaternions and Euler angles is expressed as follows:
[0080]
[0081] Step 2: The process of establishing the attitude angle estimation model based on complementary filtering is as follows:
[0082] (2.1) Assume that the gyroscope data is ω g =[ω gx ω gy ω gz ] T , the normalized data ω=[ω x ω y ω z ] T , the deviation in the heading estimation process is recorded as e = [e x e y e z ] T , is obtained from the acceleration and magnetic field strength data. Therefore, the value of the gyroscope data error compensation is, where K P =0.1, K i =0.0001:
[0083] ω=ω g +K P e+K I ∫e
[0084] (2.2) The heading angle estimation model based on complementary filtering is as follows:
[0085] Update the gyroscope data using error compensation:
[0086] ω=ω g +K P e+K I ∫e
[0087] Update the quaternion using the gyroscope data:
[0088]
[0089] The attitude angle is solved using the conversion relationship between quaternion and attitude angle.
[0090]
[0091] Step 3: Design the process of estimating the attitude angle of Android device based on sensor error calibration and complementary filtering as follows:
[0092] (3.1) First, place the Android device on a horizontal table, design N static postures, and measure the accelerometer axis readings {Acc i ∈R n×3 , i∈N}, where Acc i Represents the three-axis and velocity data collected in the i-th posture and constructs an ellipsoid model. Based on the data collected in N postures, the ellipsoid center C is solved by least squares. a And the length of each axis S a Finally, when performing device attitude estimation, the collected acceleration data needs to be processed as follows to obtain unbiased data for attitude estimation.
[0093]
[0094] (3.2) First, the Android device is circled in various postures at a certain location, such as holding the Android smartphone in a figure-8 circle, and then the magnetometer reading data of each axis is recorded. i ∈R n×3 , i∈N}, where Mag i Represents the triaxial and magnetometer data collected in the i-th posture and constructs an ellipsoid model. Based on the data collected in N postures, the ellipsoid center C is solved by least squares. m And the length of each axis S m Finally, when performing device attitude estimation, the collected acceleration data needs to be processed as follows to obtain unbiased data for attitude estimation.
[0095]
[0096] (3.3) First, place the Android device at a certain location, keep the device from rotating, and record the gyroscope three-axis data {Gyr i ∈R n×3 , i∈N}, where Gyr i Represents the three-axis and gyroscope data collected in the i-th posture. Average the N-times data according to each axis and calculate the zero bias error C gyr Finally, when performing device attitude estimation, the collected gyroscope data needs to be processed as follows to obtain unbiased data for attitude estimation.
[0097] {Gyr i =Gyr i -C gyr ∈R n×3 , i∈N}
[0098] (3.4) Input the calibrated data into the complementary filter model for calculation and output the real-time attitude angle of the Android device, see Figure 2.
[0099] Embodiment 2
[0100] See also Figure 3
[0101] In a preferred embodiment of the present invention, Figure 3 The experiment was conducted in an indoor positioning scenario shown in the figure, which has a U-shaped corridor and a poor electromagnetic environment.
[0102] In the experimental environment of the present invention, the robot moves around the selected point in a clockwise direction for 2 circles, and uses the self-developed acquisition software on the Android smartphone P20 to collect the accelerometer, magnetometer, and gyroscope data. According to steps (3.2), (3.2), and (3.3), the accelerometer, magnetometer, and gyroscope data are calibrated for errors. Then, according to (3.4), the complementary filter model is input, the calculated quaternion is converted to Euler angles, and the heading angle is output and displayed. The schematic diagram of the obtained heading angle is shown in the figure. Figure 4 shown.
[0103] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for estimating the attitude angle of an Android device. It is characterized in that The following steps are involved: Step 1: Determine the Euler angle rotation order of the Android device and establish the conversion relationship between the carrier coordinate system and the geographic coordinate system; Step 2: Establish the conversion relationship between quaternion and Euler angle based on rotation matrix; Step 3: Design a real-time Android device attitude angle estimation process based on sensor error calibration and complementary filter estimation; Step 4: According to the designed attitude angle estimation process, use the Android smartphone to collect data for real-time update of the attitude angle.
2. The method for estimating the attitude angle of an Android device according to claim 1, Features: The detailed steps in step 1 are: S1.
1. When an Android device undergoes a posture change, from the perspective of Euler angle transformation, the Android device first undergoes γ (roll angle) transformation, θ (pitch angle) transformation, and ψ (heading angle) transformation; The rotation matrix from the carrier coordinate system to the geographic coordinate system is The Euler angle expression is: S1.2, device coordinates [vx, vy, vz] after rotation matrix Transform to geographic coordinates [vx',vy',vz']; S1.
3. The transformation from geographic coordinates [vx', vy', vz'] to device coordinates is the rotation matrix The inverse transformation of S1.
4. Due to the rotation matrix is an orthogonal matrix, its inverse matrix With the transposed matrix equal; Rotation matrix from geographic coordinate system to carrier coordinate system The expression is:
3. The method for estimating the attitude angle of an Android device according to claim 1, Features: Step 2: Establish the rotation relationship between the quaternion and the Euler angle based on the rotation matrix as follows: S2.1, on Android devices, using quaternion [q 0 ,q 1 ,q 2 ,q 3 ] represents the rotation matrix The expression is as follows: S2.2 Rotation Matrix Represented by Euler angles and quaternions respectively, the corresponding items are equal.
4. The method for estimating the attitude angle of an Android device according to claim 3, Features: The conversion relationship between the quaternion and the Euler angle is expressed as: The conversion relationship expression from quaternion to Euler angle is: The conversion relationship expression from Euler angle to quaternion is: The above conversion relationship is used as the basis for real-time estimation of the attitude angle of Android devices.
5. The method for estimating the attitude angle of an Android device according to claim 1, Features: The step three is based on real-time Android device attitude angle estimation based on sensor error calibration and complementary filter estimation.
6. The method for estimating the attitude angle of an Android device according to claim 5, Features: The attitude angle estimation step in step 3 is: S3.1, the built-in sensors of the Android device, accelerometer, magnetometer, and gyroscope, are used to estimate the attitude angle of the device, and the aforementioned sensors are calibrated before estimation; S3.
2. A heading angle estimation model based on complementary filtering uses a complementary filtering model to estimate the heading angle and corrects the gyroscope using acceleration data and magnetic field strength data.
7. The method for estimating the attitude angle of an Android device according to claim 6, Features: The accelerometer, magnetometer and gyroscope sensor calibration method is: S3.1.
1. First, place the Android device on a horizontal desktop, design N static postures, and measure the accelerometer axis readings {Acc i ∈R n×3 ,i∈N}, where Acc i Represents the three-axis and velocity data collected in the i-th posture, constructs an ellipsoid model, and uses the least squares method to solve the ellipsoid center C based on the data collected in N postures a And the length of each axis S a ; Finally, when performing device attitude estimation, the collected acceleration data needs to be processed by the following formula to obtain unbiased data for attitude estimation: S3.1.
2. First, place the Android device in various postures at a certain location, such as holding an Android smartphone in a hand and performing a digital circle, and then record the reading data of each axis of the magnetometer {Mag i ∈R n×3 ,i∈N}, where Mag i Represents the triaxial and magnetometer data collected in the i-th posture, constructs an ellipsoid model, and uses the least square method to solve the ellipsoid center C based on the data collected in N postures m And the length of each axis S m ; Finally, when performing device attitude estimation, the collected acceleration data needs to be processed by the following formula to obtain unbiased data for attitude estimation: S3.1.3, first, keep the Android device still at a certain location, keep the device from rotating, and record the gyroscope three-axis data {Gyr i ∈R n×3 ,i∈N}, where Gyr i represents the three-axis and gyroscope data collected in the i-th posture. The N-times data is averaged according to each axis to calculate the zero bias error C gyr ; Finally, when performing device attitude estimation, the collected gyroscope data needs to be processed by the following formula to obtain unbiased data for attitude estimation: {Gyr i =Gyr i -C gyr ∈R n×3 ,i∈N}。 8. The method for estimating the attitude angle of an Android device according to claim 6, Features: The amendments to S3.2 include: Assume that the gyroscope data is ω g =[ω gx ω gy ω gz ] T , the normalized data ω=[ω x ω y ω z ] T , the deviation in the heading estimation process is recorded as e = [e x e y e z ] T , is obtained from the acceleration and magnetic field strength data, so the value after gyroscope data error compensation is: oh = oh g +K P e+K I ∫e Where K P =0.1,K i =0.0001; The heading angle estimation model based on complementary filtering is as follows: Update the gyroscope data using error compensation: oh = oh g +K P e+K I ∫e Update the quaternion using the gyroscope data:
9. The method for estimating the attitude angle of an Android device according to claim 8, Features: The expression for solving the attitude angle by using the conversion relationship between quaternion and attitude angle in S3.2 is:
10. The method for estimating the attitude angle of an Android device according to claim 1, Features: In step 4, according to the designed attitude angle estimation process, the Android smartphone is used to collect data for real-time update of the attitude angle. The update process is as follows: According to the designed process, write Android code, including sensor data collection, model calculation, real-time update and output of device posture.
Citation Information
Patent Citations
Mobile robot posture angle solution method
CN110146077A
Attitude detection method of nine-axis motion sensor based on EKF (Extended Kalman Filter)
CN114199241A
Method for measuring attitude angle through combination of magnetic force and GNSS (Global Navigation Satellite System)
CN115235465A
Attitude resolving method of quaternion-based improved complementary filtering algorithm
CN117073618A
Posture estimation method, posture estimation apparatus and computer readable storage medium
US20200286245A1
