Quaternion-Based Local Frame Alignment between an Inertial Measurement Unit and a Motion Capture System

Local frame alignment between an inertial measurement unit (IMU) system and an optical motion capture system (MCS) is necessary to combine the two systems for motion analysis and to validate the accuracy of IMU-based motion data by using references obtained through the MCS. In this study, we propose a new quaternion-based local frame alignment method where equations of angular velocity transformation are used to determine the frame alignment orientation in the form of quaternion. The performance of the proposed method was compared with those of three other methods by using data with different angular velocities, noises, and alignment orientations. Furthermore, the effects of the following three factors on the estimation performance were investigated for the first time: (i) transformation concept, i.e., angular velocity transformation vs. angle transformation; (ii) orientation representations, i.e., quaternion vs. direction cosine matrix (DCM); and (iii) applied solvers, i.e., nonlinear least squares method vs. least squares method through pseudoinverse. Within our limited test data, we obtained the following results: (i) the methods using angular velocity transformation were better than the method using angle transformation; (ii) the quaternion is more suitable than the DCM; and (iii) the applied solvers were not critical in general. The proposed method performed the best among the four methods. We surmise that the fewer number of components and constraints of the quaternion in the proposed method compared to the number of components and constraints of the DCM-based methods may result in better accuracy. Owing to the high accuracy and easy setup, the proposed method can be effectively used for local frame alignment between an IMU and a motion capture system.


Introduction
Recent advances in micro-electro-mechanical systems (MEMS) technology, as well as mobile and ubiquitous computing, have fostered considerable amount of interest in the inertial measurement unit (IMU) as a wearable motion sensor [1][2][3]. A typical IMU consists of a tri-axial accelerometer and a tri-axial gyroscope that measure the linear acceleration and angular velocity of the unit, respectively, with respect to the local frame fixed to the unit. Since the wearable IMUs can overcome limited working volume issue and occlusion problem of typical camera-based measurements, they have tremendous benefits for various applications such as the practice of physical medicine and rehabilitation [4][5][6] and motion reconstruction for computer animation productions [7][8][9][10][11][12][13].
Even if IMUs have great potential as motion tracking sensors, position and orientation information, which are required in motion analysis, are not directly provided by IMUs. Instead, the information has

Related Works
Recently, this issue was discussed in a few research studies [20][21][22]. De Vries et al. [20] introduced a method for the local frame alignment of an IMU with an MCS in the appendix of [20]. This method is based on the fact that angular velocities expressed in the IMU frame are transformed to those expressed in the MCS frame by pre-multiplying the constant alignment rotation matrix or direction cosine matrix (DCM) of the IMU frame with respect to the MCS frame. However, since the research in [20] focused on the evaluation of the effect of magnetic distortion on IMU applications, the performance of the alignment method was not evaluated.
Chardonnens et al. [21] proposed another alignment method using the gyroscopic angles of the two frames by time-integrating the angular velocity measurements. Then, the alignment DCM between the IMU and MCS frames was determined by a frame transformation equation as in [20]. A nonlinear least squares Levenberg-Marquardt algorithm [23] was used to solve the problem. Neither of the above two methods requires any alignment device or information about the IMU casing. This makes the methods easy to perform and practical.
Mecheri et al. [22] evaluated eight methods for the orientation alignment of two coordinate systems. The eight methods include the methods in [20] and [21] as well as methods under the theme "hand-eye calibration" or the "AX = XB" problem in robotics [24][25][26][27][28][29]. In fact, in order to apply the hand-eye calibration methods to the frame alignment between an IMU and an MCS (which is of interest here), very accurate orientation of the IMU with respect to its inertial reference frame should be available, which is not the case in most IMU applications. Mecheri et al. recommended the method in [20] rather than the method in [21] as the former had better performance in an evaluation.
In [21,22], there are a couple of interesting comments regarding the comparison of the two methods [20,21]. First, regarding the comment on the signal-to-noise (S2N) ratio (which is referred to as C1, henceforth), [21] argued that the gyroscopic angle provides a better S2N ratio than the angular velocity or acceleration and does not require fine filtering, which might be sensitive to the execution of the alignment movement. However, [22] disagreed with the argument as the method in [20] performed better than the method in [21]. Second, regarding the comment on the false local minima of the non-linear least squares method (which is referred to as C2), [22] stated that, while the method in [20] uses a linear least squares method through pseudoinverse matrix operation to calculate the alignment DCM, the method in [21] uses a non-linear least squares method that could partially contribute to the performance discrepancies between the two methods. However, [22] did not verify for the above two comments. C1 can be investigated by inserting a predefined level of noise to angular velocity measurements and generating different S2N ratio data. C2 can be verified by evaluating the estimation performance for several different alignment orientations to be estimated, while the initial orientation for the non-linear least squares method is fixed (i.e., it is not varied).

