Research on Real ‐ time Simulation of Attitude and Path Based on Inertial Data of Probe

: In order to solve the problems of manual missed detection and low efficiency of traditional Class A ultrasound, the inertial data of the probe is obtained by binding the IMU inertial sensor with the probe. Combined with Unity motion simulation, the real-time simulation of twin's posture and path is realized, which lays the foundation for the construction of digital twin system.


Introduction
Pipeline is known as the artery of modern industry and human life, and circular welding is the basis of pipeline application, which has great influence on safeguarding national energy security, ensuring economic construction and residents' life.As the most vulnerable part of the pipeline, the weld is the key factor to determine the safe, effective and stable operation of the pipeline after completion, so it is particularly important to ensure the quality of the girth weld of the pipeline in service.With its low cost, high precision and good portability, ultrasonic testing technology has become an important means of girth weld quality evaluation.With the increasing mileage of global pipelines, the large-scale application of metal pipe network, the large-scale size and the complicated laying conditions make the girth weld detection a huge workload, and the task is more arduous and dangerous.The traditional manual detection technology has the problems of missed detection and low efficiency, which is difficult to meet the current development needs.As a key enabling technology to realize intelligent manufacturing, digital twin technology can be used to model and monitor the research object in real time.And through twin data analysis and simulation verification, intelligent decision-making such as state prediction and fault diagnosis is realized.In this paper, based on the inertial data of ultrasonic probe, the attitude and position of twin are driven and the moving path is drawn, which provides a theoretical basis for the digital twins of ultrasonic nondestructive testing in the future.

Inertial Data Preprocessing
In this paper, a high-performance miniature wireless transmission attitude sensor, LPMS-B2, is developed and produced by Japanese LP-RESEARCH Company and China Guangzhou Alubi Electronic Technology Co., Ltd., as shown in Figure 1.

Gyroscope calibration
In this paper, the field calibration method is used to calibrate the gyroscope initially.This method is easy to realize without the assistance of turntable and other equipment.Firstly, the error model of gyroscope data is established, and the actual measured value of gyroscope can be understood as the sum of zero drift, actual data and random error.The formula is as follows: Where w is the actual measured value of each axis of the gyroscope,  is the zero drift of each axis of the gyroscope, and  is the random error of each axis of the gyroscope.Gyroscope will produce inevitable zero drift according to the change of ambient temperature, and the subsequent data fusion algorithm will be constantly revised.Therefore, here is mainly zero drift correction for gyroscope.In the process of correction, the single-node sensor is stationary for 10 seconds after being turned on, and then the zero output value of the gyroscope is collected by the sensor for many times, and then the obtained data is averaged by formula (1) to obtain the zero drift value w_0 of the gyroscope, and finally it is brought into formula (2) to correct the gyroscope.

𝜔 ∑ 𝜔
Taking the Z axis as an example, the gyro calibration result is shown in Figure 2 (where the abscissa is the number of data samples, the ordinate is the gyro output value, BC is before calibration, and AC is after calibration).

Acceleration calibration
When the accelerometer is kept at rest, its theoretical value is only affected by the acceleration of gravity, that is, the three-axis measured value is the component of the acceleration of gravity in three axes, and the following formula can be obtained: Deterministic error mainly includes scale and deviation (scale bias: in theory, when there is no external effect, the output of accelerometer should only be affected by gravity acceleration, but in fact there will be a bias b in the data.The deviation scale can be regarded as the ratio between the actual value and the output value of the sensor) and the inter-axis error (due to the problem of hardware manufacturing process, the x-y, z-x and y-z axes are not vertical, that is, the inter-axis error).
Considering the inter-axis error, the relationship between the actual acceleration and the measured value is shown in Formula (4), where L is the actual acceleration, a is the measured acceleration value, b is the bias value, s is the scale value, and m is the inter-axis error.
Because the IMU used in this paper is a commercial product, the inter-axis error m can be ignored here, so the formula (4) can be simplified as follows: In the process of calibration, firstly, the accelerometer is placed on the desktop, then it is slowly turned over and each surface is kept for a period of time, and six data are measured respectively as the actual measured acceleration vector a; Then calculate the reference vector as follows: Then use the maximum and minimum measured values on each axis to get the offset of each axis, and the formula is as follows: Finally, the actual measured value L, formula (6) and formula (7) in the experiment are brought into the calibration model formula (5) and the calibration formula is obtained.
Because the error of accelerometer is only affected by its own hardware, it only needs to be corrected once.In this paper, X-axis calibration is taken as an example, and the calibration results are shown in Figure 3 below (BC before calibration and AC after calibration):

