Rflysim | Sensor calibration and measurement experiment one

This lecture is about multi-rotor sensors, including magnetometers that measure magnetic fields. It mainly explains three-axis accelerometers, three-axis gyroscopes, three-axis magnetometers, ultrasonic ranging modules, barometers, and two-dimensional laser ranging radars. The basic principles, calibration methods and measurement models of GPS modules and cameras, and answers on how to perform sensor calibration and what the sensor measurement model is.

Sensor calibration and measurement experiment 1

1. Introduction to flight control inertial measurement unit

Inertial Measurement Unit (IMU) is mainly used to detect and measure acceleration, tilt, impact, vibration, rotation and multi-degree of freedom motion. Usually refers to a device that uses an accelerometer and a gyroscope to measure the single-axis, dual-axis or tri-axial attitude angle (or angular rate) and acceleration of an object. The IMU system in flight control generally includes a three-axis gyroscope, a three-axis accelerometer and a three-axis magnetometer. The gyroscope is used to measure the angular velocity of the three axes, the accelerometer is used to measure the acceleration of the three axes, and the magnetometer provides orientation information.

2. Three-axis acceleration calibration

2.1 Basic principles of three-axis accelerometer

The three-axis accelerometer is an inertial sensor that can measure the specific force of an object, that is, the overall acceleration after removing gravity or the non-gravitational force acting on unit mass. When the accelerometer remains stationary, the accelerometer senses the acceleration due to gravity, and the overall acceleration is zero. In free fall, the overall acceleration is the acceleration of gravity, but the accelerometer is in a weightless state inside, and the output of the three-axis accelerometer is zero at this time.

picture

The principle of a three-axis accelerometer can be used to measure angles, as shown intuitively in the figure. The amount of spring compression is determined by the angle between the accelerometer and the ground, and the specific force can be measured by the compression length of the spring. Therefore, in the absence of external force, the accelerometer can accurately measure pitch and roll angles without cumulative error.

picture

2.2 Three-axis accelerometer error model

Three-axis accelerometers may cause inaccuracies in data measurement due to manufacturing or installation errors. Therefore, the accelerometer needs to be calibrated. Currently, there are two calibration methods: general calibration: requires external calibration equipment, which is troublesome but accurate; automatic calibration: does not require external calibration equipment, is simple, and has slightly poor accuracy. This article will take automatic correction as an example to explain. Before automatic correction, the relationship between the three-axis acceleration before and after calibration needs to be established in advance. The error model is as follows:

picture

In order to correct the accelerometer measurements we need to estimate the following unknown parameters:

picture

Through simplification, its right side can be recorded as the following function:

picture

The specific force is measured multiple times at a fixed angle, so the measurement noise can be ignored. Specifically, the accelerometer rotates at different angles and remains stationary for a period of time at each fixed angle. Denote the average specific force measured in the kth time interval as the acceleration value before calibration. The calibration principle is that no matter how the angle at which the accelerometer is placed changes, the module length of the specific force is always a constant value, that is, the local gravity acceleration, denoted by for g. According to this principle, the following optimization equation is used to estimate unknown parameters:

picture

Thus, the Levenberg-Marquardt algorithm is adopted to obtain the optimal solution. For the specific derivation process, please refer to Chapter 7 of the literature [1].

2.3 MATLAB code implementation

1% file description:

2 % According to the accelerometer error model, use the lm optimization algorithm to calculate the accelerometer error model parameters.

3 close all

4 clc

5 clear

6

7 load AccRaw %Load uncalibrated accelerometer parameters

8 g = 9.8;

9 m = length(AccRaw);

10

11 y_dat = g*ones(m, 1); % expected gravity acceleration value

12 p0 = [1 1 1 0 0 0]';

13 p_init = [1.0 1.0 1.0 0.1 0.1 0.1]’; % initial value of accelerometer error model parameters

14

15 y_raw = calFunc(AccRaw, p0); % uncalibrated gravity acceleration value

16 y_raw = y_raw(:);

17

18 r_raw = y_dat - y_raw; %The difference between the gravity acceleration measured by the accelerometer and the standard gravity acceleration when not calibrated

19 p_fit = lm('calFunc', p_init, AccRaw, y_dat);

20 y_lm = calFunc(AccRaw, p_fit); % calibrated gravity acceleration value

21 y_lm = y_lm(:);

22 r_lm = y_dat - y_lm;

23

24 kx = p_fit(1);

25 ky = p_fit(2);

26 kz = p_fit(3);

27 bx = p_fit(4);

28 by = p_fit(5);

29 bz = p_fit(6);

30

31 Ka9_8 = [kx 0 0; 0 ky 0; 0 0 kz]

32 ba9_8 = [bx by bz]’

33 save(’calP9_8’, ’Ka9_8’, ’ba9_8’)

