*2.3. 3-Dimensional Hip and Knee Joint Angles*

As shown in Figure 3, a human leg, as a kinematic manipulator, consists of two physical links (i.e., thigh and shin) and joints (i.e., hip and knee), each having three rotational joints. Both the physical joints are imaginary. Physical joint A is located at the hip (hip joint), and physical joint B is situated in the knee. Each physical joint has three Degree of Freedom (DOF) imparting a robot system. Links A and B are also imaginary and connect physical joint A to link A and physical Joint B to link B, respectively. Sensor A is placed at the end of Link A and gives the orientation of link A to the base frame. Sensor B is situated at the end of link B and provides the orientation of link B to the base frame. It should be noted that the direction of both the sensors is maintained the same.

By defining the transformation matrices *T*<sup>0</sup> *<sup>A</sup>* as the mapping of sensor A in the base frame 0 and *TA <sup>B</sup>* as the mapping of sensor B in the sensor A frame, they can be described as follows based on the Denavit and Hartenberg (D–H) convention. The four parameters of each link give a homogeneous transformation matrix *Ai*. As per D-H convention law, every *Ai* can be represented as a product of four basic transformations as shown below.

$$A\_i = \operatorname{Rot}\_{z, \mathcal{O}\_i} \operatorname{Trans}\_{z, d\_i} \operatorname{Trans}\_{x, a\_i} \operatorname{Rot}\_{x, a\_i} \tag{1}$$

$$A\_{i} = \begin{bmatrix} c\_{\theta\_{i}} & -s\_{\theta\_{i}} & 0 & 0 \\ s\_{\theta\_{i}} & c\_{\theta\_{i}} & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & d\_{i} \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & a\_{i} \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & c\_{a i\_{i}} & -s\_{a i\_{i}} & 0 \\ 0 & s\_{a i\_{i}} & c\_{a i\_{i}} & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{2}$$

$$A\_{i} = \begin{bmatrix} \mathfrak{c}\_{\partial\_{i}} & -\mathfrak{s}\_{\partial\_{i}}\mathfrak{c}\_{a\_{i}} & \mathfrak{s}\_{\partial\_{i}}\mathfrak{s}\_{a\_{i}} & a\_{i}\mathfrak{c}\_{\partial\_{i}}\\ s\_{\partial\_{i}} & \mathfrak{c}\_{\partial\_{i}}\mathfrak{c}\_{a\_{i}} & -\mathfrak{c}\_{\partial\_{i}}\mathfrak{s}\_{a\_{i}} & a\_{i}\mathfrak{s}\_{\partial\_{i}}\\ 0 & s\_{a\_{i}} & \mathfrak{c}\_{a\_{i}} & d\_{i}\\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{3}$$

Here, 's' stands for sine and 'c' stands for cosine of the respective angles. Equation (3) is the general form of the homogeneous transformation matrix, which varies with each link, based on the D-H parameters of that link.

The transformation from frame 0 to frame 1 of the model can now be obtained by simply substituting the D–H parameters of link 1 in the general form of the homogeneous transformation matrix. Likewise, the homogeneous transformation matrix can be derived for link 1 through 6. Let *A*<sup>0</sup> 1 be the transformation from frame 0 to frame 1 or the mapping of frame 1 in frame 0. Then,

$$A\_1^0 = \begin{bmatrix} c\_{\ell 1} & 0 & -s\_{\ell 1} & 0 \\ s\_{\ell 1} & 0 & c\_{\ell 1} & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} . \tag{4}$$

Similarly,

$$A\_2^1 = \begin{bmatrix} c\varrho\_2 & 0 & s\varrho\_2 & 0\\ s\varrho\_2 & 0 & -c\varrho\_2 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}, A\_3^2 = \begin{bmatrix} c\varrho\_3 & -s\varrho\_3 & 0 & 0\\ s\varrho\_3 & c\varrho\_3 & 0 & 0\\ 0 & 0 & 1 & d\_3\\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{5}$$

