System Identification and Nonlinear Model Predictive Control with Collision Avoidance Applied in Hexacopters UAVs

Accurate trajectory tracking is a critical property of unmanned aerial vehicles (UAVs) due to system nonlinearities, under-actuated properties and constraints. Specifically, the use of unmanned rotorcrafts with accuracy trajectory tracking controllers in dynamic environments has the potential to improve the fields of environment monitoring, safety, search and rescue, border surveillance, geology and mining, agriculture industry, and traffic control. Monitoring operations in dynamic environments produce significant complications with respect to accuracy and obstacles in the surrounding environment and, in many cases, it is difficult to perform even with state-of-the-art controllers. This work presents a nonlinear model predictive control (NMPC) with collision avoidance for hexacopters’ trajectory tracking in dynamic environments, as well as shows a comparative study between the accuracies of the Euler–Lagrange formulation and the dynamic mode decomposition (DMD) models in order to find the precise representation of the system dynamics. The proposed controller includes limits on the maneuverability velocities, system dynamics, obstacles and the tracking error in the optimization control problem (OCP). In order to show the good performance of this control proposal, computational simulations and real experiments were carried out using a six rotary-wind unmanned aerial vehicle (hexacopter—DJI MATRICE 600). The experimental results prove the good performance of the predictive scheme and its ability to regenerate the optimal control policy. Simulation results expand the proposed controller in simulating highly dynamic environments that showing the scalability of the controller.


Motivation
In recent years, the field of robotics has experienced exponential growth due to fast technological advances. The applications are not restricted to the industrial field, as nowadays robots are equipped with sophisticated and intelligent algorithms that are useful for performing complex task in unstructured and natural environments with a high degree of autonomy. The integration between robots and humans through service robotics has the objective of facilitating activities of daily life or improving repetitive tasks. As such, we can find mobile manipulators that are used to load transportation in structured environments [1,2], robotic systems that help people during their rehabilitation process [3] and aerial robotic vehicles that are useful in rescue or transportation operations [4]. Robot applications can be divided into four main groups: (i) Learning robots, which are robotic systems for whom the main objective is to improve learning and stimulation processes [5,6].
(ii) Construction robots, which are systems that can be programmed to develop complex repetitive tasks, where the main contributions are the decrease in production time and the prevention of accidents in dangerous workplaces [7,8]. (iii) Field robots, which show a variety of improvements in mining industries, agricultural and livestock, increasing the economy of the population [9,10]. (iv) Military robots, which are designed to perform exploration, security, rescue, among other applications in hostile environments that can be dangerous for humans, and these applications are highly developed using unmanned aerial vehicles (UAVs) [11].
The use of unmanned aerial vehicles have grown in a wide range of fields and has been extensively studied by the scientific community due to the versatility and the possibility to perform the fully autonomous tasks that humans are unable to. The extremely agility of the UAVs with four or more rotors has attracted attention due to their ability to vertically take off and land in confined or difficult to access spaces, which eases construction and enables having a higher payload capacity, which are useful in critical missions such as transportation, rescue, search, surveillance and disaster assistance. In these applications, the execution time is an extremely important feature due to the task only being executed for high-speed trajectories. To take advantage of UAVs, it is necessary to guarantee the safe execution of the application; however, dynamic environments are spaces with highly probabilities of collisions, where obstacle information is unknown at the beginning of the task, and thus the UAV must be capable of avoiding the obstacles using online-scheme information. Obstacle avoidance is an important feature that guarantees the correct functionality of UAV applications. In this context, research efforts are still needed to safely introduce UAVs as a technological tool with great potential to solve various current problems such as a collision avoidance control structure that can perform high-speed trajectories in dynamic environments.

