A Fuzzy Tuned and Second Estimator of the Optimal Quaternion Complementary Filter for Human Motion Measurement with Inertial and Magnetic Sensors

To accurately measure human motion at high-speed, we proposed a simple structure complementary filter, named the Fuzzy Tuned and Second EStimator of the Optimal Quaternion Complementary Filter (FTECF). The FTECF is applicable to inertial and magnetic sensors, which include tri-axis gyroscopes, tri-axis accelerometers, and tri-axis magnetometers. More specifically, the proposed method incorporates three parts, the input quaternion, the reference quaternion, and the fuzzy logic algorithm. At first, the input quaternion was calculated with gyroscopes. Then, the reference quaternion was calculated by applying the Second EStimator of the Optimal Quaternion (ESOQ-2) algorithm on accelerometers and magnetometers. In addition, we added compensation for accelerometers in the ESOQ-2 algorithm so as to eliminate the effects of limb motion acceleration in high-speed human motion measurements. Finally, the fuzzy logic was utilized to calculate the fusion factor for a complementary filter, so as to adaptively fuse the input quaternion with the reference quaternion. Additionally, the overall algorithm design is more simplified than traditional methods. Confirmed by the experiments, using a commercial inertial and magnetic sensors unit and an optical motion capture system, the efficiency of the proposed method was more improved than two well-known methods. The root mean square error (RMSE) of the FTECF was less than 2.2° and the maximum error was less than 5.4°.