Alignment Procedure
For the frame alignment of an IMU coordinate system {I} to an MCS coordinate system {M}, the proposed method uses a quaternion q, which is defined as the sum of a scalar q 0 and a vector T . Any three-dimensional column vector a can be represented as the quaternionâ with the scalar part set to zero, i.e.,â = [0, a T ] T .
Then, the angular velocities expressed in the IMU frame are transformed to those expressed in the MCS frame by the following equation that includes the constant alignment quaternion q: where i indicates the frame number; N is the number of frames; and q * is the conjugate of q, defined as q * = [q 0 , −e T ] T . In addition, Iω i is the quaternion form of the angular velocity measured with an IMU (i.e., gyroscope signals), , and Mω i is the quaternion form of the angular velocity as derived from MCS data, T . Note that three markers of the MCS form a plane and can define a unique local frame. Accordingly, the MCS can track the quaternion of the MCS local frame with respect to the MCS global frame M q. Then, Mω i is obtained as: where M . q is the time derivative of M q obtained by the numerical differentiation and may cause derivative noises in Mω i . Equation (1) can be rewritten as: By combining Equation (3) with the quaternion normalization constraint ||q||= 1 , the following four non-linear constraint functions, F i , are derived: where w is the weighting factor for the normalization constraint which was set to 10 in this paper. In this study, MATLAB function fsolve is used to solve the non-linear Equation (4), with the fixed initial quaternion [1, 0, 0, 0] T and the specified algorithm option, "Levenberg-Marquardt," which is chosen in [21]. The solution from the fsolve is finally normalized to be meaningful as an orientation representation. Source codes and example data are available as Supplementary Materials.