Related Work
Depending on the environment, UAV applications can be divided in two groups: (i) Outdoor environments where many studies have employed UAVs with onboard sensors, e.g., Mellinger et al. presented collaborative grasping to logistic applications [12]; Bircher et al. performed path planning for structural inspection using UAVs [13]; search and rescue operations were developed by Oetter-shagen et al. in [14]; and an application consisting of tasks related to physical interaction with the environment was developed by Garimella et al. [15]. (ii) Indoor environments are the counterpart applications, developed in cluttered indoor experiments, examples of which include the study by Song and Hsu who presented navigation based on factor graph optimization (FGO) [16]; Paredes et al., who developed a hybrid acoustic and optical positioning system for accurate 3D movements [17]; and Sandino et al., who proposed an autonomous navigation system using partial observable and uncertainty sensor measurements [18]. Due to the different types of UAVs, these systems have the ability to perform a wide range of applications that are emerging. The most popular configuration of multi-rotors is the quadrotor UAV, which is applied in a variety of aerial fields, e.g., Radoglou-Grammatiski et al., who presented the compilation of the most important applications for precision agriculture using quadrotors [19]; and Gupta et al., who presented the advances of UAVs and the applications in transportation systems [20]. This configuration only presents four motors attached to the mechanical frame generating a limiting power that restricts the fields of use, especially for rescue and transportation tasks. However, nowadays the design of a multi-rotor with more than four rotors is a rapidly growing industry because multi-rotor configuration has presented important advances due to its high maneuverability and transportation capacity [21,22]. More works were conducted by Belmonte et al., who designed an octocopter for the inspection of mobile cranes [23]; Phong-Nguyen et al., who presented a sliding mode control algorithm with a fuzzy inference system considering variable gains for hexacopters [24]; and Ali et al., who developed adaptive backstepping for the attitude and altitude of coaxial octorotors [25].
The use of more rotors can produce high costs in production, a considerably increased size of the UAV and complex dynamics. Nowadays, it still a challenge to design effective controllers that ensure good performance in multi-rotors at high-speed trajectories. Precise trajectory tracking is an important feature for multi-rotors operating in real-world environments due to the considerable size of the structure and possible collision with obstacles. The main reasons that make this configuration more complex than the others are presented below: (i) System actuation: An inherently under-actuated system due to there only being four control inputs over the six degrees of freedom (DOF). (ii) Dynamics behavior: high nonlinearities produced by translational and rotational dynamics due to the considerable size of the system. (iii) Dynamic model mismatch: Unmodeled dynamics, uncertainties and disturbances produced for high-speed trajectories and the possibility of external forces such as wind in outdoor environments. All of these problems incited the special attention of researchers from different fields. As a consequence, a wide variety of control strategies have been proposed for the problem of trajectory tracking for hexacopters. Initially, some linear control methods were presented, and these works considered small angles' assumptions that are necessary for linear control techniques, and the most common structures were presented by Alaimo et al., who developed a proportional-integral and derivative controller (PID) under linear assumptions in UAVs with an hexacopter configuration [26] and Salim et al. presented optimum linear control that stabilizes the attitude of a micro-hexacopter in indoor environments [27].
Linear models are only valid around the hover position, providing slow movements where the controllers cannot guarantee the convergence to the desired trajectories. In order to improve the performance and to satisfy the requirements of high-speed trajectories, a large number of studies have used the principles of nonlinear control, e.g., Chen et al., who proposed a nonlinear trajectory controller for UAVs based on backstepping and nonlinear observer [28] and Wang et al. presented the sliding mode control (SMC) with a variable structure to generate the control inputs [29]. Recently, many authors have proposed using geometric tracking controllers, e.g., Lee et al. showed the results of trajectory tracking using a nonlinear controller developed in a Euclidean group SE(3) [30]; Mellinger et al. revealed the differential flatness properties in UAVs and the ability to derive the attitude, acceleration and angular rate [31]. The property of differential flatness improves the accurate trajectory tracking under high-speed references and it was demonstrated by [32,33]. In recent years, intelligent control approaches were used to developed advance control systems, and these schemes included artificial neural networks and fuzzy logic controllers that are highly used in multi-rotor UAVs; the results present interesting behaviors under disturbances and parameter changes [34][35][36][37].
Unlike multi-rotor control techniques, obstacle avoidance has not been highly developed by the research community. Obstacle avoidance is a relatively new field and most works have used the concept of artificial potential fields, a method which is based on the generation of repulsive and attractive forces that allow the movements of the system around obstacles. The literature presents the extensive applications with UAVs, but these works revealed the problem of a local minimal that cannot guarantee the execution of the task [38,39]. Nowadays, other methods have been proposed to solve the problem of obstacle avoidance, the most popular among which include: (i) rapidly exploring random tree (RRT), a formulation which generates a tree rooted at the initial configuration of the system and using random samples to create edges between feasible points. The work by Achtelik et al., who presented an RRT algorithm with a modification rapidly exploring random belief tree (RRBT), which was used to generate the collision free path using quadrotor UAVs [40]; (ii) The belief roadmap, which is a probabilistic version of the roadmap, which uses the Kalman filter for the planning motion, and has the ability to generate trajectories by avoiding obstacles; this structure was presented by [41]. (iii) The minimum snap trajectory generation this algorithm includes navigation through corridors whilst considering con-straints on velocities and accelerations, the solution to which is based on the generation of optimal trajectories that minimizes a functional cost confirmed by square norm of the snap, an application of which was presented in [31]. All the obstacle avoidance algorithms presented beforehand only consider the prior knowledge of the obstacle in the environment, whilst also requiring high computational times and complex operations.
Taking into account the problems of no-dynamics constraints and only the prior knowledge of environments, the results thus produce unfeasible control actions and problems in dynamic environments with highly probabilities of collisions during the task execution. To fully exploit hexacopters' capabilities and take advantage of the available computation power, optimization-based control techniques are becoming suitable for real-time problems. Model predictive control (MPC) has been used in many fields of robotics due to the accuracy of its tracking trajectories, robust performance and the ability to include constraints in the controller scheme. In function of the field, the general applications can be divided into the following groups: • Ground mobile robots: where Sani et al. presented nonlinear model predictive control (NMPC) to solve the competitive games between ground robots [42], another work undertaken developed by Subramanian et al. increased the ability to avoid dynamic obstacles [43], and finally, a leader-follower structure control using NMPC through visual information to mobile robots was presented by Ribeiro et al. [44]. • Robotic arms and manipulation: In the last year, this field of research has been the focus of many studies due to the complexity of the systems and the scalability of the NMPC structure. The work of Osman et al. presented a task-space controller based on (NMPC) to control a mobile manipulator 10 (DOF) [45]. • Aerial mobile robots: this field has also been the subject of a large number of studies due to the high use of aerial vehicles in real-world applications, some applications of which were studies Neunert et al., who developed an unconstrained nonlinear predictive model for generation and tracking trajectories for the AscTec Firefly hexacopter [46]; Aoki et al., who presented an NMPC for position and attitude control applied in a hexacopter without three of the six motor configurations [47]; and finally, the contribution of Tzoumanikas et al., a letter which presented the NMPC designed for micro aerial vehicles (MAVs) equipped with a robotic arm [48].
This kind of controller has had a huge impact on the field of robotics thanks to the predictive behavior and ability to introduce system constraints in the controller scheme. The main idea of this controller is to generate the control actions trying to minimize a cost function over a prediction horizon. The cost function is solved using constrained optimization techniques; however, the resolution of constrained optimization problems is computationally expensive. Due to the recent developments in hardware and nonlinear optimization solvers, nonlinear predictive control is computationally applicable in many fields and has received the attention of a hexacopter control field [49][50][51][52][53].