Introduction
Human motion measurement is a key technology in rehabilitation, gait analysis, man-machine interaction, virtual reality, and other fields [1][2][3][4]. There are numerous kinds of human motion measurement techniques such as mechanical, magnetic, optical, acoustic, and inertial/magnetic. Most of these techniques require emissions from a source so as to track objects [5]. The magnetic measurement technique requires a self-excited stable magnetic field. The ultrasonic measurement technique needs to transmit ultrasonic waves. The optical measurement technique requires light to illuminate objects. However, no self-emission source is required for the inertial/magnetic measurement technique.
Motion measurement using inertial and magnetic sensors is a relatively new technique, which has received wide attention in recent years [4]. The inertial/magnetic measurement technique often uses a combination of micro-electromechanical system (MEMS) gyroscopes, accelerometers, and magnetometers, called magnetic, angular rate, and gravity (MARG) sensors [6]. MEMS sensors are usually low-cost, small in size, and can be manufactured into a wrist watch size [4], which is In this paper, we studied the generic limb posture measurement, which can be applied to all major limbs of the body. The upper limb movement is more agile and flexible than the other body limbs [9]. By convention, we chose the upper limb as the main research object [3,4,6,9,10]. In the upper limb, the more flexible upper arm movement was selected for detailed study.
The definition of the coordinate frames involved in the upper arm is illustrated in Figure 2. For the upper arm and MARG sensors, the coordinate frame was defined as B and S, respectively. In addition, the reference coordinate frame mounted on the earth was also defined as E. The definitions of the coordinate frames. E is the reference coordinate frame, which is mounted on the earth; B is the coordinate frame of the upper arm; S is the coordinate frame of the magnetic, angular rate, and gravity (MARG) sensor.
The reference coordinate for frame E is defined according to the orientation of the human body at the beginning of the measurement. The origin of the reference coordinate frame is in the vicinity of the human body in space. The directions of the three axes are defined as the Z-axis (upward in the direction of the gravity vector), the X-axis (pointing to the right of the body), and the Y-axis (pointing to the front of the body), which follow the right-handed coordinate system. Once the reference coordinate frame is defined, it is fixed in the space and does not change with the movement of the human body.
The coordinate of frame B is fixed to the human skeleton, and the origin can be set along the skeleton, usually at the rotation center of the limb. The T-pose is where the arms are straight forward, with the palms facing down and the thumb pointing straight ahead [14]. The upper arm coordinate frame and the reference coordinate frame maintain the same direction at the T-pose, and can be transformed into each other through a translation in space [10].
The origin of the coordinate of frame S is at the center of the three axes of the accelerometer, axially along the housing of the MARG sensors, and the directions of the three axes follow the right-handed coordinate system. The data output of each sensor is represented in the corresponding sensor coordinate frame. In this paper, we studied the generic limb posture measurement, which can be applied to all major limbs of the body. The upper limb movement is more agile and flexible than the other body limbs [9]. By convention, we chose the upper limb as the main research object [3,4,6,9,10]. In the upper limb, the more flexible upper arm movement was selected for detailed study.
The definition of the coordinate frames involved in the upper arm is illustrated in Figure 2. For the upper arm and MARG sensors, the coordinate frame was defined as B and S, respectively. In addition, the reference coordinate frame mounted on the earth was also defined as E. In this paper, we studied the generic limb posture measurement, which can be applied to all major limbs of the body. The upper limb movement is more agile and flexible than the other body limbs [9]. By convention, we chose the upper limb as the main research object [3,4,6,9,10]. In the upper limb, the more flexible upper arm movement was selected for detailed study.
The definition of the coordinate frames involved in the upper arm is illustrated in Figure 2. For the upper arm and MARG sensors, the coordinate frame was defined as B and S, respectively. In addition, the reference coordinate frame mounted on the earth was also defined as E. The definitions of the coordinate frames. E is the reference coordinate frame, which is mounted on the earth; B is the coordinate frame of the upper arm; S is the coordinate frame of the magnetic, angular rate, and gravity (MARG) sensor.
The reference coordinate for frame E is defined according to the orientation of the human body at the beginning of the measurement. The origin of the reference coordinate frame is in the vicinity of the human body in space. The directions of the three axes are defined as the Z-axis (upward in the direction of the gravity vector), the X-axis (pointing to the right of the body), and the Y-axis (pointing to the front of the body), which follow the right-handed coordinate system. Once the reference coordinate frame is defined, it is fixed in the space and does not change with the movement of the human body.
The coordinate of frame B is fixed to the human skeleton, and the origin can be set along the skeleton, usually at the rotation center of the limb. The T-pose is where the arms are straight forward, with the palms facing down and the thumb pointing straight ahead [14]. The upper arm coordinate frame and the reference coordinate frame maintain the same direction at the T-pose, and can be transformed into each other through a translation in space [10].
The origin of the coordinate of frame S is at the center of the three axes of the accelerometer, axially along the housing of the MARG sensors, and the directions of the three axes follow the right-handed coordinate system. The data output of each sensor is represented in the corresponding sensor coordinate frame. The definitions of the coordinate frames. E is the reference coordinate frame, which is mounted on the earth; B is the coordinate frame of the upper arm; S is the coordinate frame of the magnetic, angular rate, and gravity (MARG) sensor.
The reference coordinate for frame E is defined according to the orientation of the human body at the beginning of the measurement. The origin of the reference coordinate frame is in the vicinity of the human body in space. The directions of the three axes are defined as the Z-axis (upward in the direction of the gravity vector), the X-axis (pointing to the right of the body), and the Y-axis (pointing to the front of the body), which follow the right-handed coordinate system. Once the reference coordinate frame is defined, it is fixed in the space and does not change with the movement of the human body.
The coordinate of frame B is fixed to the human skeleton, and the origin can be set along the skeleton, usually at the rotation center of the limb. The T-pose is where the arms are straight forward, with the palms facing down and the thumb pointing straight ahead [14]. The upper arm coordinate frame and the reference coordinate frame maintain the same direction at the T-pose, and can be transformed into each other through a translation in space [10].
The origin of the coordinate of frame S is at the center of the three axes of the accelerometer, axially along the housing of the MARG sensors, and the directions of the three axes follow the right-handed coordinate system. The data output of each sensor is represented in the corresponding sensor coordinate frame. For the sake of simplicity, we assumed that there was no relative displacement between the sensor and the upper arm, so the sensor coordinate frame and upper arm coordinate frame were considered to be identical. That is, the two frames had the same orientation, but with a different displacement.

Representation
The upper arm's movement information can be represented with Euler angles or quaternions [3]. This paper used the quaternion to calculate the rotational movement of the limb, and converted the quaternion into Euler angles for visual representation. The advantage of the Euler angles representation method is that it can intuitively represent a rotation. However, the Euler angles representation method is prone to the gimbal lock problem, resulting in the appearance of singularities. In contrast, the quaternion representation method can avoid the occurrence of singularities, and is more computationally efficient. In addition, the quaternion can be transformed with the attitude matrix and Euler angles [15].
where q E B denotes the quaternion from the upper arm coordinate frame, B, to the reference coordinate frame, E, which is calculated based on the gyroscope measurement. ω B = 0 ω T B represents a four-element column vector, and ω B = ω B,x ω B,y ω B,z is the measured value of the triaxial gyro in the upper arm coordinate frame.
We can express a quaternion as follows: Then, Equation (1) can be written as a matrix as follows: If the gyroscope output, ω B,t , and the fused quaternion, q E t−∆t , are known, then we can obtain the input quaternion as follows: where ∆t is the sampling time.
The motion of the upper arm can be represented by Euler angles (pitch-roll-yaw), as in Figure 3. The pitch angle is a rotation angle with respect to the X-axis of the coordinate frame, E. Similarly, we can define the roll angle and the yaw angle.