$$A\_4^3 = \begin{bmatrix} c\varrho\_4 & 0 & -s\varrho\_4 & 0\\ s\varrho\_4 & 0 & c\varrho\_4 & 0\\ 0 & -1 & 0 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}, A\_5^4 = \begin{bmatrix} c\varrho\_5 & 0 & s\varrho\_5 & 0\\ s\varrho\_5 & 0 & -c\varrho\_5 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{6}$$

$$A\_{\delta}^{5} = \begin{bmatrix} c\_{\partial\_{6}} & -s\_{\partial\_{6}} & 0 & 0 \\ s\_{\partial\_{6}} & c\_{\partial\_{6}} & 0 & 0 \\ 0 & 0 & 1 & d\_{6} \\ 0 & 0 & 0 & 1 \end{bmatrix}. \tag{7}$$

Since there are only 2 physical joints, A and B, each having 3 rotational joints whose origins coincide, the number of homogeneous transformation matrices can also be reduced from 6 to only 2. The mapping of the 1st physical joint to frame 0 is *T*<sup>0</sup> <sup>3</sup>. Let *<sup>T</sup>*<sup>0</sup> <sup>3</sup> be the transformation from frame 0 to frame 3 or, analogously, the mapping of frame 3 in frame 0. Since the model distinctly consists of two physical links and joints, each having three rotational joints, the number of transformation matrices can be reduced from 6 to 2 as follows:

$$T\_A^0 = A\_1^0 A\_2^1 A\_{3'}^2 \tag{8}$$

$$T\_A^0 = \begin{bmatrix} c\_1 c\_2 c\_3 - s\_1 s\_3 & -c\_1 c\_2 s\_3 - s\_1 c\_3 & c\_1 s\_2 & d\_A(c\_1 s\_2) \\ s\_1 c\_2 c\_3 + c\_1 s\_3 & -s\_1 c\_2 s\_3 + c\_1 c\_3 & s\_1 s\_2 & d\_A(s\_1 s\_2) \\ -s\_2 c\_3 & s\_2 s\_3 & c\_2 & d\_A(c\_2) \\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{9}$$

$$T\_B^A = A\_4^3 A\_5^4 A\_{6'}^5 \tag{10}$$

$$T\_B^A = \begin{bmatrix} c\_4 c\_5 c\_6 - s\_4 s\_6 & -c\_4 c\_5 s\_6 - s\_4 c\_6 & c\_4 s\_5 & d\_B(c\_4 s\_5) \\ s\_4 c\_5 c\_6 + c\_4 s\_6 & -s\_4 c\_5 s\_6 + c\_4 c\_6 & s\_4 s\_5 & d\_B(s\_4 s\_5) \\ -s\_5 c\_6 & s\_5 s\_6 & c\_5 & d\_B(c\_5) \\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{11}$$

where *c*1, *c*2, *c*3, *c*4, *c*5, *c*<sup>6</sup> stand for cos (θ1), cos (θ2), cos (θ3), cos (θ4), cos (θ5), cos (θ6), and *s*1, *s*2, *s*3, *s*4, *s*5, *s*<sup>6</sup> are sin (θ1), sin (θ2), sin (θ3), sin (θ4), sin (θ5), sin (θ6), respectively.

**Figure 3.** Three-dimensional joint angles: (**a**) description of a human leg model as a kinematic manipulator that consists of two physical links (i.e., thigh and shin) and joints (i.e., hip and knee), each having three rotational joints, the transformation; (**b**) an experimental sensor network setup.

The global homogeneous transformation matrix *T<sup>G</sup>* <sup>0</sup> is assumed to be an identity matrix,

$$T\_0^G = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} . \tag{12}$$

The forward kinematic equation to obtain the sensor B orientation in/with respect to base frame (frame 0) is given as follows:

$$T\_B^G = T\_0^G \ast T\_A^0 \ast T\_B^A. \tag{13}$$

Rearranging the above equation to get orientation of sensor B with respect to the sensors A [11] or equivalently the orientation of frame 6 with respect to frame 3:

$$T\_B^A = \left(T\_A^0\right)^{-1} \ast \left(T\_0^G\right)^{-1} \ast T\_B^0 \tag{14}$$

where *T*<sup>0</sup> *<sup>B</sup>* is the initialized version of *<sup>T</sup>*<sup>0</sup> *B* (*original*)

The initialization of rotation matrix obtained from the sensors A and B is done in order to perfectly align sensor B (*T*<sup>0</sup> *B*) with sensor A (*T*<sup>0</sup> *<sup>A</sup>*) in the sagittal plane. To initialize *<sup>T</sup>*<sup>0</sup> *<sup>A</sup>* (*original*) and *<sup>T</sup>*<sup>0</sup> *<sup>B</sup>* (*original*) in the mid-sagittal plane, the rotation matrices of sensors A and B at the initially aligned position of the leg in the sagittal plane are calculated. Thus, the calibrated rotation matrix of sensor A (*T*<sup>0</sup> *<sup>A</sup>*) is given by

.

$$T\_{A\_{\
u}(inv)}^0 = \left[T\_{A\_{\
u}(original)}^0(at\ initial\ position)\right]^{-1} \tag{15}$$

$$T\_A^0 = T\_{A \text{ (original)}}^0 \* T\_{A \text{ (inv)}}^0. \tag{16}$$

Similarly, the calibrated rotation matrix of sensor B (*T*<sup>0</sup> *<sup>B</sup>*) is given by

$$T\_{B\_{\text{ (inv)}}}^0 = \left[ T\_{B\_{\text{ (original)}}}^0 (\text{at initial position}) \right]^{-1} \,, \tag{17}$$

$$T\_B^0 = T\_{B \text{ (original)}}^0 \ast T\_{B \text{ (inv)}}^0. \tag{18}$$

Note that, in Equations (16) and (18), only the inverse of the first matrices of *T*<sup>0</sup> *<sup>A</sup>* (*original*) and *T*0 *<sup>B</sup>* (*original*) are taken so that the first matrices of initialized *<sup>T</sup>*<sup>0</sup> *<sup>A</sup>* and *<sup>T</sup>*<sup>0</sup> *<sup>B</sup>* become an identity matrix always. Next, by applying inverse kinematics to *T*<sup>0</sup> *<sup>A</sup>*, the 3-D hip joint angles θ1, θ2, θ<sup>3</sup> are obtained.

$$r\_{33} = c\_{2\prime} \cdot \theta\_2 = \cos^{-1}(r\_{33}) \tag{19}$$

$$r\_{31} = -s\_2 c\_3, \quad \theta\_3 = \cos^{-1}\left(\frac{-r\_{31}}{s\_2}\right) \tag{20}$$

$$r\_{13} = c\_1 s\_2, \quad \theta\_1 = \cos^{-1} \left( \frac{r\_{13}}{s\_2} \right) \tag{21}$$

Similarly, by applying inverse kinematics to *T<sup>A</sup> <sup>B</sup>* , the 3-D knee joint angles θ4, θ5, θ<sup>6</sup> (Figure 3b) can by calculated by

$$r\_{33} = c\_{5\prime} \cdot \theta\_5 = \cos^{-1}(r\_{33}) \,\prime \tag{22}$$

$$r\_{31} = -\text{s} \text{s} \alpha\_{\theta} \quad \theta\_{\theta} = \cos^{-1}\left(\frac{-r\_{31}}{\text{s}}\right) \tag{23}$$

$$r\_{13} = c\_4 s\_5, \ \theta\_4 = \cos^{-1} \left( \frac{r\_{13}}{s\_5} \right). \tag{24}$$