Main Contributions of This Work
Run NMPC structures are realizable in modern computers and guarantee the execution of complex tasks but still require more computational time than the schemes mentioned beforehand. It is necessary to show performance under tracking accuracy and the ability to extend this technique to dynamic environments in order to add obstacles in the optimization problem. With all the aforementioned controllers and the significant results in many areas, this work presents the nonlinear model predictive control to fast trajectory tracking in dynamic environments applied in hexacopter platforms. The controller best generates the control policy that moves the hexacopter to the reference trajectory while avoiding obstacles through the environment. To construct the approach, this work developed the important contributions presented below: • System dynamics: a large number of research platforms cannot be controlled through torque commands; as such, this work developed a reduced dynamic model of the hexacopter using general control velocities, which is possible with the incorporation of low-level PID schemes in mathematical representation. The PIDs guarantee the required velocities generated by the high-level controllers. The mathematical representation was developed through an Euler-Lagrange formulation and the data-driven technique known as dynamic mode decomposition (DMDc). Both approaches were identified using experimental data from the (DJI MATRICE 600 PRO); furthermore, this work presents accuracy comparative results between both techniques and selects the best formulation to build the controller scheme. • NMPC formulation: this includes the differential kinematics and the reduced dynamic representation; furthermore, due to the ability of the NMPC controller, the system constraints can be included in the optimization problem. The constraints included in this work are: control action limits, control rate of change, and the system dynamics and static and dynamic obstacles. The nonlinear optimization problem was solved using CasADI framework and the problem was transformed into a nonlinear programming problem (NLP) form using the direct multiple-shooting method. The CasADI optimization toolkit guarantees a fast convergence with the possibility of extending the solution to onboard hardware implementation. • Results: the experiments were conducted in real-world outdoor environments, where the system has a model mismatch and external disturbance product by air flows and delay in system communications. The experiments were developed through the hexacopter platform (DJI MATRICE 600 PRO) where multiple reference trajectories were selected in order to verify the performance of the controller. The metrics used in the experiments are the following: tracking accuracy, computational time and disturbance rejection. Additionally, the simulation results show the scalability in simulated high dynamic environments, considering the identified dynamics and obstacles; these results will be used as a start point in future research due to the fact that the hexacopter aerial platform does not have any sensor to measure obstacles during the experiments.

Outline
This work is structured as follows. Section 2 presents the instantaneous kinematics with the reduced dynamic model and system identification and validation. Furthermore, the controller formulation is presented in this section, which consists of the nonlinear model predictive controller with an obstacles avoidance scheme. Section 3 shows the realworld experiments and simulation results; furthermore, considering the experiment results, this section exhibits a review of the important aspects and the future research direction. The conclusions of the work are presented in Section 4.

Hexacopter System Preliminaries
This section presents the instantaneous kinematics and the dynamic model. The dynamic model was formulated in maneuverability velocities space using two different formulations: the Euler-Lagrange and dynamic mode decomposition. After the formulation process, this work presents the validation results in order to verify the performance of each formulation. Figure 1 shows the hexacopter platform DJI MATRICE 600 PRO, where the worldfixed inertial frame is represented by < I > with the following unit vectors I x , I y , I z and the body-fixed frame attached to hexacopter movements is defined by < B > with the unit vectors B x , B y , B z , where the center of mass (CoM) is aligned; furthermore, the hexacopter is configured with six motors in the mechanical frame which allows the movement of the system.

Kinematics Model
The robot has the ability to move through the inertial frame < I > and it is enabled to rotate only in yaw ψ defined in the vertical axis B z , whilst the others' angular rotations roll and pitch (φ, θ) are not considered in this work due to this hexacopter platform having a low level flight controller which guarantees the hover position. The position and orientation of the point to be controlled is defined by the vector η = η x η y η z η ψ T ∈ R 4 with respect to the frame < I >, and the following equation defines these elements in greater detail: where the values (η x 0 , η y 0 , η z 0 ) are the locations of the CoM and (d x , d y , d z ) are the distances in the body-fixed frame < B > to the point of interest η. In order to know the evolution of the interest point, it is necessary to introduce the concept of the instantaneous kinematic, defining the time derivative asη = ∂η ∂t µ. With these considerations, the velocity of the point is defined by the vectorη = η xηyηzηψ T ∈ R 4 with respect to the frame < I >; furthermore, the time derivative produces maneuverability velocities µ attached to the frame < B >. Due to the low-level PIDs controllers, the maneuverability vector is defined by µ = µ l µ m µ n ω T ∈ R 4 , with the longitudinal velocities (µ l , µ m , µ n ) through the axis (B x , B y , B z ) and the angular rate of change ω over unit vector B z . Using the definition of instantaneous kinematics, the evolution can be defined by the following equation: the equation presented before can be written in a matrix form, defined as: where the expressions −(d x sin(ψ) + d y cos(ψ)) and (d x cos(ψ) − d y sin(ψ)) represent the additional behavior considering the displacement of the point of interest. To simplify the notation, Equation (3) is expressed in the compact form in (4) where J(ψ(t)) ∈ R 4×4 is the Jacobian matrix which allows the linear mapping between the control maneuverability velocities µ to the evolution of the point of interestη, Equation (3) is expressed in vector-function form as: Considering thatη(t) = d dtη , the following relation was developed: it can be written in compact form asη(t) = J(ψ)μ(t) +J(ψ, ω)µ(t), whereμ = μ lμmμnω T ∈ R 4 is the vector of maneuverability accelerations, and this formulation will be used in the dynamic model section.