Motion Speed
The maximum movement frequency of the upper arm of the human body is about 3.7 times per second [16], therefore, it is difficult for a person to maintain long-term high-speed movements. In this study, we choose two representative human motion speeds, namely: 0.5 movements per second (0.5 mov/s) and 2 movements per second (2 mov/s), representing human low-speed motion and human high-speed motion, respectively.

Description of the Proposed Algorithm
We proposed a complementary filter algorithm based on fuzzy logic and the ESOQ-2 algorithm. The block diagram of the algorithm is shown in Figure 4. The ESOQ-2 algorithm calculates the reference quaternion with accelerometers and magnetometers. The reference quaternion has a more precise dynamic response at a low frequency. In contrast, the input quaternion calculated by gyroscopes has a more precise dynamic response in high frequency. In this paper, a complementary filter fused the reference quaternion and input quaternion, and the conversion frequency was tuned by fuzzy logic.

Motion Speed
The maximum movement frequency of the upper arm of the human body is about 3.7 times per second [16], therefore, it is difficult for a person to maintain long-term high-speed movements. In this study, we choose two representative human motion speeds, namely: 0.5 movements per second (0.5 mov/s) and 2 movements per second (2 mov/s), representing human low-speed motion and human high-speed motion, respectively.

Description of the Proposed Algorithm
We proposed a complementary filter algorithm based on fuzzy logic and the ESOQ-2 algorithm. The block diagram of the algorithm is shown in Figure 4. The ESOQ-2 algorithm calculates the reference quaternion with accelerometers and magnetometers. The reference quaternion has a more precise dynamic response at a low frequency. In contrast, the input quaternion calculated by gyroscopes has a more precise dynamic response in high frequency. In this paper, a complementary filter fused the reference quaternion and input quaternion, and the conversion frequency was tuned by fuzzy logic.

Motion Speed
The maximum movement frequency of the upper arm of the human body is about 3.7 times per second [16], therefore, it is difficult for a person to maintain long-term high-speed movements. In this study, we choose two representative human motion speeds, namely: 0.5 movements per second (0.5 mov/s) and 2 movements per second (2 mov/s), representing human low-speed motion and human high-speed motion, respectively.

Description of the Proposed Algorithm
We proposed a complementary filter algorithm based on fuzzy logic and the ESOQ-2 algorithm. The block diagram of the algorithm is shown in Figure 4. The ESOQ-2 algorithm calculates the reference quaternion with accelerometers and magnetometers. The reference quaternion has a more precise dynamic response at a low frequency. In contrast, the input quaternion calculated by gyroscopes has a more precise dynamic response in high frequency. In this paper, a complementary filter fused the reference quaternion and input quaternion, and the conversion frequency was tuned by fuzzy logic.  In order to analyze the complementary filter, we performed a Laplace transform (s is the Laplace operator) on q m , . q gyr , andq. As shown in Figure 5, q m (s) is the Laplace transformation (LT) of q m , and sq gry (s) denotes the LT of . q gyr . F 1 (s) and F 2 (s) are two transfer functions and F 1 (s) + F 2 (s) = 1 [5].
In Equation (7), 1 () Fs is equivalent to a low-pass filter and can filter out the high-frequency noise of the reference quaternion. 2

