# Design and Implementation of A Shape Shifting Rolling-Crawling-Wall-Climbing Robot
## 3 Mathematical Model
### Dynamics Model
#### 3.3.2 Constraint Conditions  
The positions conveyed using (4)-(6) yield the constraint conditions for the translation components. \[\Phi_{x1}:\mathbf{p}_{11}-\mathbf{R}_{\theta}(\mathbf{\phi}_{b})\mathbf{e}_{b}-\bm {R}_{\theta}(\mathbf{\phi}_{11})\mathbf{e}_{t1}-\mathbf{p}_{b}=0 \tag{8}\] \[\Phi_{x2}:\mathbf{p}_{12}-\mathbf{R}_{\theta}(\mathbf{\phi}_{t1})\mathbf{e}_{t1}- \mathbf{R}_{\theta}(\mathbf{\phi}_{t2})\mathbf{e}_{t2}-\mathbf{p}_{t2}=0\] (9) \[\Phi_{x3}:\mathbf{p}_{13}-\mathbf{R}_{\theta}(\mathbf{\phi}_{t2})\mathbf{e}_{t2}- \mathbf{R}_{\theta}(\mathbf{\phi}_{t3})\mathbf{e}_{t3}-\mathbf{p}_{t3}=0 \tag{10}\]  
The constraints that bind the orientation of the body and the first component are represented by a quaternion's equality, as shown below. \[\mathbf{\phi}_{b}= \mathbf{\phi}_{1}\] \[\mathbf{\phi}_{1}^{-1}\circ\mathbf{\phi}_{b}= \mathbf{\phi}_{1}^{-1}\circ\mathbf{\phi}_{1}\] \[\mathbf{\phi}_{1}^{-1}\circ\mathbf{\phi}_{b}= I_{q}. \tag{11}\]  
Constraining each component's orientation, we select the constraint conditions from (11). The robot's joint between the body and the first component is implemented using a servo, hence it possesses a single degree of freedom. The axis direction is along the z axis in the global coordinate in the initial state. Thus, the joint constraint conditions can be given by the second and the third row equations from (11),  
\[\Phi_{\theta 1}:\left\{ \begin{array}{l}q_{01}q_{1b}-q_{11}q_{0b}-q_{21}q_{3b}+q _{31}q_{2b}=0\\ q_{01}q_{2b}-q_{21}q_{0b}+q_{11}q_{3b}-q_{31}q_{1b}=0\end{array} \right. \tag{12}\]  
While extracting the first element from (11), we obtain:  
\[q_{0b}q_{01}+q_{1b}q_{11}+q_{2b}q_{211}+q_{3b}q_{311}=1\] \[\mathbf{\phi}_{b}.\mathbf{\phi}_{11}=1\]  
hence, the element is incapable of the constraint condition. Following the same way, the constraint conditions between the first component and second component are given by the third and forth rows from the following equation. \[\Phi_{\theta 2}:\mathbf{\theta}_{t2}^{-1}\circ\mathbf{\phi}_{t1}=\mathbf{I}_{q}, \tag{13}\]  
The constraint conditions between the second leg component and third leg component are given by the second row and the third row of the following equation  
\[\Phi_{\theta 3}:\mathbf{\theta}_{t3}^{-1}\circ\mathbf{\phi}_{t2}=\mathbf{I}_{q}. \tag{14}\]  
The constraint conditions (8)-(14) give a constraint matrix \(\mathbf{C}\) that should satisfy \(\mathbf{C}\mathbf{v}=0\). The matrix \(\mathbf{C}\) is represented as \[C:=\frac{\partial\mathbf{\Phi}}{\partial x_{q}}A_{q}\]  
where \(\mathbf{\Phi}\) is the list of constraint conditions including the denoted conditions of each leg. To express the system dynamics of the robot, an independent velocity vector \(\dot{\mathbf{q}}\) is defined as  
\[\dot{\mathbf{q}}= [\omega x_{b},\omega y_{b},\omega z_{b},\dot{x}_{b},\dot{y}_{b}, \dot{z}_{b},\] \[\omega z_{leg111},\omega x_{leg12},\omega z_{leg13},\omega z_{leg211},\omega x_{leg212},\omega z_{leg213},\] \[\omega z_{leg31},\omega x_{leg32},\omega z_{leg33}\omega z_{leg411},\omega x_{leg412},\omega z_{leg413}]^{T}.\]  
The vector \(\mathbf{v}_{d}\) is dependent on \(\dot{\mathbf{q}}\) and is selected from \(\mathbf{v}\). Then, \(\mathbf{v}\) can be redefined as \(\mathbf{v}=[\dot{\mathbf{q}}^{T},\mathbf{v}_{d}]^{T}\). Note that the related matrix and the related vector (e.g., \(\mathbf{M},\mathbf{h}\)) should be transformed into the dependent form. To map a generalised velocity space to an independent velocity space, we defined a matrix \(\mathbf{D}\) that satisfies the conditions \(\mathbf{C}\mathbf{D}=0\) and \(\mathbf{v}=\mathbf{D}\dot{\mathbf{q}}\). The constraint matrix \(\mathbf{C}\) can be separated by \(\mathbf{v}=[\dot{\mathbf{q}}^{T},\mathbf{v}_{d}]^{T}\).