Dynamic Model
This section presents the dynamic model, which has been developed considering low-level PIDs controllers that only generate longitudinal movements in I x , I y , I z and the angular rotation through B z . The dynamic model is useful for guaranteeing the stability of the proposed controller in real-world applications.

Euler-Lagrange Formulation
One of the approaches to find the mathematical model is the Euler-Lagrange formulation. This formulation is a convenient analytical method for obtaining the dynamic model and studying the physical phenomena of the hexacopter. The Euler-Lagrange formulation uses the total energy of the system confirmed by kinetic and potential energy. The total kinetic energy is defined by the following equation: where M = diag(m, m, m, I) is a diagonal matrix confirmed by the mass of the hexacopter m and the moment of inertia I around the vertical axis B z . On the other hand, the potential energy is the position or configuration of the system with respect to the world-fixed frame < I >, and the potential energy is described by: where g represents the gravitational acceleration. The Lagrange formulation is obtained by the subtraction of the kinetic T(η) and potential V(η) energy expressed as: Now, applying the Euler-Lagrange formulation: where f I = f x I f y I f z I τ ψ I T ∈ R 4 are the generalized forces and torque vector with respect to the frame < I >; with this formulation, it is possible to obtain the nonlinear model by the following equations: the equations presented in (11) can be written in a matrix form, resulting in: To simplify the notation, this work compacts Equation (12), resulting in the following classical representation: (13) whereH ∈ R 4×4 is the mass and inertia matrix of the hexacopter system, in addition to being positive and symmetric definite;C ∈ R 4×4 is the matrix of Coriolis forces and g ∈ R 4 is known as the gravitational vector. Vectorsη = η xηyηzηψ andη = η xηyηzηψ are the acceleration and velocity of the point of interest in the inertia frame < I >.
Due to the fact that the hexacopter platform can be controlled through reference maneuverability velocity commands, this work converts the generalized force and torque inputs of the dynamic model (13) into reference maneuverability velocities as system control inputs. Considering the position dynamic model presented in [54] which considers all DOF in a multirotor: it can be written in a compact form asμ = w x µ + gR(θ, φ, ψ) T e 3 − f z m e 3 , where w = w x w y w z are the angular velocities associated with the frame < B >, w x represents skew symmetric matrix and finally R(θ, φ, ψ) represents the rotation matrix from the frame < B > to < I >. For any multicopter, drags applied to rotating blades are in the direction of the body axes; from (14), the position dynamic model considering the aerodynamic drag model is represented as: whereμ l ,μ m are the accelerations in the body frame < B > and k drag is the drag constant. To include the drag coefficients in the dynamic model, this work split Equation (14) and can be written as: where a x =μ l + g sin(θ) and a y =μ m − g cos(θ) sin(φ). Since the low-level controller guarantees hover, the cross terms are ignored, so the specific force satisfies: where the forces produced in the system f hB = f x f y are generate by a PD controller for the horizontal plane. The PD controller was designed as: where µ h = µ l µ m T ∈ R 2 is the vector of the horizontal maneuverability velocities, is the reference desired velocity and k pl , k dl are positive definite matrices. For the PD controller, this work used the following assumptions iḟ µ h re f = 0 then lim t→∞ f h = 0 and lim t→∞ μ h = 0, respectively. A similar concept was applied to the vertical force attached to the body frame f z B = f re f + mg. Designing a PD controller for the vertical thrust as: where k pn , k dn are positive definite matrices, this work considers the following assumptions ifμ n re f = 0 then the lim t→∞ f z I = 0 and lim t→∞ μ n = 0, respectively. The same approach can be extended to the attitude dynamic model presented in [54], which is defined as: where τ τ x τ y τ ψ ∈ R 3 is the vector of moments in the body axes < B >; J B ∈ R 3×3 includes the moment of inertia and G B G B,φ G B,θ G B,ψ T ∈ R 3 represents the gyroscopic torques. Ignoring the term −w × (J B · w) + G B , the simplified attitude dynamic model is defined as: J Bẇ = τ ψ , where a PD controller for angular translations is defined as: where k pω , k dω ∈ R are positive scalars and the following assumptions are true ifω re f = 0; then, lim t→∞ τ ψ = 0 and lim t→∞ ω = 0, respectively. After all the considerations presented beforehand, this work introduces the general structure of low-level PD controllers combining Equations (18), (19) and (21), finally the structure is presented in Equation (22).
Equation (22) (4) and (6) are substituted into a dynamic hexarotor model (12), and equating the expression to (22), a new reduced dynamic model can written as: This new formulation represents the evolution of the hexacopter's general velocities with the reference maneuverability velocities as the input of the system. This representation is useful because commercial aerial platforms can be directly controlled with maneuverability velocities, ignoring the low-level control. Equation (23) can be compactly written as: where H = (RK p ) −1 ((HJ + RK d ), C = (RK p ) −1 (HJ + RK p +CJ) , G = (RK p ) −1 (g − RḠ)) = 0. Thus, H(ζ, a, b) ∈ R 4×4 is a positive definite matrix, which is the new mass and inertia matrix of the hexacopter robot, the new Coriolis and Centripetal matrix is defined by C(ζ, µ) ∈ R 4×4 , R represents the rotation matrix under the z axis from frame < B > to frame < I >. The vector of dynamic parameters represents the combination of all the internal values in the hexacopter robot such as the physical, mechanical, electrical and PD values, and the vector is defined by ζ = ζ 1 ζ 2 . . . ζ l d ∈ R l d where l d = 19 is the number of variables that this work needs to identify as the details of each parameters are presented in Appendix A for Equations (A1) and (A2).

