# Neural PD Controller for an Unmanned Aerial Vehicle Trained with Extended Kalman Filter
## 3 Multirotor Dynamic Model  
The multirotor used for this work was the quadcopter. There are two principal configurations for quadcopters; in this case, the configuration selected is described in Figure 2.  
The robotic platform where the algorithm was tested is the Parrot AR.Drone 2.0 (r) quadrotor. Multirotor systems have an even number of rotors divided into two groups rotating in opposite directions. The configuration of the selected platform is depicted in Figure 2. For this specific configuration, where the robot structure does not match with the \(x\) and \(y\) axis from the body frame (Figure 3), the movement of the vehicle is given by the following combination of rotor actions: increasing or decreasing the speed of the four rotors in the same proportion changes the altitude of the system. Then, because the multirotor is an underactuated system, there is no actuator that generates movement in \(x\) and \(y\) directions directly; instead, these displacements are achieved by changes in the attitude due to combinations of the two pairs of propellers: the rotation in \(y\) axis (pitch \(\theta\)) results in translational movement in \(x\); contrarily, a rotation in \(x\) (roll \(\phi\)) results in translationalmovement in \(y\). Similarly, the orientation (yaw \(\psi\)) needs a combination of the four propellers and it is the result of the difference of the counter-torque between both pairs. In general, the center of mass is considered to be at the origin of the body fixed frame. The quadrotor orientation in space is given by a rotation matrix \(\mathbf{R}\in SO(3)\) from the quadrotor \(\mathbf{B}\) to the inertial frame \(\mathbf{E}\). As in [4], the dynamics of the quadrotor may be expressed as follows  
\[\left[ \begin{array}{cc}m\mathbf{I}_{3\times 3}&0\\ 0&\mathbf{I}\end{array} \right]\left[ \begin{array}{c}\mathbf{V}\\ \dot{\mathbf{\omega}}\end{array} \right]+\left[ \begin{array}{c}\mathbf{\omega}\times m \mathbf{V}\\ \mathbf{\omega}\times\mathbf{I}\mathbf{\omega}\end{array} \right]=\left[ \begin{array}[] {c}\mathbf{F}\\ \mathbf{\tau}\end{array} \right] \tag{1}\]  
where \(\mathbf{I}\) is the inertia matrix, \(\mathbf{V}\) is the body linear speed vector and \(\mathbf{\omega}\) is the angular speed. The quadrotor equations of motion can be expressed as  
\[\dot{\mathbf{\zeta}} =\mathbf{v} \tag{2}\] \[\dot{\mathbf{v}} =-ge_{3}+\mathbf{R}_{e_{3}}\left(\frac{b}{m}\sum\Omega_{i}^{2}\right)\] \[\dot{\mathbf{R}} =\mathbf{R}\dot{\mathbf{\omega}}\] \[\mathbf{I}\dot{\mathbf{\omega}} =-\mathbf{\omega}\times\mathbf{I}\mathbf{\omega}-\sum\mathbf{J}_{r}\left( \mathbf{\omega}\times e_{3}\right)\Omega_{i}+\mathbf{\tau}_{a}\]  
where the gravity \(g\) is acting on \(z\) axis (\(e_{3}\)), \(\dot{\mathbf{\zeta}}\) is the linear velocity vector, the rotation matrix is represented by \(\mathbf{R}\), \(\dot{\mathbf{\omega}}\) is the skew symmetric matrix of the vector of angular velocity and \(\Omega_{i}\) represents the speed of rotor \(i\). \(\mathbf{I}\) and \(\mathbf{J}_{r}\) are the body and the rotor inertia respectively. \(m\) is the mass of the system, \(b\) is the thrust factor, \(l\) is the distance from the center of mass to the rotor (it is assumed the same distance to all rotors) and \(\mathbf{\tau}_{a}\) represents the torque applied to the quadrotor. For this configuration, \(\mathbf{\tau}_{a}\) is denoted as follows  
\[\mathbf{\tau}_{a}=\left( \begin{array}{c}\frac{\sqrt{2}}{2}lb\left(\Omega_{1}^{2} +\Omega_{2}^{2}-\Omega_{3}^{2}-\Omega_{4}^{2}\right)\\ \frac{\sqrt{2}}{2}lb\left(\Omega_{1}^{2}+\Omega_{3}^{2}-\Omega_{2}^{2}-\Omega _{4}^{2}\right)\\ d\left(\Omega_{1}^{2}+\Omega_{4}^{2}-\Omega_{2}^{2}-\Omega_{3}^{2}\right) \end{array} \right) \tag{3}\]  
with a drag factor \(d\). Figure 3: Quadrotor configuration. \(B\) represents the quadrotor fixed frame and \(E\) the inertial frame. Figure 2: Illustration of the concept of the motion of a quadrotor.