Examination of the Unmanned Aerial Vehicle

The contemporary interdisciplinary field of knowledge, which is the robotics used in unmanned aerial vehicles, is developing very dynamically. In view of the above, the authors of this paper have set themselves the following thesis: it is possible to build a flying mobile robot based on a controller with low computing power and a simple PID controller, and in this respect they undertook to prove it. The examined object in real experiments was the Quadrocopter. The article discusses the tasks implemented during the design and practical implementation of a remotely controlled flying unit. First, a mathematical model describing the dynamics of the UAV movement was defined. Then, electronic components were selected to allow the quadrocopter to fly. The board has a central unit in the form of the ATmega644PA microcontroller. In the following, the process of programming subsequent elements that make up the quadrocopter control program was carried out. The control system for stabilizing the machine requires information about the location of the quadrocopter in space. This is accomplished by a measurement module containing an accelerometer and a gyroscope. In addition, the quadrocopter needs information about the potential operator's commands. In the final part of the article, based on the analysis of the research subject, the mathematical model created and the necessary simulation tests carried out in this area, practical conclusions were presented.


Introduction
An unmanned aerial vehicle, colloquially known as a "drone", is an unmanned flying machine with an electric drive. For maintaining in the air, it uses the lifting force, which is produced due to the action of aerodynamic laws, on fixed, i.e. so-called wings, or moving support surfaces -rotors. UAV can also use aerostatic buoyancy, or aerostat. The unmanned aerial vehicle can be controlled remotely by the operator, both from the ground, air, as well as the ship, and moreover, it is possible to control using autonomous systems [1], [2].
In this work, issues related to the unmanned aerial vehicle type quadrotor, i.e. quadcopter, were considered. It is driven by four propellers whose axes of rotation are perpendicular to one plane on which they are placed. Thanks to this construction, controlled movement in three-dimensional space is possible. An example of the appearance of the object is shown in Figure 1. As for the properties of this object, the robot body is a rigid body that has four arms of the same length and arranged at 90 degrees to each other. At their ends, propellers are mounted, which are also rigid bodies, and their string is proportional to the square of their rotational speeds. As for the center of gravity of the UAV, it is in its geometric center. Just as the thrust is proportional to their rotational speeds, the aerodynamic resistance is proportional to the square of the speed of the whole body. Due to the supply of additional energy to the quadcopter system resulting from the work of propellers, this system is non-conservative [3].
Below, in Figure 2, an overview diagram of the tested object is presented.

Fig. 2. Overview diagram of the examined object
The environment in which the model operates is described with the help of two Cartesian systems that are related to both the body of the robot and its surroundings. In the first system the coordinates were presented as symbols x, y, z, while in the second symbols X, Y, Z were used. The origin of the coordinate system related to the UAV body was placed in its geometric center, while the X and Y axes in the plane of propellers.
To determine the orientation of the quadcopter in space, the angles of longitudinal rotation, i.e. pitching, transverse -roll and vertical -yaw were used.
Colloquially, the angles of rotation are marked with the abbreviation RPY (Roll, Pith, Yaw) and this is shown in Figure 3. The symbols φ, θ, ψ are used to mark the entered angles. The accepted vector of state variables is q = (x, y, z, φ, θ, ψ). In the context of control, a computer simulation of robots requires the implementation of a physical object model with the required accuracy. In order to obtain it, a Newton-Euler's or Euler-Lagrange's formalism is used. The first one is based on the principle of maintaining forces and the principle of keeping moments. Its advantage is the ease of achieving reverse dynamics, thanks to which it is used in model-based regulators. Euler-Lagrange's formalism is an energy approach. It can be used on any coordinates describing the system, and the dynamics equations obtained in this way are in the explicit form. It will be used in this chapter to obtain a quadrotor dynamics model. The derivation will be carried out based on the dissertation [4].

Euler-Lagrange's equations
In terms of classical mechanics lagrangian L is the difference between the kinetic T and the potential energy V of the object In accordance with the Hamilton's principle of the Smallest Action, the conservative system accepts the trajectories for which it functioned (2) it achieves the smallest possible value. The work [5] presents a solution to the problem of minimization using a calculus of variations. As a result, Euler-Lagrange's equations are obtained The fundamental advantage of Euler-Lagrange's formalism is the invariance of the form of equations, regardless of the choice of generalized coordinates .
The study of non-conservative systems such as quadrotor requires the use of generalized Euler-Lagrange's equations. After considering the effect of non-conservative forces 1 on coordinates , the previous equation takes the form: Generalized forces are not always identical with physical forces. Their character differs due to the selection of generalized coordinates. In the case of angular coordinates, they have the dimension of moments. Not for every selection of generalized coordinates, there is a physical interpretation of generalized forces [6], [7].
The above equations can be written in a typical form of dynamics equations (5) where: M, C and Dare the inertia matrices, centrifugal and Coriolis's forces and gravitational forces of the object respectively [8], [9], [10].