Euler-Lagrange Identification and Validation
This section presents the identification and validation of the dynamic parameters, as this work uses real experimental data to estimate these values in order to use the model in the proposed controller. This work transforms the mathematical model (24) in the linear parametric representation into: Model identification cost: this function was formulated using the subtraction between the reference maneuverability µ ref (l|t) velocities applied in the hexacopter and the system measurements defined by the matrix Θ(μ(l|t), µ(l|t)); the operator || · || is known as the Euclidean norm; and Q m ∈ R 4×4 >0 is a positive definite weighting matrix. With Equation (26), it is possible to generate the functional cost or performance index over the experimental data, which is formulated as follows: Considering the performance index function presented in (27), the optimization structures are defined in (28), which was solved using the sequential quadratic programming (SQP) technique.
This work used the experimental information of the hexacopter platform DJI MATRICE 600 PRO to identify the dynamic parameters. The aerial system has a low-level flight controller called A3, which is confirmed by three global positioning systems (GPS) and three inertial measurement unit systems (IMUs). Furthermore, this system provides highly precise measurements from the system states. The identified parameters are presented in Table 1; furthermore, for the identification and validation process, this work used a different kind of reference velocity signals.  Figure 2 shows the results of the identification process, where the signals µ l , µ m , µ n and ω were obtained by real-world experiments; and µ lm , µ mm , µ nm and ω m are the estimated values of the dynamic model using the optimization formulation presented previously. The presence of noise in the signals is an important factor due to the fact that it probably causes problems in the identification process; this work uses a filter defined as: λ/(s + λ) with λ = 1 to eliminate noise in the real measurements. The filter was applied to the system measurements and the reference maneuverability velocities. The validation process of the dynamic parameters is a very important factor; hence, the model needs to estimate the behavior of the system with different signals in order to represent the real dynamics of the system. The validation signals are shown in Figure 3, the validation process shows the performance of the estimate dynamic model, which will be useful for the comparative section. With all the previously presented results and the validation of the dynamic parameters, this work formulates the identified model using Euler-Lagrange as a vector-function presented as:

Dynamic Mode Decomposition Formulation
This section presents the second approach of the dynamic model formulation which, due to the hexacopter platform, only has internal low-level PIDs; and the system tries to stay close to the hover-position with small angular variations in roll and pitch angles (φ, θ). Furthermore, this kind of hexacopter platforms cannot be controlled with the torques commands, and the control inputs at the system are the reference maneuverability velocities µ ref . Considering the small angle assumptions and the inputs in the system, the model can hence be formulated with a linear approximation for time-varying systems resulting in: where µ andμ are the vectors of the maneuverability velocities and accelerations; µ ref is the reference maneuverability velocity vector also known as the control vector; matrices A ∈ R 4×4 and B ∈ R 4×4 represent the unforced system and the contribution of the control vector, respectively. One of the emerging techniques to identify systems by experimental information is that of dynamic mode decomposition (DMD) [55][56][57], where the objective is to approximate the matrices A and B. The DMD algorithm proposes the construction of snapshot measurements s and the formation of augmented matrices, resulting in a new formulation of the system as follows:χ ≈ Aχ + BΓ where the new matrices are defined below: χ and χ are the augmented matrices confirmed by the maneuverability accelerations and velocities, respectively; and Γ is the matrix of the reference velocities applied in the system over the s number of snapshots. For estimation purposes, the system can be formulated as: where Φ = A B ∈ R 4×(4+4) is the matrix confirmed by unknown values of A and B; and Ω = χ Γ T ∈ R (4+4)×s is the data matrix obtained from the system. This work finds the best values of the unknown matrix using the Frobenius norm ||χ − ΦΩ|| F , defining the values in the following equation: One of the best methods to find the solution of the Frobenius norm is the singular value decomposition (SVD); therefore, applying this method to the augmented data matrix resulting as Ω ≈ŪΣV T , whereŪ,Σ andV are matrices with a truncation valuer, with these considerations presented above, the estimation is defined by the following equation: To approximate the values of the matrices A and B, the Equation (34) can be written as (35), considering the splitting values of the singular vectorŪ .
The values of the matrix A can be approximated using the split matrixŪ 1 ∈ R 4×r and the values of B are approximated using the values ofŪ 2 ∈ R 4×r .

Dynamic Mode Decomposition Identification and Validation
This section presents the identification and validation process of the dynamic model using the DMD formulation. The values of matricesχ, χ and Γ were constructed by measure snapshots information of the aerial platform DJI MATRICE 600 PRO and the application of Algorithm 1, which represents all the necessary steps to identify the values of unknown matrices.
The approximation values of the unknown matrix are presented in Tables 2 and 3, where, a ij and b ij are the individual elements ofĀ andB, respectively.
The signals used for the identification process are presented in Figure 4, which are the same as those used for the identification process employing Euler-Lagrange formulation, due to the fact that both techniques need to estimate the values under the same conditions.