Pre-integration algorithm for IMU attitude solution
In this paper, a nine-axis IMU is used, and its integrated three sensors, namely gyroscope, accelerometer and magnetometer, can be fused to improve the measurement accuracy of the whole system.The main data fusion algorithms include Kalman filter and its derivatives [1][2][3], complementary filter [4][5], particle filter [6], optimizationbased method [7], etc.The data fusion algorithm used in this paper is Kalman algorithm.Because this paper has a complete circular motion, in order to avoid the singularity of Euler angle, quaternion is chosen as the attitude calculation method in this paper.
Quaternions were first invented by Sir William Rowan Hamilton [8] in 1843 as an extension of complex numbers.Any definite vector in three-dimensional space can be expressed as a rotation around a specific axis.As long as the rotation axis and rotation angle of the vector are given, it will be easy to represent quaternion or convert it from quaternion to other forms.
Complex numbers have real and imaginary parts, and similar quaternions consist of one real part and three imaginary parts.Three imaginary parts are closely related to the rotation axis, and the rotation angle affects four parts.A quaternion q can be defined in the following form: Where  is the imaginary part of quaternion and  is the real part.i, j and k are standard orthogonal bases of threedimensional space and satisfy the following formula: Because the data acquisition frequency of IMU is generally 100Hz or even 1000Hz, which is much higher than the frequency of Unity rendering animation processing function FixedUpdate, there will be redundant IMU measurement values between two frames of images rendered by animation, as shown in Figure 2-1.The common method is to use preintegration algorithm [9] to match the two and reduce repeated integration calculation.

Attitude simulation
After the probe model is imported into Unity 3D, a new Quaternion is mounted on the probe model through the transform.rotation component of Unity 3D, and the , , ,  quaternions after serial port processing are assigned to the virtual body of the probe, so that the attitude data can drive the attitude of the twin.The experimental results are shown in Figure 5 below:

Path simulation
Through the Acceleration mode in the AddForce function of Unity 3D, the calibrated acceleration data read by serial port is pre-integrated, and a DLL dynamic chain library with the external output frequency of 50Hz (the same as the frame rate of the FixedUpdate animation rendering function) is established.ax, ay and az are assigned to the virtual body of the probe by creating a new three-dimensional vector, so that the purpose of driving the twin by inertial data can be completed.The experimental results are shown in Figure 6 below.

Conclusion
(1) In this paper, the inertial sensor and the ultrasonic probe are tied and bridged, and the probe twin is driven by obtaining the inertial data of the probe, so as to map the actual motion state (attitude and acceleration) of the probe in real time.
(2) In the simulation process, the pre-integration algorithm is adopted for the acceleration data of inertial sensor, which makes the accuracy of displacement simulation of virtual body in Unity improved by 18.3% compared with that without pre-integration algorithm.

Figure 2 .
Figure 2. Comparison chart of gyroscope calibration results

Figure 3 .
Figure 3.Comparison chart of accelerometer calibration results

Figure 4 .
Figure 4. Schematic diagram of animation rendered image frames and IMU with different frequencies IMU pre-integration model is shown in the following formula (10)[10]:

Figure 5 .
Figure 5.Comparison of Unity 3D pose simulation results

Figure 6 .
Figure 6.The velocity-time diagram of acceleration integration during probe movement.