Algorithm for roll angle and pitch angle of unmanned vehicle

By performing linear fitting and Kalman filtering on the data collected by MPU6050, the error problem caused by the jitter of MPU6050 in unmanned vehicle attitude recognition is solved, and the calculation accuracy of roll angle and pitch angle is significantly improved.

CN118690102APending Publication Date: 2024-09-24CHANGAN AUTOMOBILE (GRP) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410768184.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

In the existing unmanned vehicle attitude recognition technology, the angular velocity integral error and direct signal error caused by the jitter of the MPU6050 six-axis sensor cause the calculation results of the roll angle and pitch angle to deviate from the real situation and the accuracy is not high.

Method used

The MPU6050 collects acceleration and angular velocity and performs linear fitting processing, and uses the Kalman filter algorithm to reduce errors and calculate accurate roll and pitch angles.

Benefits of technology

It effectively reduces the data error and improves the accuracy of the roll angle and pitch angle of the unmanned vehicle, making the results closer to the real values ​​and ensuring the normal operation of the unmanned vehicle.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690102A
    Figure CN118690102A
Patent Text Reader

Abstract

The invention discloses an algorithm for a roll angle and a pitch angle of an unmanned vehicle, and the algorithm comprises the following steps: 1), collecting the accelerations ax, ay and az of a whole vehicle in X, Y and Z axes through an MPU6050 attitude sensor, and collecting the angular velocities wx and wy of the whole vehicle in the X and Y axes; 2) performing linear fitting processing on the collected accelerations ax, ay and az of the X axis, the Y axis and the Z axis and the collected angular velocities wx and wy of the X axis and the Y axis; 3) calculating a roll angle and a pitch angle of the unmanned vehicle according to the accelerations ax, ay and az of the X-axis, the Y-axis and the Z-axis after linear fitting processing; 4) the roll angle obtained through calculation and the X-axis angular velocity wx after linear fitting processing are substituted into a Kalman filtering algorithm to reduce roll angle errors, and an accurate roll angle is obtained; the pitch angle obtained through calculation and the Y-axis angular velocity wy after linear fitting processing are substituted into a Kalman filtering algorithm to reduce pitch angle errors, and the accurate pitch angle is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of posture recognition of unmanned vehicles, and in particular to an algorithm for roll angle and pitch angle of an unmanned vehicle. Background Art

[0002] At present, most unmanned vehicles use MPU6050 to collect the acceleration and angular velocity of the unmanned vehicle to perform posture recognition on its body. MPU6050 is a six-axis attitude sensor, which is an integrated six-axis motion processing component, including an accelerometer and a gyroscope. The accelerometer can collect the acceleration of the X, Y, and Z axes, and the gyroscope can collect the angular velocity of the X, Y, and Z axes.

[0003] In the prior art, the attitude solution based on the MPU6050 six-axis sensor generally uses the following two methods to calculate the roll angle and pitch angle:

[0004] 1. The angular velocity collected by the gyroscope is integrated and accumulated over time. This method has a good effect in a short time. However, in actual applications, due to the serious jitter of the MPU6050 six-axis sensor, the angular velocity collected by the gyroscope will produce an integral cumulative error as time increases. The integral cumulative error means that when calculating the attitude angle, the angular velocity collected by the gyroscope is multiplied by time to obtain the angle difference and accumulate it to obtain the current attitude angle. For example, the X-axis (head direction) angular velocity is integrated with the sampling time to obtain the roll angle. Since the collected signal itself has an error, in the absence of other corrections, after multiplying it with the sampling time, the error will become larger and larger as time increases, causing the result to deviate from the actual situation.

[0005] 2. Use the MPU6050 six-axis sensor to directly output four signals, and then substitute the four signals into the formula to directly calculate the roll angle and pitch angle. This method also causes errors in the collected signals due to the severe jitter of the MPU6050 six-axis sensor in actual applications, resulting in large deviations between the calculation results of the roll angle and pitch angle and the actual situation. Summary of the invention

[0006] In view of the above-mentioned problems, the present invention provides an algorithm for the roll angle and pitch angle of an unmanned vehicle, which greatly improves the accuracy of the roll angle and pitch angle and ensures the normal operation of the unmanned vehicle.