Algorithm 1 Identification process Using DMD
Input: DJI MATRICE 600 PRO measurements (χ, χ, Γ) and truncation valuer. Output: MatricesĀ andB. Ident (χ, χ, Γ,r) do end Ident return (Ā,B) Table 2. Approximation values of unforced matrix.  Table 3. Approximate values of control actuation matrix. The estimated model displays good behavior due to the fact it replicates the signals obtained from experimental data. The noise in the angular maneuverability velocity ω is an important factor, however, dynamic mode decomposition and the robustness of the Frobenius norm can deal with this noise and the application of filters is not necessary in the identification process.

Matrix Approximated Values
In the same way presented in the validation process using the Lagrange formulation, this section presents the validation process under DMD formulation, the results of which are shown in Figure 5, which shows the good performance of the proposed technique.

Accuracy Comparative Results
This section presents the comparative results between the Euler-Lagrange (29) and dynamic mode decomposition (36) formulations. This work uses the integral square error (ISE) to show the performance of each formulation and selects the best one for the nonlinear model predictive controller structure. Figure 6 shows the ISE of each formulation, where the model for frontal maneuverability velocity µ lm presents a considerable error using the Euler-Lagrange formulation-with a value of precisely 1.  With the previously presented results, this work uses the DMD estimated model to construct the proposed controller. Combining Equations (5) and (36), the general mathematical representation is defined as: where x = η T µ T T ∈ R 8 is the generalized vector of the system states that is confirmed by η, which is the pose of the point of interest in the hexacopter and µ is the maneuverability velocities.

Control Methodology
This section presents the formulation of the proposed controller, where the main objective is the trajectory tracking over the desired reference trajectory using an hexacopter platform and due to the dynamic effects and the important size of the system, this work includes obstacle avoidance to improve the behavior of the system in dynamic environments. This work presents the nonlinear model predictive controller (NMPC); furthermore, the constraints included in the optimization problem were: generalized system dynamics, bounded maneuverability velocities, rate of change of control velocities and obstacles in the dynamic environment. The main objectives of the proposed controller are: to solve the control problem associated with the trajectory tracking subject to the system and the environment and system constraints. The control problem is solved by the scheme shown in Figure 7, where the structure uses the system information and possible obstacles in the environment to generate an optimal control policy under the system constraints.

Nonlinear Model Predictive Control
In order to solve the NMPC proposed scheme, this work formulates the generalized dynamics (37) as a prediction, resulting in: (38) where l ∈ [t, t + T] is the instant value evolution between the initial time t and the prediction horizon T. Due to the prediction behavior of this scheme, the NMPC formulation requires index performances over the prediction horizon T that guarantees the solution of the control problem and the system constraints. The generation of the performance functions are presented below.

Tracking Trajectory Formulation
This subsection presents the generation of the cost function over the evolution instants l considering the following property: to formulate the function as: Control stage cost (39) Trajectory Stage Cost: this part of the function is structured by the control error between the desired trajectory η ref = η x re f η y re f η z re f η ψ re f T ∈ R 4 and the measurements of the system x; the constant matrix W t ∈ R 4×8 produces linear mapping between all the states of the system and the outputs η x , η y , η z and η ψ ; the Euclidean norm is defined by the operator || · ||; finally, Q t ∈ R 4×4 >0 is a constant positive definite matrix. Control stage cost: this part of the cost function defines the variations between the maneuverability control velocities µ ref (l|t)) considering that Q u ∈ R 4×4 >0 is a positive definite weighting matrix.
The cost function at the last step of the prediction horizon T was formulated with following property: T (x(t + T|t), η ref (t + T|t)) : R 4 → R ≥0 ; with this consideration, the cost function is defined as: Terminal trajectory cost: this term considers the control error between the reference trajectory at the last step of the prediction horizon T, where Q T ∈ R 4×4 >0 is a positive definite weighting matrix.
This work uses Equations (39) and (40) to generate the performance index over the prediction horizon, which was developed in the continuous time formulation, where τ is the interval analyzed in the integral operation, and the performance index is defined as: The performance index function (41) guarantees the trajectory tracking propriety of the controller. The tuning process of the positive definite matrices were developed in the simulations in order to prevent accidents in real-world experiments.

Maneuverability Velocities Constraints
Due to the hexacopter platform having maximum maneuverability velocities, this work proposes control input constraints on the NMPC structure, in addition to further constraints on the successive difference of the maneuverability velocities which were included to prevent aggressive behaviors. The input constraints are defined in (42) in order to maintain the control signals generated by the proposed structure under the limits of the hexacopter platform where µ ref min ∈ R 4 and µ ref max ∈ R 4 are the vectors of lower and upper limits in maneuverability velocities; to the successive difference, this works considers j ∈ [t, t + (T − 1)] and ∆µ ref max as the vector of the maximum rate of change between the maneuverability velocities.