()
Fs is equivalent to a high-pass filter, and can filter out the low frequency noise of the input quaternion. The conversion frequency of the complementary filter is c f , in Equation (8), and can be adjusted by varying the filter gain, K [17].
The output of the complementary filter in the time domain in Figure 4 is as follows: By applying Equation (4) to Equation (9), we get the following [6]: ,0 1.
, by using Equation (8) and it can be seen from Equation (11) where τ = 1 K . In Equation (7), F 1 (s) is equivalent to a low-pass filter and can filter out the high-frequency noise of the reference quaternion. F 2 (s) is equivalent to a high-pass filter, and can filter out the low frequency noise of the input quaternion. The conversion frequency of the complementary filter is f c , in Equation (8), and can be adjusted by varying the filter gain, K [17].
The output of the complementary filter in the time domain in Figure 4 is as follows: By applying Equation (4) to Equation (9), we get the following [6]: where µ t = K∆t 1+2π f c ∆t , by using Equation (8) and f c ∝ µ t . Therefore, it can be seen from Equation (11) that tuning the fusion factor, µ t , can change the conversion frequency, f c , of the complementary filter. When µ t increases, f c correspondingly increases. At this time, the complementary filter output is more biased toward the reference quaternion, q E m,t . Similarly, when µ t decreases, f c decreases correspondingly, and the complementary filter is more biased to the input quaternion, q E gry,t . To prevent the quaternion from being non-orthogonal, we performed orthogonalization on it. We calculated the reference quaternion by using the ESOQ-2 algorithm. The ESOQ-2 algorithm has been proposed for the Wahba problem [18]. The Wahba problem is used to estimate the attitudes of a body in the least-squares sense, by using the vector's reference values and the corresponding measurement values, as shown in Equation (13).
where α i represents the relative weight of the observation vector (∑ i α i = 1, i = 1 ∼ n). The weight is related to the data credibility of the ith observation vector.
In Equation (13), r is the n-dimensional vector defined in the reference coordinate frame, b is the corresponding vector definition in the body coordinate, and A is the attitude matrix from r to b. In this paper, n is 2, r represents the gravity vector and geomagnetic field vector defined in the reference coordinate frame, and b represents the accelerometer and magnetometer measurement vector. Assuming that in the quasi-static condition (limb motion acceleration is negligible when compared to gravitational acceleration) the magnetic field is not distorted, the attitude measurement in this paper was used to determine the body posture through the reference and measurement values of the gravity vector and the geomagnetic field vector.
The q-method demonstrates that the optimal quaternion, q opt , is the eigenvector with the largest eigenvalue of the 4 × 4 symmetric matrix K [19], Therefore, as long as the eigenvector with the largest eigenvalue of matrix K is obtained, the optimal attitude quaternion can be obtained.
The procedure for the ESOQ-2 algorithm is as follows: (1) Calculate the structure matrix where B = ∑ i α i b i r T i is the attitude profile matrix, I 3×3 is the 3 × 3 unit matrix, and z is the vector (2) Calculate the maximum eigenvalue of the approximated matrix K Thus, the direction of the optimal quaternion is obtained by normalizing q, that is, q opt = q/ q T q.
(4) Avoid singularity adjustment For the singularity problem that this method may produce, the specific details of the solution are in the literature [19].
In this paper, the gravity vector is expressed as g = 0 0 9.78 T , assuming that the local geomagnetic vector modulus is h, and the declination angle of the local geomagnetic vector is ε. When the X-axis of the reference coordinate frame points to the east and the Y-axis points to the north, the geomagnetic vector can be expressed as m = 0 h cos ε h sin ε T .

Compensation for the Accelerator
The quasi-static condition in the ESOQ-2 algorithm is rare in human motion. Therefore, we needed to compensate the accelerator in order to handle a high dynamic movement. Because of the acceleration of the limb movement, the accelerometer output is the combination of the gravity acceleration and the motion acceleration. In this case, the input quaternion is more reliable, so we replaced the accelerometer's output with the gravitational acceleration vector calculated with the input quaternion. Based on the aforementioned concept, the input vectors, f, (gravity-related) for the ESOQ-2 algorithm were calculated using the following equations: gyr,3 2 q gyr,1 q gyr,2 + q gyr,0 q gyr,3 2 q gyr,1 q gyr,3 − q gyr,0 q gyr,2 2 q gyr,1 q gyr,2 − q gyr,0 q gyr,3 q 2 gyr,0 − q 2 gyr,1 + q 2 gyr,2 − q 2 gyr,3 2 q gyr,2 q gyr,3 + q gyr,0 q gyr,1 2 q gyr,1 q gyr,3 + q gyr,0 q gyr,2 2 q gyr,2 q gyr,3 − q gyr,0 q gyr,1 q 2 gyr,0 − q 2 gyr,1 − q 2 gyr,2 + q 2 where f m,t = f mx,t f mx,t f mx,t is the accelerometer triaxial output data, and ω b,t is the gyroscope triaxial output data. C B E represents the attitude transformation matrix from the reference coordinate frame (E) to the sensor coordinate frame (S) and the upper arm coordinate frame (B), assuming that the latter two coordinate frames are consistent in direction. q gyr = q gyr,0 q gyr,1 q gyr,2 q gyr,3 is the input quaternion. δ a and δ w are the corresponding thresholds for acceleration and angular velocity, respectively.

