# Control of an Omnidirectional UAV for Transportation and Manipulation Tasks
## 3 Modeling
### Dynamics  
The dynamic model can be written in compact form as  
\[\mathbf{M}(\mathbf{q})\ddot{\mathbf{q}}+\mathbf{C}(\mathbf{q},\dot{\mathbf{q}})\dot{\mathbf{q}}+\mathbf{g}( \mathbf{q})=\mathbf{\eta}, \tag{5}\]  
where \(\mathbf{M}(\mathbf{q})\in\mathbb{R}^{8\times 8}\) is the symmetric and positive definite inertia matrix  
\[\mathbf{M}(\mathbf{q})=\sum_{i=0}^{2}\Big{(}m_{i}\mathbf{J}_{P_{i}}^{\rm T}(\mathbf{q})\mathbf{J}_ {P_{i}}(\mathbf{q})+\mathbf{J}_{O_{i}}^{\rm T}(\mathbf{q})\mathbf{M}_{i}\mathbf{J}_{O_{i}}(\mathbf{q}) \Big{)}, \tag{6}\]  
\(m_{i}\ (i=0,1,2)\) is the mass of the \(i\)th component (platform, rotor frame, and mobile frame) of the ODQuad, \(\mathbf{M}_{i}\) is its inertia tensor expressed in the inertial frame. The matrix \(\mathbf{C}(\mathbf{q},\dot{\mathbf{q}})\in\mathbb{R}^{8\times 8}\) collects the Coriolis and centrifugal terms  
\[\mathbf{C}(\mathbf{q},\dot{\mathbf{q}})\dot{\mathbf{q}}=\dot{\mathbf{M}}(\mathbf{q})\dot{\mathbf{q}}-\bigg{[} \frac{\partial}{\partial\mathbf{q}}\bigg{(}\frac{1}{2}\mathbf{q}^{\rm T}\mathbf{M}(\mathbf{q}) \dot{\mathbf{q}}\bigg{)}\bigg{]}^{\rm T}. \tag{7}\]  
The vector \(\mathbf{g}(\mathbf{q})\in\mathbb{R}^{8}\) contains the generalized gravitational forces  
\[\mathbf{g}(\mathbf{q})=-\sum_{i=0}^{2}m_{i}\mathbf{\bar{g}}^{\rm T}\mathbf{J}_{P_{i}}(\mathbf{q}), \tag{8}\]  
with \(\mathbf{\bar{g}}^{\rm T}=[0\ 0-9.81]^{\rm T}\). The vector \(\mathbf{\eta}\) collects the external generalized forces acting as inputs, i.e.,  
\[\mathbf{\eta}= \begin{bmatrix}\mathbf{f}_{0}\\ \mathbf{\mu}_{0}\\ \mathbf{\tau}_{\delta}\end{bmatrix} , \tag{9}\]  
where \(\mathbf{f}_{0}\) and \(\mathbf{\mu}_{0}\) are the force and moment, respectively, acting on the platform, and \(\mathbf{\tau}_{\delta}\in\mathbb{R}^{2}\) are the torques acting on the roll-pitch joint. The force \(\mathbf{f}_{0}\) depends on the four propellers' thrusts, \(\sigma_{i}\ (i=1,\dots,4)\), that are directed along the \(z_{2}\) axis. Therefore, the total force acting on the platform, expressed in \(\mathbf{\Sigma}_{2}\), has the following expression, \(\mathbf{f}^{2}=[0\ 0\ f_{z}]^{\rm T}\). The input \(\mathbf{f}_{0}\) can be derived from \(\mathbf{f}^{2}\), expressed in the inertial frame  
\[\mathbf{f}_{0}=\mathbf{R}_{2}\mathbf{f}^{2}, \tag{10}\]  
where \(\mathbf{R}_{2}\) represents the orientation of the frame \(\mathbf{\Sigma}_{2}\) with respect to the inertial one. Analogously, the moment \(\mathbf{\mu}_{0}\) can be written as \[\mu_{0}=R_{2}\left(\mu^{2}+S(r_{2,C_{2}}^{2})f^{2}\right), \tag{11}\]  
where \(\mu^{2}\) is the moment generated by the propellers expressed in frame \(\mathbf{\Sigma}_{2}\). In turn, \(f^{2}\) and \(\mu^{2}\) can be expressed as [7]  
\[ \begin{bmatrix}f_{z}\\ \mathbf{\mu}^{2}\end{bmatrix} = \begin{bmatrix}1&1&1&1\\ l&0&-l&0\\ 0&-l&0&l\\ c&-c&c&-c\end{bmatrix}\begin{bmatrix}\sigma_{1}\\ \sigma_{2}\\ \sigma_{3}\\ \sigma_{4}\end{bmatrix} =\mathbf{N}\sigma, \tag{12}\]  
where \(l>0\) is the distance of each rotor from \(\mathcal{O}_{2}\), \(c=\gamma_{d}/\gamma_{t}\), while \(\gamma_{d}\) and \(\gamma_{t}\) are the drag and thrust coefficients, respectively. The torque vector \(\mathbf{\tau}_{\delta}\) is given by the sum of the torques generated by the joint actuators, \(\mathbf{\tau}_{c}\), and the effect of the thrusts on the joints  
\[\mathbf{\tau}_{\delta}=\mathbf{\tau}_{c}+\mathbf{J}_{2}^{\mathrm{T}}\mathbf{h}_{2}, \tag{13}\]  
where  
\[\mathbf{J}_{2}= \begin{bmatrix}J_{2}\\ J_{O_{2}}\end{bmatrix} ,\qquad\mathbf{h}_{2}= \begin{bmatrix}R_{2}f^{2}\\ R_{2}\mathbf{\mu}^{2}\end{bmatrix} .\]  
For control design purposes, the matrices in (5) can be written as block matrices  
\[\mathbf{M}=\begin{bmatrix} \begin{array}{ccc}\mathbf{M}_{pp}&\mathbf{M}_{p\delta}&\mathbf{M} _{p\delta}\\ \mathbf{M}_{p\phi}\mathbf{\tau}&\mathbf{M}_{\phi\phi}\\ \mathbf{M}_{p\delta}\mathbf{\tau}&\mathbf{M}_{\phi\delta}\end{array}