In MATLAB, after running this file, MATLAB will pop up the following image, in which the first line is: the collected data and feature points of the accelerometer on the X, Y, and Z axes, and the second line is: the number of iterations of the LM algorithm. , comparison chart before and after calibration, and data indicator chart before and after calibration.

picture

The final calibrated parameters will also pop up in the MATLAB command line, as shown in the figure below.

picture

Note: The address of the demo file corresponding to this experiment for versions below RflySim v3.0 is: *\PX4PSP\RflySimAPIs\Exp02_FlightControl\e3-SensorCalib;

For RflySim v3.0 and above, the address is: *\PX4PSP\RflySimAPIs\5.RflySimFlyCtrl\1.BasicExps\e3-SensorCalib.

2.4 Measurement model of three-axis accelerometer

The accelerometer is firmly connected to the body axis and measures the specific force in the three body axis directions. It can be expressed as:

picture

The drift can be modeled as the following Gaussian random walk process:

picture

Note: Since most MEMS sensors are based on semiconductor materials, and semiconductors are very sensitive to temperature, coupled with other factors such as installation and circuit design, zero-point drift and temperature drift are inevitable.

3. Analysis of the influence of gravity acceleration on accelerometer calibration

Different altitudes will produce different gravity acceleration values, according to the following formula:

picture

Among them Ta=I3. If the gravitational acceleration changes, for example, g changes to αg, α>0. Multiplying both sides of the equation by α can yield the following relationship:

picture

This means that after the gravitational acceleration changes, K*’’’’’’= αK* and ba*’=ba* can be obtained according to the optimization equation. Correction steps are as follows:

①: Open the "calLM.m" file and change the value of gravity acceleration g from 9.8 to 1.

1% file description:

2 % According to the accelerometer error model, use the lm optimization algorithm to calculate the accelerometer error model parameters.

3 close all

4 clc

5 clear

6

7 load AccRaw %Load uncalibrated accelerometer parameters

8 g = 1; % Change here to 1

9 m = length(AccRaw);

10

11 y_dat = g*ones(m, 1); % expected gravity acceleration value

12 p0 = [1 1 1 0 0 0]';

13 p_init = [1.0 1.0 1.0 0.1 0.1 0.1]’; % initial value of accelerometer error model parameters

14

15 y_raw = calFunc(AccRaw, p0); % uncalibrated gravity acceleration value

16 y_raw = y_raw(:);

17

18 r_raw = y_dat - y_raw; %The difference between the gravity acceleration measured by the accelerometer and the standard gravity acceleration when not calibrated

19 p_fit = lm('calFunc', p_init, AccRaw, y_dat);

20 y_lm = calFunc(AccRaw, p_fit); % calibrated gravity acceleration value

21 y_lm = y_lm(:);

22 r_lm = y_dat - y_lm;

23

24 kx = p_fit(1);

25 ky = p_fit(2);

26 kz = p_fit(3);

27 bx = p_fit(4);

28 by = p_fit(5);

29 bz = p_fit(6);

30

31 Ka9_8 = [kx 0 0; 0 ky 0; 0 0 kz]

32 ba9_8 = [bx by bz]’

33 save(’calP9_8’, ’Ka9_8’, ’ba9_8’)

②: Copy the sensor data obtained in the basic experiment to the directory where the "calLM.m" file is located.

③: Run the "calLM.m" file to get the calibration results and curves. The correction parameters are:

picture

picture

It can be seen that the calibration parameter ba′ obtained when g=1 is almost unchanged compared to the calibration parameter ba obtained when g=9.8, but the value of K*a′ becomes smaller. The value of K*’α should be reduced to 1/9.8 of αK*α, which is consistent with the conclusion of theoretical analysis. The three-axis accelerometer is fixed on the multi-rotor body, and its coordinate axis is consistent with the coordinate axis of the body. The pitch angles when g are 9.8 and 1 respectively can be calculated from the corrected accelerometer values ​​and formulas. In order to change the pitch angle in the continuous process, the accelerometer data is collected again when the f flight control is slowly rotated. Therefore, it can be found that the results calculated by the accelerometer have nothing to do with the reference acceleration of gravity.

Note: The address of the demo file corresponding to this experiment for versions below RflySim v3.0 is: *\PX4PSP\RflySimAPIs\Exp02_FlightControl\e3-SensorCalib;

For RflySim v3.0 and above, the address is: *\PX4PSP\RflySimAPIs\5.RflySimFlyCtrl\1.BasicExps\e3-SensorCalib.

references:

[1] Translated by Quan Quan, Du Guangxun, Zhao Zhiyao, Dai Xunhua, Ren Jinrui, and Deng Heng. Multi-rotor aircraft design and control [M], Electronic Industry Press, 2018.

[2] Quan Quan, Dai Xunhua, Wang Shuai. Design and control practice of multi-rotor aircraft [M], Electronic Industry Press, 2020.

Guess you like

Origin blog.csdn.net/FEISILAB_2022/article/details/133710588