Flight attitude estimation method and system based on MEMS sensor
Technical Field
The application relates to the technical field of aircraft attitude estimation, in particular to a flight attitude estimation method and system based on an MEMS sensor.
Background
The flight attitude refers to the state of the three axes of the aircraft in the air relative to a certain reference line or a certain reference plane or a certain fixed coordinate system. The aircraft has various flight attitudes during flying in the air, and the flight attitudes determine the moving direction of the aircraft, thereby influencing the flying height and the flying direction. The estimation of the flight attitude plays a crucial role in the flight process of the aircraft, and the flight attitude can be estimated to ensure that the flight course of the aircraft is correct and the flight safety is ensured.
The MEMS sensor is a core device of an Attitude and Heading Reference System (AHRS) and a Micro inertial navigation system (Micro-INS), the traditional method for estimating the flight attitude based on the MEMS sensor is to calculate and estimate the data of an accelerometer and a gyroscope in the MEMS sensor and carry out Kalman filtering iteration, and the method generally has the following problems that (1) the gyroscope in the MEMS sensor generates accumulated errors after long-time movement, which means that the device characteristics of the gyroscope cannot be eliminated, drift caused by the accumulated errors influences the output angle value and influences the accuracy of a Kalman filter system equation; (2) the method is generally applicable to steady-state motion scenes, including a static mode and a constant rotating speed motion mode, and cannot be applied to actual scenes. Under the complex motion mode, the error caused by the accumulated drift of the gyroscope is more obvious, and the output result is not accurate.
Disclosure of Invention
The present invention is directed to a method and system for estimating a flight attitude based on a MEMS sensor, which may solve one or more of the above-mentioned problems of the prior art.
According to one aspect of the present invention, a method for estimating a flight attitude based on a MEMS sensor is provided, comprising the steps of:
collecting data output by an accelerometer and a magnetometer, and determining a carrier coordinate system;
converting the carrier coordinate system into a ground coordinate system, and solving an error according to the corresponding gravity and the vector of the earth magnetic field;
using the data output by the error correction gyroscope;
updating quaternion by using the corrected data output by the gyroscope to obtain a new attitude angle;
and performing Kalman filtering by using the new attitude angle to obtain a flight attitude estimation result.
The beneficial effects are as follows: according to the invention, a carrier coordinate system is calculated through data of the accelerometer and the magnetometer, an error is calculated according to a vector of corresponding gravity and an earth magnetic field, and the error is used for correcting the output of the gyroscope, so that the output of the gyroscope is more accurate, the problem of accumulated drift error generated by the gyroscope is effectively solved, and the accuracy of the output result of the Kalman filter is increased; quaternion is used for participating in calculation, so that the overall calculation amount is reduced, the calculation cost is reduced, and the calculation speed is increased; by solving the problem of accumulated drift error generated by a gyroscope, the method provided by the invention can be applied to complex motion modes in actual motion scenes.
In some embodiments, collecting data output by the accelerometer and the magnetometer, and determining the carrier coordinate system comprises:
according to the data output by the accelerometer, determining an initial roll angle phi and an initial pitch angle theta, wherein the formula is as follows:
in the formula,ax、ayAnd azInitial data output for the accelerometer;
the transformation matrix between the carrier coordinate system and the bottom surface coordinate system is T, and when ψ is 0, the formula of the transformation matrix T is as follows:
can be obtained by operation
In the formula, phi is an initial roll angle, and theta is an initial pitch angle;
the initial data output by the magnetometer is compensated by the initial data output by the accelerometer, namely the compensated magnetometer data is obtained according to the initial roll angle phi, the initial pitch angle theta and the initial data output by the magnetometer, and the calculation formula is as follows:
in the formula, magxAnd magyOutput data for compensated magnetometer, mx、myAnd mzInitial data output for the magnetometer;
calculating an initial heading angle psi by using the compensated magnetometer output data, wherein the calculation formula is as follows:
the initial attitude angles were obtained as follows:
where φ is the initial roll angle, θ is the initial pitch angle, and ψ is the initial heading angle.
The beneficial effects are as follows: and the initial data output by the magnetometer is compensated by the initial data output by the accelerometer, so that the accuracy of the initial attitude angle is further improved.
In some embodiments, converting the carrier coordinate system into a ground coordinate system, and determining the error according to the gravity vector and the geomagnetic vector of the corresponding reference includes:
the corresponding initial quaternion is obtained from α, γ, and β, as follows:
and solving a conversion matrix T by using the initial quaternion, wherein the conversion matrix T is as follows:
the initial data output by the accelerometer is normalized, and the processing formula is as follows:
and calculating direction vectors of gravity and a magnetic field, wherein the formula is as follows:
using the treated ax′、ay' and az' calculation error from the direction vectors of gravity and magnetic field, formula:
in the formula, ex、eyAnd ezTo define the initial value of error, ax′、ay' and az' normalization of the processed accelerometer output data, vx、vyAnd vzThe direction vectors of gravity and the magnetic field.
In some embodiments, the data output using the error correction gyroscope uses the following equation:
in the formula, gx、gyAnd gzInitial angular velocity, K, of the gyroscope outputPTo scale factor, KiThe adjustment coefficients are integrated.
The beneficial effects are as follows: and the data output by the gyroscope is compensated, so that the measurement precision is improved.
In some embodiments, the scaling factor K isP1 and integral adjustment coefficient Ki=0。
In some embodiments, performing a quaternion update using the corrected gyroscope output data, obtaining the new attitude angle comprises:
using corrected angular velocity gx′、gy' and gz' with initial quaternion q0、q1、q2And q is3Calculating a derivative of the initial quaternion;
in the formula (I), the compound is shown in the specification,
and
is the derivative of the initial quaternion;
and (3) integrating the derivative of the initial quaternion to obtain a new quaternion, wherein the formula is as follows:
in the formula, q0′、q1′、q2' and q3' is a new quaternion;
and (3) bringing a new quaternion into the conversion matrix T to obtain the conversion matrix T as follows:
calculating the attitude angle according to the formula
Where φ ' is the new roll angle, θ ' is the new pitch angle, and ψ ' is the new heading angle.
In some embodiments, using the new attitude angle for kalman filtering to obtain the flight attitude estimation result comprises:
the state equation is determined as follows:
in the formula, XkThe state vector at the moment k, q is a discrete time model obtained by using a Runge-Kutta method, t is sampling time, M is an operation matrix, and the calculation formula of M is as follows:
wherein, gx′、gy' and gz' is the corrected gyroscope output, t is the sampling time;
the discrete-time model q is as follows:
in the formula, t is sampling time, Ω b represents a component of angular velocity on the navigation mark coordinate system, and can be obtained from output data corrected by a gyroscope, and the matrix type of Ω b is represented as the following formula:
in the formula, gx′、gy' and gz' is the corrected gyroscope output;
determining a measurement matrix H (k), wherein the measurement matrix H (k) has the following formula:
wherein g represents the acceleration of gravity, q0′、q1′、q2' and q3' denotes a new quaternion;
performing basic algorithm arrangement of Kalman filtering, wherein the algorithm flow is as follows:
the state update equation:
one-step prediction mean square error equation:
P(k,k-1)=Φ(k,k-1)P(k,k-1)ΦT (k,k-1)+Q(k)
filter gain matrix equation:
K(k)=P(k,k-1)HT (k)[H(k)P(k,k-1)HT (k)+R(k)]-1
the state estimation calculation equation:
estimating mean square error equation
P(k)=[I-K(k)H(k)]K(k,K-1)[I-K(k)H(k)]T+K(k)R(k)KT (k)。
In a second aspect, an embodiment of the present invention provides a system for determining a flying attitude based on a MEMS sensor, including: the data output ends of the accelerometer, the magnetometer and the gyroscope are connected with the input end of the processor, and the data output end of the processor is connected with the input end of the filter.
In addition, in the technical scheme of the invention, the technical scheme can be realized by adopting the conventional means in the field unless being particularly described.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a flowchart of a method for estimating a flying attitude based on a MEMS sensor according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of a system for estimating a flying attitude based on a MEMS sensor according to another embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1:
fig. 1 shows a method for estimating a flying attitude based on a MEMS sensor according to an embodiment of the present invention, which includes the following steps:
s11: and collecting data output by the accelerometer and the magnetometer, and determining a carrier coordinate system.
In an alternative embodiment, collecting data output by the accelerometer and the magnetometer and determining the carrier coordinate system comprises:
according to the data output by the accelerometer, determining an initial roll angle phi and an initial pitch angle theta, wherein the formula is as follows:
in the formula, ax、ayAnd azInitial data output for the accelerometer;
the transformation matrix between the carrier coordinate system and the bottom surface coordinate system is T, and when ψ is 0, the formula of the transformation matrix T is as follows:
can be obtained by operation
In the formula, phi is an initial roll angle, and theta is an initial pitch angle;
according to the initial attitude angle information and magnetometer data, parameters required for acquiring course angle information can be obtained, and the formula is as follows:
in the formula, Xh、YhAnd ZhMeans that when the carrier coordinate system coincides with the ground coordinate, Xh、YhAnd ZhThe components of the earth magnetic field in the three-axis direction of the carrier coordinate system are shown;
the heading angle ψ can be calculated using the following formula:
according to Xh、YhCan obtain one of the heading angle psiThe general calculation formula is:
the initial data output by the magnetometer is compensated by the initial data output by the accelerometer, namely the compensated magnetometer data is obtained according to the initial roll angle phi, the initial pitch angle theta and the initial data output by the magnetometer, and the calculation formula is as follows:
in the formula, magxAnd magyOutput data for compensated magnetometer, mx、myAnd mzInitial data output for the magnetometer;
calculating an initial heading angle psi by using the compensated magnetometer output data, wherein the calculation formula is as follows:
the initial attitude angles were obtained as follows:
where φ is the initial roll angle, θ is the initial pitch angle, and ψ is the initial heading angle.
S12: and converting the carrier coordinate system into a ground coordinate system, and solving the error according to the corresponding gravity and the vector of the earth magnetic field.
In an alternative embodiment, the converting the carrier coordinate system into a ground coordinate system, and the calculating the error according to the gravity vector and the geomagnetic vector of the corresponding reference includes:
the corresponding initial quaternion is obtained from α, γ, and β, as follows:
and solving a conversion matrix T by using the initial quaternion, wherein the conversion matrix T is as follows:
the initial data output by the accelerometer is normalized, and the processing formula is as follows:
and calculating direction vectors of gravity and a magnetic field, wherein the formula is as follows:
using ax′、ay' and az' calculation error from the direction vectors of gravity and magnetic field, formula:
in the formula, ex、eyAnd ezTo define the initial value of error, ax′、ay' and az' normalization of the processed accelerometer output data, vx、vyAnd vzThe direction vectors of gravity and the magnetic field.
S13: the data output by the gyroscope is corrected using the error.
In an alternative embodiment, the data output using the error correction gyroscope uses the following equation:
in the formula, gx、gyAnd gzInitial angular velocity, K, of the gyroscope outputPTo scale factor, KiThe adjustment coefficients are integrated.
In the alternativeIn the examples, the scaling factor K P1 and integral adjustment coefficient Ki=0。
S14: and updating the quaternion by using the corrected data output by the gyroscope to obtain a new attitude angle.
In an alternative embodiment, performing quaternion update using the corrected data output by the gyroscope, and obtaining a new attitude angle includes:
using corrected angular velocity gx′、gy' and gz' with initial quaternion q0、q1、q2And q is3Calculating a derivative of the initial quaternion;
in the formula (I), the compound is shown in the specification,
and
is the derivative of the initial quaternion;
and (3) integrating the derivative of the initial quaternion to obtain a new quaternion, wherein the formula is as follows:
in the formula, q0′、q1′、q2' and q3' is a new quaternion;
and (3) bringing a new quaternion into the conversion matrix T to obtain the conversion matrix T as follows:
and (3) calculating the attitude angle according to the following formula:
where φ ' is the new roll angle, θ ' is the new pitch angle, and ψ ' is the new heading angle.
S15: and performing Kalman filtering by using the new attitude angle to obtain a flight attitude estimation result.
The kalman filter is a highly efficient recursive filter that regenerates an estimate of an unknown variable based on the values of each measurement at different times, taking into account the joint distribution at each time, and is therefore more accurate than an estimation based on a single measurement.
In an alternative embodiment, the obtaining of the flight attitude estimation result by using the new attitude angle to perform kalman filtering includes:
the state equation is determined as follows:
in the formula, XkThe state vector at the moment k, q is a discrete time model obtained by using a Runge-Kutta method, t is sampling time, M is an operation matrix, and the calculation formula of M is as follows:
wherein, gx′、gy' and gz' is the corrected gyroscope output, t is the sampling time;
the discrete-time model q is as follows:
in the formula, t is sampling time, Ω b represents a component of angular velocity on the navigation mark coordinate system, and can be obtained from output data corrected by a gyroscope, and the matrix type of Ω b is represented as the following formula:
in the formula, gx′、gy' and gz' is the corrected gyroscope output;
determining a measurement matrix H (k), wherein the measurement matrix H (k) has the following formula:
wherein g represents the acceleration of gravity, q0′、q1′、q2' and q3' denotes a new quaternion;
performing basic algorithm arrangement of Kalman filtering, wherein the algorithm flow is as follows:
the state update equation:
one-step prediction mean square error equation:
P(k,k-1)=Φ(k,k-1)P(k,k-1)ΦT (k,k-1)+Q(k)
filter gain matrix equation:
K(k)=P(k,k-1)HT (k)[H(k)P(k,k-1)HT (k)+R(k)]-1
the state estimation calculation equation:
estimating mean square error equation
P(k)=[I-K(k)H(k)]K(k,K-1)[I-K(k)H(k)]T+K(k)R(k)KT (k)。
According to the invention, a carrier coordinate system is calculated through data of the accelerometer and the magnetometer, an error is calculated according to a vector of corresponding gravity and an earth magnetic field, and the error is used for correcting the output of the gyroscope, so that the output of the gyroscope is more accurate, the problem of accumulated drift error generated by the gyroscope is effectively solved, and the accuracy of the output result of the Kalman filter is increased; quaternion is used for participating in calculation, so that the overall calculation amount is reduced, the calculation cost is reduced, and the calculation speed is increased; by solving the problem of accumulated drift error generated by a gyroscope, the method provided by the invention can be applied to complex motion modes in actual motion scenes.
Example 2:
fig. 2 shows a system for determining a flying attitude based on a MEMS sensor according to embodiment 2 of the present invention, which includes an accelerometer 1, a magnetometer 2, a gyroscope 3, a processor 4, and a filter 5, wherein data output terminals of the accelerometer 1, the magnetometer 2, and the gyroscope 3 are connected to an input terminal of the processor 4, and a data output terminal of the processor 4 is connected to an input terminal of the filter 5. The processor 4 is used for acquiring and processing the data measured by the accelerometer 1, the magnetometer 2 and the gyroscope 3, and sending the processed result to the filter 5 for estimating the flight attitude.
The system for determining a flying attitude based on an MEMS sensor according to embodiment 2 may be configured to execute the method for estimating a flying attitude based on an MEMS sensor according to embodiment 1 of the present invention, and accordingly achieve the technical effects achieved by the method for estimating a flying attitude based on an MEMS sensor according to embodiment 1 of the present invention, which are not described herein again.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.