Quaternion Fusion Factor
In this paper, fuzzy logic was used to generate the fusion factor for the reference quaternion and the input quaternion. As a fuzzy input, e1 can be calculated as Equation (21), as follows: where the quaternion differential value, . q gyr , is calculated from the gyroscope output. In addition, ξ represents the minimum value of the angular velocity differential mode value . q E gyr under normal human motion, which can be obtained through simple experiments.
The specific steps for designing a fuzzy controller are as follows [20]: (1) Fuzzification That is, a fuzzy set is used to represent real-valued signals. This paper used a single-valued method. (2) Establish fuzzy inference rules In this part, e1 is the fuzzy input, and u is the fuzzy output. The fuzzy output, u, was µ t in the paper. From Equation (21), we can see that when the acceleration of the line motion was large, . q gyr increased and e1 decreased. According to Equation (11), µ t should be tuned to be smaller, as the quaternion calculated by the gyroscope is more reliable. On the contrary, when the linear motion acceleration is small, . q gyr decreased and e1 increased. Therefore, µ t should be tuned to be larger. The rules of the fuzzy inference are set according to the aforementioned principles in Table 1. (3) Determine the weights and rule reliability In practice, it is important to establish the relationship between the weights of the fuzzy rules and the reliability of the fuzzy rules in the knowledge base. There is a reversible mapping between the weights and the corresponding fuzzy rule confidence vectors.

(4) Choose the appropriate relationship generation method and inference synthesis algorithm
The selection of appropriate relationship generation methods and inference synthesis algorithms is required when designing a fuzzy controller. This article used the Z-shaped membership function and the S-shaped membership function in the MATLAB fuzzy toolbox. The fuzzy membership functions designed based on the fuzzy inference rules and rule reliability are shown in Figure 6. When the output of an inference process forms a fuzzy output set, it is necessary to compress its distribution in order to produce a single value that expresses the output of the fuzzy system, that is, anti-blurring. This study used the maximum membership degree average method.

Experimental Results and Discussion
In this section, we consider the experimental testbed and evaluate the performance of the proposed FTECF method at different test times and motion speeds. We also compare the FTECF with two other methods in terms of accuracy and structure, so as to further evaluate its performance.
To verify the proposed algorithm, we used the MARG sensors named MTi-3 [21]. MTi-3 is produced by Xsens Technologies (Enschede, The Netherlands). Figure 7a shows that we bound MTi-3 to the subject's right upper arm to measure its motion. All of the sensor signals were sampled at 100 Hz and were interfaced to a personal computer (PC) via a universal serial bus (USB) cable. The accompanying software MT manager provided the calibrated sensor measurements. An Oqus 7+ optical motion capture system (Qualisys, Göteborg, Sweden), shown in Figure 7b, provided the reference orientation, which captures motion by using passive reflective technology with three

(5) Defuzzification
When the output of an inference process forms a fuzzy output set, it is necessary to compress its distribution in order to produce a single value that expresses the output of the fuzzy system, that is, anti-blurring. This study used the maximum membership degree average method.

Experimental Results and Discussion
In this section, we consider the experimental testbed and evaluate the performance of the proposed FTECF method at different test times and motion speeds. We also compare the FTECF with two other methods in terms of accuracy and structure, so as to further evaluate its performance.
To verify the proposed algorithm, we used the MARG sensors named MTi-3 [21]. MTi-3 is produced by Xsens Technologies (Enschede, The Netherlands). Figure 7a shows that we bound MTi-3 to the subject's right upper arm to measure its motion. All of the sensor signals were sampled at 100 Hz and were interfaced to a personal computer (PC) via a universal serial bus (USB) cable. The accompanying software MT manager provided the calibrated sensor measurements. An Oqus 7+ optical motion capture system (Qualisys, Göteborg, Sweden), shown in Figure 7b, provided the reference orientation, which captures motion by using passive reflective technology with three cameras [22]. The spatial positioning accuracy of Oqus 7+ is less than 1 mm, and the latency time is less than 4 ms.