[0007] The technical solution of the present invention is: an algorithm for the roll angle and pitch angle of an unmanned vehicle, comprising the following steps:

[0008] 1) The MPU6050 attitude sensor is used to collect the acceleration of the vehicle on the X, Y, and Z axes. x 、a y 、a z , and the angular velocity w of the vehicle on the X and Y axesx 、w y ;

[0009] 2) The collected acceleration a of the X, Y, and Z axes x 、a y 、a z and the angular velocity w of the X and Y axes x 、w y All processed by linear fitting;

[0010] 3) The acceleration a of the X, Y, and Z axes after linear fitting x 、a y 、a z , through the formula Calculate the roll angle of the unmanned vehicle using the formula Calculate the pitch angle of the unmanned vehicle;

[0011] 4) The calculated roll angle and the X-axis angular velocity w after linear fitting are x The Kalman filter algorithm is introduced to reduce the roll angle error and obtain an accurate roll angle; the calculated pitch angle and the Y-axis angular velocity w after linear fitting are y The Kalman filter algorithm is introduced to reduce the pitch angle error and obtain an accurate pitch angle.

[0012] Preferably, in step 2), the collected acceleration a of the X, Y, and Z axes is x 、a y 、a z and the angular velocity w of the X and Y axes x 、w y All the data were processed by first-order linear fitting.

[0013] Preferably, the fitting coefficients of the first-order linear fitting are obtained by a least squares method.

[0014] Preferably, the step of obtaining the fitting coefficient of the first-order linear fitting by the least squares method is:

[0015] ①Set the fitting period;

[0016] ② Collect data and record the data and corresponding time;

[0017] ③ According to the fitting cycle, the recorded data and the corresponding time are substituted into y=kx+b, where y is the recorded data, x is the time corresponding to the recorded data, k and b are the fitting coefficients, and the fitting coefficients k and b are obtained to complete the first-order linear fitting.

[0018] Furthermore, in step ①, the fitting period is set to 10.

[0019] Preferably, in step 1), the acceleration a of the vehicle on the X, Y, and Z axes is x 、a y 、a z , the angular velocity w of the vehicle on the X and Y axes is collected by the accelerometer of MPU6050 x 、w y , collected by the gyroscope of MPU6050.

[0020] The advantages of the present invention are:

[0021] 1. The present invention processes the collected data by linear fitting, thereby reducing the data error caused by the jitter of the MPU6050 six-axis sensor.

[0022] 2. The present invention calculates the roll angle and pitch angle of the unmanned vehicle through the acceleration of the X, Y, and Z axes collected by the accelerometer, thereby avoiding the data error caused by the jitter of the gyroscope and further improving the accuracy of the roll angle and pitch angle of the unmanned vehicle.

[0023] 3. The present invention improves the accuracy of the calculated roll angle and pitch angle through the Kalman filter algorithm, so that the roll angle and pitch angle of the unmanned vehicle are closer to the true value and more accurate results are obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 is a flow chart of the present invention;

[0025] Figure 2 is the Z-axis acceleration a of the present invention z The first-order linear fitting result graph. DETAILED DESCRIPTION

[0026] See also Figure 1 to Figure 2 , an algorithm for the roll angle and pitch angle of an unmanned vehicle, comprising the following steps:

[0027] 1) The acceleration of the vehicle on the X, Y, and Z axes is collected through the MPU6050 accelerometer x 、a y 、a z The angular velocity w of the vehicle on the X and Y axes is collected through the MPU6050 gyroscope x 、w y ;

[0028] 2) The collected acceleration a of the X, Y, and Z axes x 、a y 、a z and the angular velocity w of the X and Y axes x 、w yAll are processed by first-order linear fitting, and the fitting coefficient of the first-order linear fitting is obtained by the least square method. In this embodiment, the Z-axis acceleration a is processed z For example, we use the least squares method to obtain a z The steps for fitting the coefficients of the first-order linear fit are:

[0029] ① Set the fitting cycle to 10, that is, 10 sets of data are fitted each time, and each set of data includes data and corresponding time;