Obstacle Constraints
This section presents the obstacle constraints in order to track the desired trajectory and avoid obstacles in the dynamic environments. The obstacles can be defined as ξ obs (i|z) = where i ∈ [z, z + Z] considering the analyzed obstacle as z and Z the number of obstacles detected by the system, the representation of the obstacles is shown in Figure 8. The function of the distance between obstacles and the hexacopter has the following property: obs (x(l|t), ξ obs (i|z)) : R 4 → R ≥0 , and the equation is formulated as: obs (x(l|t), ξ obs (i|z)) = Distance to Obstacles ||ξ obs (i|z) − W o x(l|t)|| 2 (43) where W o ∈ R 3x8 is a constant matrix that produces linear mapping between all the states of the system and the outputs η x , η y and η z . With the previously presented considerations, this work formulates the system states constraints in (44), and where the safe region was defined as r obs ∈ R >0 , this value includes the safely region and the rotating blades' positions.

Nonlinear Model Predictive Control Formulation
Considering the performance index presented before (41) and the system states (44) and control (42) constraints, this work can formulate the optimization problem as: with the following constrains: x(l|t) ∈ r obs − obs (x(l|t), ξ obs (i|z)) ≤ 0 (45c) P is the function that guarantees the correct trajectory tracking and obstacle avoidance of the hexacopter system. The optimal control problem (45a) was converted into a nonlinear programming formulation (NLP) using the direct multiple shooting method, where the control maneuverability velocities µ ref (l|t) and the system states x(l|t) are the decision variables of the optimization problem. A multiple shooting technique is more computationally efficient when it is compared with other discretization formulation, e.g., single shooting, more information in [58]. The system model was considered as the optimization constrain defined by (45b), the system and control constraints formulated in (45c) and (45d), respectively. With these considerations, this work minimizes the nonlinear programming problem using CasADI as a nonlinear optimization framework [59].

Results and Discussions
This section presents the simulations and experimental results to validate the proposed controller for the hexacopter platform DJI MATRICE 600 PRO. The experiments were performed considering: (i) Real-world experiment: the results presented in this section were developed using the nonlinear model predictive controller and environment obstacles are not considered in this experiments due to the hexacopter platform not having the required sensor for real-world measurements. (ii) Simulation experiment: simulation experiments show the effectiveness of the proposed controller in highly dynamic simulation environments with simulations of the dynamic behavior of the hexacopter in order to make it more realistic and prove the scalability of the controller.

Real-World Experiments
Several experiments on trajectory tracing were performed in order to demonstrate the performance of the proposed controller. In order to demonstrate the effectiveness of the optimization structure, the controller was implemented at onboard computer of the hexacopter through the software Matlab, additionally the hexacopter platform is shown in Figure 9 with the following hardware features Intel processor i7-7700HQ and CPU 2.80 GHz × 8. The controller was developed considering the optimal control problem (45a), the evolution of the identified model was developed using the fourth-order Runge-Kutta method, with a sample time of t s = 0.1[s] and the final time of the experiment is defined as t f = 100[s].   The desired reference trajectory for the hexacopter and the initial conditions are defined in Table 4  To implement the proposed controller, the constant values of positive definite matrices are defined in Table 5, and were obtained through a variety of experiments in order to improve the performance of the controller scheme. Table 5. Proposed values for the NMPC scheme in a real-world experiment.

Parameters
Values Parameters Values The results of the experiment are illustrated in Figures 11-14. Figure 11 shows the movement of the hexacopter platform based on real information over the experiment. The hexacopter tracks the desired reference trajectory; however, the results present a small control error in the trajectory due to the wind velocity that acts as an external disturbance.
The reference trajectory is defined as η ref = η x re f η y re f η z re f η ψ re f and the hexacopter system states during the experiment were confirmed by η. The previously presented results show the performance of the controller that guarantees the execution of the reference trajectory over different axes. The control signals represented in Figure 12 are generated by the proposed control scheme, the external disturbances produce a miss match in the model but the controller generates the adequate smooth control actions.  Figure 13 shows the control errors of the proposed controller, whereη x ,η y ,η z andη ψ are the results from the steady state error that asymptotically converge to values close to zero, i.e., since these position errors are bounded and different from zero η ref (t) − W t x(t) = 0 ∈ R 3 , it is achieved that the errors in the steady state are |η| < 0. 15[m]. In addition, the control error maintains a dependency on the external disturbances in the outdoor environments, and external disturbances are the product of the wind velocity which was approximately 10 km/h.
The time required to solve the optimal control problem is shown in Figure 14, and the computation time stays always below the sample time t s = 0.1 [s], guaranteeing the efficient computation of the proposed control considering the time horizon of T = 2 [s] in the optimal control problem.

Simulation Experiments
This section presents the simulation result of the proposed controller. In order to improve the results, this experiment was performed using the identified dynamics in Equation (36) with the identified parameters presented in Tables 2 and 3 . Furthermore, a Gaussian noise with the following consideration in all the states η n ∼ N (−0.05, 0.05) and µ n ∼ N (−0.01, 0.01), where η n and µ n are the additive noise in position and velocity states, was identified.
The desired reference trajectories and initial values over the frame < I > are defined in Table 6. Table 6. Desired reference trajectory in the simulation experiment.