Experimental Results and Discussion
In this section, we consider the experimental testbed and evaluate the performance of the proposed FTECF method at different test times and motion speeds. We also compare the FTECF with two other methods in terms of accuracy and structure, so as to further evaluate its performance.
To verify the proposed algorithm, we used the MARG sensors named MTi-3 [21]. MTi-3 is produced by Xsens Technologies (Enschede, The Netherlands). Figure 7a shows that we bound MTi-3 to the subject's right upper arm to measure its motion. All of the sensor signals were sampled at 100 Hz and were interfaced to a personal computer (PC) via a universal serial bus (USB) cable. The accompanying software MT manager provided the calibrated sensor measurements. An Oqus 7+ optical motion capture system (Qualisys, Göteborg, Sweden), shown in Figure 7b, provided the reference orientation, which captures motion by using passive reflective technology with three cameras [22]. The spatial positioning accuracy of Oqus 7+ is less than 1 mm, and the latency time is less than 4 ms.  In the experiment, the subject swung his upper arm according to the procedure of Figure 8. First, the subject stretched his upper arm and remained stationary at the T-pose for about 10 s, in order to calculate the initial position. Then, the subject swung his upper arm in the order of roll-pitch-yaw, and subsequently repeated the motion for about 55 s in the same order. As shown in Figure 8, we referred to the entire experiment as the 110 s test, and the approximately one-minute portion of the 110 s test as the 55 s test. By comparing the results of the two tests, we could conclude the influence of time on the algorithm. In addition, two motion speeds were mentioned in Section 2.3. In order to study the performance of the proposed algorithm at different motion speeds, we performed three trials for each speed. In the experiment, the subject swung his upper arm according to the procedure of Figure 8. First, the subject stretched his upper arm and remained stationary at the T-pose for about 10 s, in order to calculate the initial position. Then, the subject swung his upper arm in the order of roll-pitch-yaw, and subsequently repeated the motion for about 55 s in the same order. As shown in Figure 8, we referred to the entire experiment as the 110 s test, and the approximately one-minute portion of the 110 s test as the 55 s test. By comparing the results of the two tests, we could conclude the influence of time on the algorithm. In addition, two motion speeds were mentioned in Section 2.3. In order to study the performance of the proposed algorithm at different motion speeds, we performed three trials for each speed. Two other algorithms, Madgwick's method [11] and Yun's method [4], were used to compare the proposed FTECF method. In order to verify the orientation estimation accuracy, the root mean square error (RMSE) value of the Euler angles from the quaternion-based orientation was chosen as the criterion to evaluate the performance of the proposed FTECF method [4][5][6]10]. The calculation formula is as follows: Two other algorithms, Madgwick's method [11] and Yun's method [4], were used to compare the proposed FTECF method. In order to verify the orientation estimation accuracy, the root mean square error (RMSE) value of the Euler angles from the quaternion-based orientation was chosen as the criterion to evaluate the performance of the proposed FTECF method [4][5][6]10]. The calculation formula is as follows: where β obs indicates the Euler angles calculated by the FTECF or other methods, the Euler angles, β tru , are the reference attitudes, and n indicates the number of calculations. Note that Yun's method was assumed in the quasi-static state, which means that the acceleration of motion is small relative to the acceleration of gravity. The experiment obviously did not meet this assumption. We performed Equations (18) and (19) on the QUEST algorithm in Yun's method (similar to the ESOQ-2 algorithm in this paper, which uses a gravitational acceleration vector and a geomagnetic vector to determine the attitudes).
The relevant parameter of the fuzzy tuned algorithm was selected as ξ = 0.0006325. The corresponding thresholds for acceleration and angular velocity were δ a = 0.1 m/s 2 and δ w = 10 • /s, respectively. g and h were selected as 9.78 m/s 2 and 0.6 Gauss, respectively.
The declination angle of the local geomagnetic vector ε was −58 • .

