## 5 Flexible Body Dynamics Based on Rayleigh-Ritz Shape Matrix  
Using Rayleigh-Ritz shape matrix, the elastic displacement vector of body \(i\) in a two-dimensional space is given by:  
\[{u_{f}}^{i}=\left[ \begin{array}{cc}{u_{f_{1}}}^{i}\\ {u_{f_{2}}}^{i}\end{array} \right]={S_{b}}{q_{f}}^{i}, \tag{45}\]  
where \({u_{f_{1}}}^{i}\) and \({u_{f_{2}}}^{i}\) represent the axial and transversal displacement of any point between the end points of the body \(i\). Hence, it is clear that Equation (45) is a displacement interpolation function. The matrix \({S_{b}}\) for a planar case is the following Rayleigh-Ritz shape matrix:  
\[{S_{b}}=\left[ \begin{array}{cccc}1-\xi&0&0&\xi&0&0\\ 0&1-3\xi^{2}+2\xi^{3}&I\!\left(\xi-2\xi^{2}+\xi^{3}\right)&0&3\xi^{2}-2\xi^{3}& I\!\left(\xi^{3}-\xi^{2}\right)\end{array} \right], \tag{46}\]  
whereas \({q_{f}}^{i}\) is the vector of elastic coordinates of the two endpoints of the body \(i\) in the 2D space:  
\[{q_{f}}^{i}=\left[ \begin{array}{cccc}{q_{f1}}^{i}&{q_{f2}}^{i}&{q_{f3}}^{i}&{q _{f4}}^{i}&{q_{f5}}^{i}&{q_{f6}}^{i}\end{array} \right]^{T}. \tag{47}\]  
The first three coordinates of \({q_{f}}^{i}\) belong to one end point of the body \(i\) whereas the remaining three coordinates belong to the other end point. For each end point, the three coordinates represent the axial elastic displacement, the transversal elastic displacement and the slope about an axis perpendicular to the plane. For the manipulator at hand, all the elastic coordinates are shown in Figure 5. Notice that a coordinate subscript represents the order of the coordinate which represents the degree of freedom, whereas the superscript represents the body to which the coordinate belongs. Since each link has 6 coordinates while the manipulator has 4 links, the total number of the coordinates is 24. They can be written as a single vector \(q_{f}\):  
\[q_{f}=\left[ \begin{array}{cc}q_{f}{}^{1}&q_{f}{}^{2}&q_{f}{}^{3}&q_{f}{}^{4} \end{array} \right]^{T}\!, \tag{48}\]  
where:  
\[q_{f}{}^{1}=\left[ \begin{array}{c}q_{f}{}^{1}\\ q_{f}{}^{2}\\ q_{f}{}^{3}\\ q_{f}{}^{4}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right];\qquad q_{f}{}^{2}=\left[ \begin{array}{c}q_{f} {}^{1}\\ q_{f}{}^{2}\\ q_{f}{}^{3}\\ q_{f}{}^{4}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right];\qquad q_{f}{}^{3}=\left[ \begin{array}{c}q_{f} {}^{3}\\ q_{f}{}^{3}\\ q_{f}{}^{3}\\ q_{f}{}^{4}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right];\qquad q_{f}{}^{4}=\left[ \begin{array}{c}q_{f} {}^{1}\\ q_{f}{}^{2}\\ q_{f}{}^{4}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right]. \tag{49}\]  
Due to the imposed boundary conditions, the elastic coordinates of the bodies of the manipulator are reduced to the following:  
\[q_{f}{}^{1}=\left[ \begin{array}{c}q_{f}{}^{1}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right];\qquad q_{f}{}^{2}=\left[ \begin{array}{c}q_{f} {}^{2}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right];\qquad q_{f}{}^{3}=\left[ \begin{array}{c}q_{f} {}^{3}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right];\qquad q_{f}{}^{4}=\left[ \begin{array}{c}q_{f} {}^{4}\\ q_{f}{}^{5}\\ q_{f}{}^{6}\end{array} \right]. \tag{50}\]  
Accordingly, the columns of the shape matrix corresponding to the eliminated elastic coordinates are also omitted. Hence, the shape matrix for each body is reduced to the following:  
\[S=\left[ \begin{array}{ccc}\xi&0&0\\ 0&3\xi^{2}-2\xi^{3}&L\left(\xi^{3}-\xi^{2}\right)\\ \end{array} \right]. \tag{51}\]  
Figure 5: The elastic nodal coordinates in a planar 3 PRR manipulator. Subsequently, the inertia matrix of each body is obtained by using Equations (16)-(29) whereas the quadratic velocity vector for each body is obtained by using Equations (30)-(32). The gravitational force vector is defined by assuming that the center of mass (COM) of each body is at the middle of the body, therefore the matrix \(S^{i}\) in Equation (35) is defined by using \(\xi=0.5\). The external force vector is obtained by using Equation (35) where the elements corresponding to the rigid coordinates are given by the forces or torques applied to the rigid coordinates.