Initial Positions
Initial Maneuverability Velocities Reference Trajectory The desired values of the reference trajectory are the same as the proposed in realworld experiments; therefore, the results present similar behavior. The controller constant values are the same as those presented in Table 5. However, the safe region distance was defined as r obs = 0.4[m].
The trajectory described by the hexacopter platform and the reference trajectory are presented in Figure 15. The results show that the hexacopter tracks the desired reference trajectory, in addition to the avoidance obstacles property being demonstrated due to the system following the reference and trying to maintain the distance to obstacles considering the safety radius r obs . The three obstacles were positioned over the reference trajectory, two of which were positioned at the corners are dynamic obstacles and they have movements during the experiment.
The values of the control errors presented in Figure 16 tend to increase when the hexacopter avoids the obstacles satisfying the system constraints, a phenomenon which is represented in the rectangles representing obstacles close to the hexarotor. Given that the errors in steady stateη x ,η y ,η z andη ψ symptomatically converge towards zero in the presence of the Gaussian noise applied in the simulation, the results show the robustness under this type of disturbance and the ability to keep the system under the reference trajectory, i.e., the position errors are bounded and are different from zero η ref (t) − W t x(t) = 0, achieving a final characteristic error with a max |η| < 0.9[m] when the obstacles are close to the hexarotor and |η| < 0.1[m] without obstacles near the system reference trajectory. The control signals are presented in Figure 17, which are generated by the proposed control scheme. Taking into consideration the dynamics of the robotic system and the simulated environmental conditions, the behavior of the reference velocities are close to the dynamic model values. Furthermore, the values are presented as smooth curves with the presence of peaks when the obstacles are close to the hexacopter which are emphasized by the rectangles shown in Figure 17. The behavior of the control actions prevents collisions between the hexacopter and the obstacles during the simulation.
The time required to solve the proposed controller and the Euclidean distance are presented in Figure 18, and the computational time is an important factor to demonstrate its ability to generate an adequate control policy that guarantees the system constraints. The computational time presents peaks produced by the obstacles that are close to the hexacopter during the trajectory whilst the controller finds a sub-optimal solution to guarantee that the computational time remains under the sample time; however, this problem can be efficiently solved using another low-level language to implement the proposed controller or with a more powerful computer, which is therefore a solvable technological issue. On the other hand, the distance to each obstacle shows that the proposed controller respects the safely radius, guaranteeing the avoidance property of the system.

Discussion
The experiments presented in the last section show that the nonlinear model predictive scheme solves the control problem associated with the trajectory tracking subject to the system and environment constraints. Specifically, the real-world experiments showed the robustness of the proposed controller due to the excessive wind velocity during the experiment which acted as an external disturbance. Despite the excessive wind velocity, the controller generates the adequate smooth control actions guaranteeing that the steady state error that converges towards values close to zero with the dependency of the external disturbances. The use of CasADI such as an optimization framework guarantees the fact that the computational time always stays below the sample time, which is one of main problems in NMPC schemes due to the highly computational time that these solutions required, as similar computing times were presented in [45].
On the other hand, the simulation results show the ability of the proposed scheme to generates the adequate control signals guaranteeing the corrected tracking trajectories while the system avoids obstacles during the simulation. The presence of Gaussian noise provides uncertainty in the measurements demonstrating the power of the controller as it maintains the distance to obstacles in consideration of the safety radius. One of the main differences presented in this experiment was the control error, which tends to increase when the hexacopter avoids obstacles satisfying the system constraints. Furthermore, the computational time presents peaks produced by the hard constraints included in the optimization problem, and despite the hard constraint, the controller finds a sub-optimal solution to guarantee a low computational time. Other works have used the concept of soft constraints, low-level programming language and embeddable optimization methods such as (SQP) in order to increase the convergence of the optimization algorithm and reduce the computational time [60][61][62][63][64]. This work uses the concept of soft constraints and the approximation of the nonlinear problem in order to improve the computational time and the future implementation on a single on-board PC.

Conclusions
This work carried out the identification of a dynamic system using the dynamic mode decomposition with control technique to develop the optimal control problem for trajectory tracking with obstacle avoidance, a decision which was made due to the precision of the comparative results between the Euler-Lagrange and the dynamic mode decomposition formulations. The optimal control problem was translated into a nonlinear programming problem (NLP) using the multiple shooting technique and considering the control actions and systems states as decision variables, which is a technique that improves the computational time and the convergence of the algorithm. The nonlinear model predictive control (NMPC) generates the maneuverability velocities policy that allows the hexacopter platform to track the reference trajectory while avoiding obstacles presented in the environment.
The NMPC formulation was developed in consideration of the reference desired trajectory and constraints in the system such as the bounded control actions, the generalized dynamics and static and dynamic obstacles. Furthermore, the NMPC problem was solved through the nonlinear programming framework CasADI, which solves high-dimensional optimization problems and has advantages that can be expanded to a low-level programming language to improve the computational time.
The simulation results show how the hexacopter avoids both static and dynamic obstacles whose locations vary over time while executing the trajectory tracking task, and always maintaining a safe distance defined as a radius of repulsion. Since there is no sensor for obstacle measurements in the hexacopter platform, the real experimental tests were not carried out with obstacle avoidance; however it was verified that although the experimental tests were carried out during the period of time in which the average wind speed was approximately 10 km/h, the behavior of the control law on the hexacopter system fulfills the desired task, so that the control errors in stable state converge closer to zero. In addition, it can be observed that the steady state error asymptotically converges towards values closer to zero under conditions wherein the control actions are saturate when they reach the established restrictions. On the other hand, the computational time of the proposed control algorithm is maintained under 100 ms in real experimentation due to the optimization technique used to solve the control problem. During the simulation tests, it is clearly verified that the computational time remains under 100 ms; however, when obstacle avoidance occurs, this time increases but remains under the specified sample time with a sup-optimal solution. Other works use the concept of soft constraints to guarantee the rapid convergence of the optimization algorithm, as this work will use the same concept to improve the computational time and the possible expansion to visual-servoing systems under an MPC structure.