The Effect of Motion Speed and Test Time on the Proposed FTECF
We plotted the typical measurements of the proposed FTECF at two motion speeds. Figures 9 and 10 are the typical measurement results of FTECF at 0.5 mov/s and 2 mov/s, respectively. In Figures 9a and 10a, the red solid lines indicate the Euler angles measured by the optical motion capture system, and the blue dotted lines indicate the Euler angles calculated by the FTECF. The blue lines in Figures 9b and 10b indicate the angle errors calculated by Equation (22). As can be seen from Figures 9b and 10b, in terms of the fluctuation of the error, yaw was the largest, pitch was second, and roll was the smallest. In addition, the results showed that the proposed FTECF maintained a RMSE within a certain range of accuracy.   Figure 11 shows the RMSE of the FTECF under four different test conditions. In Figure 11, the blue bars indicate the RMSE of the FTECF at the 0.5 mov/s, 55 s test condition. The meaning of the red, yellow, and purple bars can be inferred from the legend. In order to obtain the influence of the motion speed on the proposed algorithm, we compared the blue and yellow bars with a test time of 55 s, and the red and purple bars with a test time of 110 s. The results show that yaw had a smaller RMSE at higher motion speeds, while pitch and roll changed less at different motion speeds when compared with yaw. Similarly, in terms of the influence of test time on the proposed algorithm, we compared the blue and red bars with a motion speed of 0.5 mov/s, and the yellow and purple bars with a motion speed of 2 mov/s. From Figure 11, we can see that the three Euler angles showed a small change at different test times.  Figure 11 shows the RMSE of the FTECF under four different test conditions. In Figure 11, the blue bars indicate the RMSE of the FTECF at the 0.5 mov/s, 55 s test condition. The meaning of the red, yellow, and purple bars can be inferred from the legend. In order to obtain the influence of the motion speed on the proposed algorithm, we compared the blue and yellow bars with a test time of 55 s, and the red and purple bars with a test time of 110 s. The results show that yaw had a smaller RMSE at higher motion speeds, while pitch and roll changed less at different motion speeds when compared with yaw. Similarly, in terms of the influence of test time on the proposed algorithm, we compared the blue and red bars with a motion speed of 0.5 mov/s, and the yellow and purple bars with a motion speed of 2 mov/s. From Figure 11, we can see that the three Euler angles showed a small change at different test times.

Compare the Proposed FTECF and the Other Two Methods
To compare the performances of the proposed FTECF and the other two methods, we listed each of the Euler angle's maximum RMSE from each method, as shown in Table 2. We also listed the maximum errors of each method. The maximum RMSE of each method and the smallest maximum error of the three methods are in bold.  Table 2 shows that the maximum RMSE of the FTECF was less than 2.2°, and the maximum error was less than 5.4°. In addition, the RMSE of the pitch and roll of the FTECF were also smaller

Compare the Proposed FTECF and the Other Two Methods
To compare the performances of the proposed FTECF and the other two methods, we listed each of the Euler angle's maximum RMSE from each method, as shown in Table 2. We also listed the maximum errors of each method. The maximum RMSE of each method and the smallest maximum error of the three methods are in bold. Table 2 shows that the maximum RMSE of the FTECF was less than 2.2 • , and the maximum error was less than 5.4 • . In addition, the RMSE of the pitch and roll of the FTECF were also smaller than the other two methods, while the RMSE of the yaw was slightly larger than that in Madgwick's method.
The proposed FTECF found a balance between high precision and simple structure. Compared with the Kalman filter algorithm represented by Yun's method, the proposed method needed lower calculation costs and adapted well to high-speed human motion. The gradient descent algorithm represented by Madgwick's method was also simple in structure. However, the proposed method had a higher precision than Madgwick's method.

Conclusions
In this paper, we proposed a complementary filter, based on fuzzy logic and the ESOQ-2 algorithm, for human motion measurement. Firstly, the proposed method was effective at handling high dynamic movement with the fuzzy tuned algorithm and the compensation of the accelerator. The proposed algorithm did not accumulate errors under either 55 s and 110 s of measurement, indicating that it had the potential for long-term human motion measurement. Secondly, the RMSE of the proposed FTECF was less than 2.2 • , which was comparable to the other two methods. In summary, this paper demonstrated the different speed motion measurements of the human upper arm by using the proposed method, and the results also illustrated its high accuracy.
Due to its high accuracy and computational efficiency, the proposed algorithm can be potentially implemented in a network of miniature MARG sensors for human body motion, forming a truly portable and ambulatory motion measurement system. The motion measurement system can be used in patient rehabilitation and behavioral monitoring. Future work will further study the influence of magnetic interference on the proposed algorithm. The complexity of the algorithm and the measurement effect for a longer time will also be studied. In addition, we will study the joint orientation assessment when the sensors are used in combination.
Author Contributions: X.Z. and W.X. conceived and designed the experiments; W.X. performed the experiments; X.Z. and W.X. wrote and approved the manuscript.
Funding: As part of the research project, this work was supported by the National Natural Science Foundation of China (61703024).