[0030] ② Collect Z-axis acceleration a z , and record the Z-axis acceleration a z and the corresponding time, as shown in Table 1;

[0031] Table 1

[0032]

[0033] ③ x 1 ,y 1 、x 2 ,y 2 ,……x 10 ,y 10 Substitute the first-order equation y=kx+b to obtain the Z-axis acceleration a z The fitting coefficients k and b of the first-order linear fitting, and then x 10 Substitute into the fitted first-order equation y=kx+b to get the fitting result y corresponding to the output 1 ' 0 , x 2 ,y 2 、x 3 ,y 3 ,……x 11 ,y 11 Substitute into the first-order equation y=k 1 x+b 1 , and get the Z-axis acceleration a z The fitting coefficient k of the first-order linear fit 1 、b 1 Then, x 11 Substitute the fitted first-order equation y=k 1 x+b 1 In the output, the fitting result y corresponding to the output is obtained 1 ' 1 ..., and so on, the Z-axis acceleration a is completed. z The first-order linear fitting process of Figure 2 The orange data in the figure is the original collected Z-axis acceleration a z Data, blue data is the Z-axis acceleration a after first-order linear fitting zThe fitted data is smoother than the original data, which reduces the acquisition error.

[0034] 3) Linear fitting to process the acceleration a of the X, Y, and Z axes x 、a y 、a z After that, according to the relationship between gravity acceleration and rotation matrix, the formula for calculating the roll angle of the unmanned vehicle is:

[0035]

[0036] The formula for calculating the pitch angle of the unmanned vehicle is:

[0037]

[0038] In the formula, roll is the roll angle of the unmanned vehicle, and pitch is the pitch angle of the unmanned vehicle.

[0039] 4) The calculated roll angle and the X-axis angular velocity w after linear fitting are x The Kalman filter algorithm is introduced to reduce the roll angle error and obtain an accurate roll angle; the calculated pitch angle and the Y-axis angular velocity w after linear fitting are y The Kalman filter algorithm is introduced to reduce the pitch angle error and obtain an accurate pitch angle.

[0040] The Kalman filter algorithm consists of the following equations:

[0041]

[0042] P k|k-1 =FP k-1|k-1 F T +Q k

[0043]

[0044] P k|k =(IK k H)P k|k-1

[0045] z k =Hx k +v k

[0046] In the formula, is the prediction of state x at the Kth moment at the K-1 moment, is the state after Kalman filtering at time K-1, F is the state transfer matrix, which is used to represent the prediction process from the previous stage to this stage, u k is the control vector (input), B is the control vector gain matrix, w kis the prediction equation noise, w k ~N(0,Q k ), P k|k-1 is the covariance of the state quantity predicted at the K-1 moment to the Kth moment, Q k is the noise w k covariance, H is the mapping of the state vector to the state vector space in the observation equation, R k is the covariance of the observation noise, x k is the observed quantity, v k is the observation equation noise, x k ~N(0,R k ), I is the unit matrix, K k is the Kalman gain.

[0047] In this embodiment, the algorithm for reducing the pitch angle error by using the Kalman filter algorithm is to convert the Y-axis angular velocity w y Substitute u into the Kalman filter algorithm k , and bring the calculated pitch angle pitch into the z in the Kalman filter algorithm k .

[0048] According to the calculation needs, there are

[0049] Angular velocity = new angular velocity - angular velocity offset

[0050] Angle = angle calculated in the previous cycle + angular velocity * dt

[0051] Therefore, some initial values ​​in the Kalman filter algorithm equation are set so that

[0052]

[0053] ω k =0

[0054]

[0055] R k =0.003

[0056]

[0057] Input is the Y-axis angular velocity w y And the calculated pitch angle pitch, that is,

[0058] u k =w y

[0059] z k =pitch

[0060] The desired result is θ represents the updated estimated angle, that is, the desired Kalman filter result, is the gyroscope angular velocity offset, is the instrument error, and can be set to a fixed value.