Validation Using Simulated Data
A triaxial gyroscope in a wireless MTw IMU system (Xsens Technologies, Enschede, The Netherlands) was used to obtain the angular velocities with respect to the IMU frame I ω at a 100-Hz sampling rate. Before measurement, the IMU was stabilized following a few minutes of sensor warm-up time, which makes effect of ambient temperature on measurement minimal. The gyroscope in an MTw system provides the so-called 'calibrated sensor readings' for orthogonality in a body-fixed coordinate system which is defined as the IMU frame. The gyroscope has a full scale of ±2000 • /s and a noise of 0.01 • /s/ √ Hz . See [30] for detailed specification of the MTw. Within a volume of 30 cm radius, the MTw was moved by hand in a random manner in three-dimensional space as evenly as possible, as in [20] and [22]. The alignment movement had better cover the rotation space as evenly as possible because the solvers such as least square methods minimize the total residual, as discussed in [21]. The Awinda USB dongle station connected to a PC received wireless data from the IMU. In actual alignment processes, angular velocities with respect to the MCS frame M ω are derived from marker data based on Equation (2). However, in the validation of this chapter, M ω's were generated (or simulated) by using the above I ω's and a predefined q which was to be estimated, according to Equation (1). Therefore, only the MTw sensor without an MCS was used for this validation. This is because, if the validation test is performed using an MCS as in the actual process, it is impossible to acquire the perfectly exact alignment orientation q. Note that the exact alignment orientation as a reference should be available for accurate calculation of estimation errors. Furthermore, the position tracking errors of an MCS may interfere with the performance comparison between alignment methods. For these reasons, the simulated angular velocity data according to the reference alignment orientation that we set were considered as more suitable for the performance comparison between methods.
Ten trials were performed for each test, and each trial lasted over 60 s as in [22]. A cutoff threshold of 0.2 rad/s was applied as in [20] since angular velocities should be above the noise level of the gyroscope. Then, each trial was set to 6000 samples of data after cutoff, to provide a sufficient amount of data for solvers. Note that sampling rate is not critical for the proposed method, as long as a sufficient amount of data can be provided to the method.
In order to observe the effect of the signal noisiness on the estimation performance, four levels of random noises were added to both I ω and M ω: N1 [standard deviation (SD) of 0.003 rad/s], N2 (SD of 0.01 rad/s), N3 (SD of 0.05 rad/s), and N4 (SD of 0.1 rad/s).
In order to determine the alignment performance of the nonlinear least squares method for several alignment orientations from a fixed initial orientation, seven alignment orientations in terms of Euler angles were set as follows: A1 (1 • /0 • /−1 • in the order of roll/pitch/yaw), A2 (45 Regarding the fixed initial orientation for the MATLAB function fsolve, the quaternion [1, 0, 0, 0] T was used for M1, and the identity matrix that corresponds to the aforementioned quaternion was used for M3 and M4. For each of the tests, the results of the proposed method (M1) were compared with those of the other three methods (M2-M4). M2 is the DCM-based method introduced in [20] by using the pseudoinverse operation. In this paper, the pseudoinverse matrix is obtained using singular value decomposition (SVD). M3 is the same as M2 except that it uses the MATLAB function fsolve instead of the pseudoinverse operation. M4 is also the DCM-based method introduced in [21] that uses fsolve. To summarize, (i) M1 uses the quaternion while the other three use the DCM, (ii) M2 uses SVD while the other three use fsolve, and (iii) M4 is based on the gyroscopic angle, while the other three are based on angular velocity (Table 1).

Validation Using Experimental Data
The purpose of the validation using experimental data in this chapter is to provide examples of actual alignment accuracy levels based on the specific IMU and MCS at our disposal. In addition to the aforementioned MTw IMU system, an OptiTrack Flex13 motion capture system (NaturalPoint, Inc., Corvallis, OR, USA) was used with the same sampling rate (i.e., 100 Hz), in order to obtain the angular velocities with respect to the MCS frame M ω (see Figure 1). For taking simultaneous measurements, the MTw sensor was mounted on top of a plastic right triangle ruler (with a 31 cm hypotenuse) and then three reflective markers from the Flex13 MCS were attached to each vertices of the ruler using double-sided adhesive tapes. These three markers form a plane that defines a unique orientation. Then, M ω's were derived from the orientation. Note that the MTw was mounted on the ruler with a specific alignment orientation which is the one that alignment methods estimate. The alignment orientation in terms of Euler angles was determined as 1.958 • /−30.576 • /44.347 • in the order of roll/pitch/yaw. Since these angles were used as references for the calculation of estimation errors from the alignment method, they were determined using only very sophisticated data with particular careful attention, by applying the following conditions: (i) 3 <||ω||< 7 rad/s, (ii) −0.03 < M ω − I ω < 0.03 rad/s, and (iii) variation in distances between the markers should be less than 0.5 mm. From about 20 min of data recording (i.e., about 120,000 samples), only 13,564 samples that met the above conditions were input to the angular velocity-based methods (i.e., M1, M2, and M3) so that all three methods yielded almost same alignment estimation results. Accordingly, the averages of the results from M1, M2, and M3 were considered as the reference angles. The averaged variation and maximum variation from the reference angles were only 22 mdeg and 42 mdeg, respectively.
Two tests were conducted: TS ( 1.5 <||ω||< 2 rad/s, relatively slow) and TF ( 5 <||ω||< 6.5 rad/s, relatively fast). As in Section 3.2, the ruler which the MTw was mounted onto was moved by hand in a random manner. Ten trials were performed for each test, and each trial was set to 6000 samples of data after applying the same cutoff threshold as in Section 3.2.

Results
With regard to the validation using the simulated data, Figure 2 shows the averaged root mean squared errors (RMSEs) from 70 trials (i.e., 10 trials × 7 alignment orientations) for each noise level from N1 to N4.  Table 2 lists the detailed RMSEs from the simulated data in terms of the mean and standard deviation. It is true that in the noise level of the sensors for both IMU and MCS, there are large variations for each product. The average of 1400 RMSE data values for each method (i.e., 70 RMSE data × 5 different tests × 4 noise levels) is as follows: 11.46, 15.64, 14.31, and 57.02 mdeg for M1, M2, M3, and M4, respectively. Therefore, the order of accuracy by method is as follows: M1 > M3 ≈ M2 > M4. As shown in Figure 3, the proposed method M1 performed slightly better than M2 introduced in [20], consistently for all noise levels and angular velocities. With regard to the validation using the experimental data, Table 3 shows the RMSEs in terms of the mean and standard deviation. Although the RMSEs were much higher than those from the simulated data due to addition of errors from the MCS measurement into the input data, M1 was slightly but consistently superior to M2 and M3. Furthermore, the standard deviations of M1 were smaller than those of M2 and M3.

Discussion and Conclusions
The performance of M4 was lower than those of the other three methods. This result is in good agreement with the finding in [22]. The inferior performance of M4 is possibly associated with the use of gyroscopic angles rather than angular velocities. Note that M4 is the only method that uses the angle information for estimation. The strapdown integration process to obtain the gyroscopic angles is inherently prone to drift errors. Then, the frame transformation based on erroneous angles may result in errors in alignment estimation. Although [21] argued that the gyroscopic angle provides a better S2N ratio than the angular velocity, the performance of M4 was lower than those of the other three methods for all noise levels (i.e., N1 to N4).
If we consider that the only difference between M1 and M3 is the orientation representation (see Table 1), it may be said that the quaternion chosen by M1 is better than the DCM chosen by M3 for the estimation of alignment orientation. For the quaternion and DCM, the numbers of component (to be estimated) are four and nine, while the numbers of constraints are one and six, respectively. The fewer number of components and constraints of the quaternion may yield better estimates within the same data sets.
As the angular velocity increased, the error tended to decrease, in general, in both the simulated data (see Table 2 and Figure 2) and the experimental data (see Table 3). This may be because the influence of the noise is relatively reduced when the angular velocity increases at the same noise level. In the case of M4, this tendency was irregular. This irregularity is also suspected to be related to the strapdown integration process to obtain angles for M4.
As the noise level increased, the error tended to increase, which is simply natural (see Table 2). A noticeable factor is that the order of accuracy by method was the same for all noise levels. This means that one method cannot be said to be more sensitive than the other depending on the S2N ratio. Specifically, with regard to C1 on the S2N ratio issue, our result does not support the description in [21], that is, the gyroscopic angle compared to the angular velocity provides a good S2N ratio.
With regard to C2, the applied solvers were not critical in general. However, we could find some effects related to the use of the nonlinear least square method fsolve in M3. See Table 4 for the coefficients of variance (CVs) between the RMSE results based on the simulated data, from seven different alignment orientations, i.e., A1 to A7, where each RMSE result used for the CV calculation is the average of the RMSEs from 10 trials. The CVs were as small as 0.5 or less in all methods, except 0.64 of T4 and 0.62 of T5 from M3 in N1. Small CV means that the difference of estimation performance by alignment orientation is small. Averaged RMSEs from 10 trials from A1 to A7, in case of T4 from M3 in N1 were 0.43, 0.52, 0.64, 0.50, 1.76, 1.94, and 1.57 mdeg, respectively; and those in case of T5 from M3 in N1 were 0.34, 0.94, 0.90, 0.88, 2.57, 2.54, and 1.73 mdeg, respectively. Note that, in both cases, the RMSEs were high for A5, A6, and A7 when the alignment orientations were quite different from the initial orientation through two 45 • rotations. Along with the CV distinction, as shown in Figure 2, the RMSE from M3 in N1 increased as the angular velocity increased from T4 to T5 compared to the RMSE at T3. Considering that the difference between M2 and M3 exists only in the solver (see Table 1), obviously the estimation difference comes from the difference of the solver, which is consistent with the description in [22], although [22] compares M2 and M4. In the case of M1, low CV was maintained in all cases. Even though both M1 and M3 use the fsolve, M3 based on DCM was sometimes affected by alignment orientation but M1 based on quaternion was not affected. This also implies the superiority of quaternion to DCM for orientation alignment problem. In this study, we proposed a quaternion-based local frame alignment method where a quaternion is used to represent the orientation. The performance of the proposed method was compared with those of three other methods. Within our limited test data, the proposed method performed the best among the four methods. We expect that the fewer number of components and constraints of the quaternion in the proposed method compared to number of components and constraints of the DCM may result in better accuracy. Owing to its high accuracy and easy setup, the proposed method can be effectively used for local frame alignment between an IMU and an MCS.