Non-conservative Moments
The quadrotor system is non-conservative due to the work performed by the rotor engines [11], [12], [13]. The following forces and non-conservative moments are included in the derived model .
 the sum of thrust of the engines (6) where: Ω -is the rotational speed of the propeller i, and bthe thrust coefficient.  difference between the thrust generated by the engines 2 and 4 where: lis the length of the arm.  difference between the thrust generated by the engine pairs 1 and 3 and also 2 and 4 (9) where: dis the coefficient of air resistance.
where: -is the matrix of inertia of the propeller, the rotational speed of the body relative to the axis Y.

Coordinates of the position
In order to determine the dynamics equations for position coordinates it is enough to use the second Newton's dynamics principle [14], [15], [16] where: ais the acceleration of the body, mis the mass of the object, and Fthe resultant force acting on it.
The resultant force acting on the quadrotor consists of the force of gravitation described by the formula [17], [18], [19] (13) and the sum of thrust of the engines (14) where: Ω -is the rotational speed of the propeller i. Assume that the force of gravity acts along the global z axis, and the direction of the thrust of the engines is consistent with the normal force of quadrotor Z.
In order to express the vector described in the coordinates of the quadrotor in the coordinate system related to the earth, the formula was used [20], [21]: (15) where: (16) By substituting the resultant force to the equation on the second principle of Newton's dynamics, we obtain: (17) Then, after simplifying the above equation, we get the form:

Angular coordinates
The generalized Euler-Lagrange's equations will be used to derive the equations of dynamics for angular coordinates. As generalized coordinates, angles RPY-(φ, θ, ψ) will be used, which are described in chapter 1.

 Euler-Lagrange's equations
Having the analytical form of kinetic and potential energy as well as generalized non-conservative forces, it is possible to apply generalized Euler-Lagrange's equations [22], [23], [24].
In the physical quadcopter, it is impossible to measure directly the angle of RPY. A device called IMU (Inertial Measurement Unit), which is a combination of accelerometers and gyroscopes, is commonly used for this purpose.
Thanks to it, the velocities and angular accelerations associated with the body of the robot are read. For this reason, in the model below, we change the speed φ, theta, psi and we mark , , .
Transformation is performed using the following formula: (20) In this way, we get: After applying a linear approximation in the above expressions (21) for small values of swinging and pitching angles (α ≈ 0 → sin α ≈ 0, cos α ≈ 1) the system dynamics equations for RPY angles were obtained.
In order to give the control outputs sense of forces, i.e. moments affecting the quadrotor described in subchapter 2.2 "Non-conservative Moments", we will introduce a new control vector = ( 1 2 3 4 ) and an auxiliary variable Ω as follows [25], [26]: (23) It is easy to determine the values of rotational speeds of propellers Ω depending on the U vector, namely: By combining a simplified equation with the second dynamics principle (18) and the system dynamics equation for RPY angles (22) taking into account the first relationship described in this subsection (23) we get a complete model of quadrotor dynamics in the form: In the literature, we can find several versions of the quadrotor model. Nevertheless, it is important to always rely on the same theoretical basis for all comparative activities. It was decided to implement the above model for several reasons. First of all, it is one of the first models presented, and all the next ones refer to it and are based on it. This model is very well described in the literature and the vast majority of publications by known authors accept this description. However, attention should be paid to the differences in the models used. For example, the work entitled "Modeling, identification and control of a quadrotor helicopter" [27] introduces the scaling of controls 2 and 3 by the distance of the propeller from the center of the model l, thanks to which the speed of changing the pitching and yaw angles becomes associated with the physical model [28], [29].

Operating algorithm of the robot
To operate the robot, an application designed by the authors has been implemented, the algorithm of which is presented in Figure 9. For example, the reception of information from sensors is carried out at a frequency of 1 [kHz], so only after the time t 1 equal to 1 [ms] has elapsed since the previous measurement the next one is performed. Such structure of the program ensured full control over the performance of individual functions and minimized the number of operations required [30], [31], [32], [33].

Fig. 10. Schematic diagram of the control system
The controller input is an offset between the angle setpoint value from the pilot and the measured angle.
In order to control the angular velocity of the object in the X and Y axes, a cascade controller consisting of two PID controllers was used separately for each axis.
Due to the lack of an object model, the values of the proportional, integral and derivative elements of both PID controllers were determined empirically. Figure 11 shows the obtained results of the robot tests during the flight. The control system is characterized by a significant overshoot, but this is a desirable effect, especially when changing the direction of the flight of the robot.
Thanks to the achievement of acceptable measurement results, it was possible to make stable flights without any belaying.

Conclusions
The paper presents a prototype of a flying robot, intentionally equipped with an 8-bit microcontroller and a simple regulator to check the possibility of smooth regulation and control of its flight.
The use of two microcontrollers allowed to ensure sufficient computing power and correct execution of the robot control program.
Experimental results of the designed robot, such as: 15minute flight time, steady state error of not more than 1° and free control and smooth maneuvering of the flying object, proved that it is possible to perform quadcopter flight control with the use of low-performance microcontroller and simple cascade controller.