## 2 Materials and Methods
### Analytical Modelling of Flexible Mechanisms Using Euler-Bernoulli Beam Theory
\begin{array}{cccc}\frac{1}{3}\;m_{2}l^{3}\big{(}3\,i^{2}-3\,i+1 \big{)}&\frac{m_{2}l^{2}}{20}(-3+10\,i)&m_{2}\Big{(}-\frac{1}{12}\,il^{3}+\frac {1}{30}\,l^{3}\Big{)}&\frac{m_{2}l^{2}}{20}(-7+10\,i)&\frac{m_{2}l^{3}(-3+5\,i) }{60}\\ \frac{1}{20}\;m_{2}l^{2}(-3+10\,i)&\frac{13\,m_{2}l}{35}&-\frac{11\,m_{2}l^{2} }{210}&\frac{9\,m_{2}l}{70}&\frac{13\,m_{2}l^{2}}{420}\\ m_{2}\Big{(}-\frac{1}{12}\,il^{3}+\frac{1}{30}\,l^{3}\Big{)}&-\frac{11\,m_{2}l^ {2}}{210}&\frac{m_{2}l^{3}}{105}&-\frac{13\,m_{2}l^{2}}{420}&-\frac{m_{2}l^{3} }{140}\\ \frac{1}{20}\;m_{2}l^{2}(-7+10\,i)&\frac{9\,m_{2}l}{70}&-\frac{13\,m_{2}l^{2} }{420}&\frac{13\,m_{2}l}{35}&\frac{11\,m_{2}l^{2}}{210}\\ \frac{m_{2}l^{3}(-3+5\,i)}{60}&\frac{13\,m_{2}l^{2}}{420}&-\frac{m_{2}l^{3}}{14 0}&\frac{11\,m_{2}l^{2}}{210}&\frac{m_{2}l^{3}}{105}\end{array} \right], \tag{10}\]  
where \(m_{2}=\rho S\). In the general case, the mass matrix depends on the state variables. If we consider more complex description of deflection, the nonlinear model equations of flexible arm can be derived. The kinetic energy of each element as well as payload is changed, while the position vector \(r\) is derived as follows:  
\[r(s,t)=\left[ \begin{array}{c}(j-1)l\cos(\theta(t))\\ (j-1)l\sin(\theta(t))\end{array} \right]+\left[ \begin{array}{c}\cos(\theta(t) )&-\sin(\theta(t))\\ \sin(\theta(t))&\cos(\theta(t))\end{array} \right]\left[ \begin{array}{c}s\\ u(s,t)\end{array} \right]\text{.} \tag{11}\]  
The kinetic energy is in the form  
\[T_{i}=\frac{1}{2}\rho S\int_{0}^{l}\dot{r}^{T}r\text{ds}=\frac{1}{2}\dot{Q}(t )^{T}M_{i}(q)Q(t), \tag{12}\]  
Figure 3: One element of arm with state-coordinates in detail. where \(M_{i}(q)\) is the state-dependent mass matrix, with elements as \(M_{i}\) in (9), nevertheless with different element \((1,1)\), where \(M_{i}(q)_{1,1}=m_{2}[l^{2}(\frac{q_{21}+2}{105}^{2}+\frac{q_{21}^{2}}{105}+l^{2} -i-\frac{q_{21}+q_{22}l}{70}+\frac{1}{3})+(-\frac{11q_{21}}{105}+\frac{13}{210} +\frac{2q_{21+2}}{210})q_{21}-1-\frac{13}{210}q_{21}(q_{21}-\frac{22q_{21+2}}{1 3})l+\frac{13}{35}+\frac{13}{35}+\frac{q_{21+1}q_{22+1}}{35}]l\). For the payload, the mass matrix depends on the state variables as well as \(M(q)\) in (12), more specifically for location of mass at the tip, on \(q_{2n+1}(t)\). The kinetic energy of the payload can be expressed as  
\[T_{p}=\frac{1}{2}m_{p}\dot{r}_{(s=l,i=n+1)}^{T}\dot{r}_{(s=l,i=n+1)}, \tag{13}\]  
where \(m_{p}\) is the centred mass of the payload, and \(r_{(s=l,i=n+1)}\), representing the position vector of the last element, is as follows:  
\[r_{(s=l,i=n+1)}=\left[ \begin{array}{c}[-l(n+1)\sin(\theta(t))-\cos(\theta(t ))q_{2\,n+1}(t)]\dot{\theta}(t)-q_{2\,n+1}(t)\sin(\theta(t))\\ [l(n+1)\cos(\theta(t))-\sin(\theta(t))q_{2\,n+1}(t)]\dot{\theta}(t)+\dot{q}_{2 \,n+1}(t)\cos(\theta(t))\end{array} \right]. \tag{14}\]  
Further,  
\[\dot{r}^{T}\dot{r}=\ \ \left[l^{2}(n+1)^{2}+q_{2\,n+1}^{2}(t)\right]{}^{ \cdot 2}+2\,l\dot{q}_{2\,n+1}(t)(n+1)^{\,i}+\dot{q}_{2\,n+1}^{2}(t)\ \, \tag{15}\]  
and therefore, for kinetic energy \(T_{p}\) of the payload, we obtain  
\[T_{p}=\frac{1}{2}\dot{Q}_{n}(t)^{T}M_{p}(q_{2n+1}(t))Q_{n}(t), \tag{16}\]  
where \(M_{p}(q_{2n+1}(t))=m_{p}\left[ \begin{array}{cccc}l^{2}(n+1)^{2}+q_{2\,n+1 }^{2}(t)&0&0&l(n+1)&0\\ 0&0&0&0&0\\ 0&0&0&0&0\\ l(n+1)&0&0&1&0\\ 0&0&0&0&0\\ \end{array} \right]\). Consequently, the potential energy of the element \(i\) can be expressed as  
\[V_{i}=\frac{1}{2}EI\int_{0}^{l}\left[\frac{\partial^{2}u_{i}(s,t)}{\partial s ^{2}}\right]^{T}\left[\frac{\partial^{2}u_{i}(s,t)}{\partial s^{2}}\right] \text{ds}, \tag{17}\]  
where \(EI\) is the flexural rigidity of the link material, (more formally, \(EI=E\cdot I\), where \(E\) is [PERSON]'s module of the material and \(I\) is the second moment of area). It follows that \(\frac{\partial^{2}u_{i}(s,t)}{\partial s^{2}}=Q_{i}(t)^{T}N_{i}^{\prime\prime} (s)^{T}N_{i}^{\prime\prime}(s)Q_{i}(t)\), where \(N_{i}^{\prime\prime}(s)=\left[\begin{array}{cccc}-\frac{128}{P}+\frac{6}{P} &\frac{68}{P}-\frac{2}{P