[0061] Now, let To estimate the initial value, u k =wy, ω k =0, Substitute into the Kalman filter equation In, obtain Then Substitute into the Kalman filter equation P k|k-1 =FP k-1|k-1 F T +Q k In the k|k-1 ; P k|k-1 , R k =0.003 into the Kalman filter equation In the equation, we get the Kalman gain K k ; then K k 、z k =pitch, Substitute into the Kalman filter equation In the Kalman estimate is a 2*1 vector where x 11 This is the pitch angle of the Kalman filter. k , P k|k-1 , Substitute into the Kalman filter equation P k|k =(IK k H)P k|k-1 In the above example, the state covariance P is updated. k|k , the Y-axis angular velocity w y Constantly bring u into the Kalman filter algorithm equation k , the calculated pitch angle pitch is continuously brought into the z in the Kalman filter algorithm equation k , the Kalman filter algorithm continuously updates the predicted value State covariance moment Kalman gain K k , the predicted filter value can be updated in real time to improve the accuracy of the calculated pitch angle.

[0062] Similarly, in the algorithm that uses the Kalman filter algorithm to reduce the roll angle error, it is only necessary to change the x-axis angular velocity wx Substitute u into the Kalman filter algorithm equation k , and bring the calculated roll angle roll into the z in the Kalman filter algorithm equation k The accuracy of the calculated roll angle roll can be improved, and the algorithm principle is the same as the algorithm principle of using the Kalman filter algorithm to reduce the pitch angle error.

[0063] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modification made to the present invention by those skilled in the art without departing from the spirit of the present invention shall fall within the protection scope of the present invention.

Claims

1. An algorithm for calculating the roll angle and pitch angle of an unmanned vehicle, characterized in that: The following steps are involved: 1) The MPU6050 attitude sensor is used to collect the acceleration of the vehicle on the X, Y, and Z axes. x 、a y 、a z , and the angular velocity w of the vehicle on the X and Y axes x 、w y ; 2) The collected acceleration a of the X, Y, and Z axes x 、a y 、a z and the angular velocity w of the X and Y axes x 、w y All processed by linear fitting; 3) The acceleration a of the X, Y, and Z axes after linear fitting x 、a y 、a z , through the formula Calculate the roll angle of the unmanned vehicle using the formula Calculate the pitch angle of the unmanned vehicle; 4) The calculated roll angle and the X-axis angular velocity w after linear fitting are x The Kalman filter algorithm is introduced to reduce the roll angle error and obtain an accurate roll angle; the calculated pitch angle and the Y-axis angular velocity w after linear fitting are y The Kalman filter algorithm is introduced to reduce the pitch angle error and obtain an accurate pitch angle.

2. The algorithm for calculating the roll angle and pitch angle of an unmanned vehicle according to claim 1, characterized in that: In step 2), the collected acceleration a of the X, Y, and Z axes is x 、a y 、a z and the angular velocity w of the X and Y axes x 、w y All the data were processed by first-order linear fitting.

3. The algorithm for calculating the roll angle and pitch angle of an unmanned vehicle according to claim 2, characterized in that: The fitting coefficients of the first-order linear fitting are obtained by the least squares method.

4. The algorithm for calculating the roll angle and pitch angle of an unmanned vehicle according to claim 3, characterized in that: The steps of obtaining the fitting coefficients of the first-order linear fitting by the least squares method are as follows: ①Set the fitting period; ② Collect data and record the data and corresponding time; ③ According to the fitting cycle, the recorded data and the corresponding time are substituted into y=kx+b, where y is the recorded data, x is the time corresponding to the recorded data, k and b are the fitting coefficients, and the fitting coefficients k and b are obtained to complete the first-order linear fitting.

5. The algorithm for calculating the roll angle and pitch angle of an unmanned vehicle according to claim 4, characterized in that: In step ①, the fitting period is set to 10.

6. The algorithm for calculating the roll angle and pitch angle of an unmanned vehicle according to claim 1, characterized in that: In step 1), the acceleration a of the vehicle on the X, Y, and Z axes is x 、a y 、a z , the angular velocity w of the vehicle on the X and Y axes is collected by the accelerometer of MPU6050 x 、w y , collected by the gyroscope of MPU6050.

Citation Information

Cited By

  • Electric wheelchair walking aid control method and system based on road condition self-adaption

    CN122260875A

  • A road condition self-adaptive based electric wheelchair walking assisting control method and system

    CN122260875B