Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 9, No. 1, 2024 110 Research on Real‐time Simulation of Attitude and Path Based on Inertial Data of Probe Renjie Huang, Jun Li*, Junlong Wang, Ye Yuan, Chenchen Liu, Chen He College of Mechanical Engineering, Sichuan University of Science & Engineering, Yibing, 644000, China * Corresponding author Abstract: 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. Keywords: Unity, IMU, Digital twin, Ultrasonic detection. 1. 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. 2. 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. 2.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: Figure 1. IMU Physical image π‘Š π‘Š π‘Š 𝑀 𝑀 𝑀 𝑀 𝑀 𝑀 𝑣 𝑣 𝑣 (1) 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. πœ” βˆ‘ β€Š πœ” (2) 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). 111 Figure 2. Comparison chart of gyroscope calibration results 2.2. 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: π‘Žπ‘π‘ π‘Žπ‘π‘ π‘Žπ‘π‘ g (3) 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. 𝑙 𝑙 𝑙 𝑠 π‘š π‘š π‘š 𝑠 π‘š π‘š π‘š 𝑠 π‘Ž π‘Ž π‘Ž 𝑏 𝑏 𝑏 (4) 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: 𝑙 𝑙 𝑙 𝑠 0 0 0 𝑠 0 0 0 𝑠 π‘Ž π‘Ž π‘Ž 𝑏 𝑏 𝑏 (5) 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: 𝑙 ⎣ ⎒ ⎒ ⎒ ⎒ ⎑ g 0 0 g 0 0 0 g 0 0 g 0 0 0 g 0 0 g⎦ βŽ₯ βŽ₯ βŽ₯ βŽ₯ ⎀ (6) Then use the maximum and minimum measured values on each axis to get the offset of each axis, and the formula is as follows: 𝑏 (7) 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): Figure 3. Comparison chart of accelerometer calibration results 3. 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-3], complementary filter[4-5], particle filter[6], optimization- based 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: π‘ž π‘ž , π‘ž π‘–π‘ž π‘—π‘ž π‘˜π‘ž π‘ž π‘ž π‘ž (8) Where π‘ž is the imaginary part of quaternion and π‘ž is the real part. i, j and k are standard orthogonal bases of three- dimensional space and satisfy the following formula: 112 𝑖 𝑗 π‘˜ 1 (9) 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 pre- integration algorithm[9] to match the two and reduce repeated integration calculation. 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]: ⎩ βŽͺ ⎨ βŽͺ βŽ§Ξ”π‘… Exp 𝐽 𝛿𝑏 𝑅 𝑅 Exp π›Ώπœ™ Δ𝑣 𝐽 𝛿𝑏 𝐽 𝛿𝑏 𝑅 𝑣 𝑣 𝑔Δ𝑑 𝛿𝑣 Ξ”οΏ½Μ‚οΏ½ 𝐽 𝛿𝑏 𝐽 𝛿𝑏 𝑅 𝑝 𝑝 𝑣 Δ𝑑 𝑔Δ𝑑 𝛿𝑝 (10) In der Formel, Δ𝑅 𝑏 is abbreviated as Δ𝑅 , Δ𝑣 𝑏 , 𝑏 is abbreviated as Δ𝑣 , Ξ”οΏ½Μ‚οΏ½ 𝑏 , 𝑏 is abbreviated as Ξ”οΏ½Μ‚οΏ½ . 4. Unity Simulation Results 4.1. 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: Figure 5. Comparison of Unity 3D pose simulation results 4.2. 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. Figure 6. The velocity-time diagram of acceleration integration during probe movement. 5. 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. References [1] Ligorio G, Sabatini A M. A novel Kalman filter for human motion tracking with an inertial-based dynamic inclinometer[J]. IEEE Transactions on Biomedical Engineering, 2015, 62(8): 2033-2043. [2] Xu C, He J, Zhang X, et al. Geometrical kinematic modeling on human motion using method of multi-sensor fusion[J]. Information Fusion, 2018, 41: 243-254. [3] Taunyazov T, Omarali B, Shintemirov A. A novel low-cost 4- DOF wireless human arm motion tracker[C]//2016 6th IEEE International Conference on Biomedical Robotics and Biomechatronics (BioRob). IEEE, 2016: 157-162. [4] Atrsaei A, Salarieh H, Alasty A, et al. Human arm motion tracking by inertial/magnetic sensors using unscented Kalman filter and relative motion constraint[J]. Journal of Intelligent & Robotic Systems, 2018, 90: 161-170. [5] El-Gohary M, McNames J. Human joint angle estimation with inertial sensors and validation with a robot arm[J]. IEEE Transactions on Biomedical Engineering, 2015, 62(7): 1759- 1767. [6] El-Gohary M, McNames J. Human joint angle estimation with inertial sensors and validation with a robot arm[J]. IEEE 113 Transactions on Biomedical Engineering, 2015, 62(7): 1759- 1767. [7] Fourati H, Manamanni N, Afilal L, et al. A nonlinear filtering approach for the attitude and dynamic body acceleration estimation based on inertial and magnetic sensors: Bio-logging application[J]. IEEE Sensors Journal, 2010, 11(1): 233-244. [8] Tian Y, Wei H, Tan J. An adaptive-gain complementary filter for real-time human motion tracking with MARG sensors in free-living environments[J]. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 2012, 21(2): 254-264. [9] Hsu Y L, Wang J S, Lin Y C, et al. A wearable inertial-sensing- based body sensor network for shoulder range of motion assessment[C]//2013 1st International Conference on Orange Technologies (ICOT). IEEE, 2013: 328-331. [10] Tao Y, Hu H. A novel sensing and data fusion system for 3-D arm motion tracking in telerehabilitation[J]. IEEE Transactions on Instrumentation and Measurement, 2008, 57(5): 1029-1040.