Drone Trajectory Tracking with Python#
The dynamics and kinematics of a drone are crucial in understanding and controlling its flight behavior.
1. Dynamics and Kinematics of the Drone#
The drone’s state can be described by its position \(x, y, z\), orientation (roll \(\phi\), pitch \(\theta\), and yaw \(\psi\)), and their respective velocities and angular velocities.
Translational Motion#
The translational motion of the drone can be described by Newton’s second law of motion:
where:
\(m\) is the mass of the drone.
\(\ddot{\mathbf{r}}\) represents the linear acceleration.
\(\mathbf{F}\) is the total thrust force generated by the drone’s motors.
\(g\) is the acceleration due to gravity.
\(\hat{z}\) is the unit vector in the vertical direction.
Rotational Motion#
The rotational motion of the drone is described using Euler’s equations of motion for a rigid body:
where:
\(I\) represents the moment of inertia matrix.
\(\boldsymbol{\omega}\) is the angular velocity vector (p, q, r).
\(\boldsymbol{\tau}\) is the vector of external torques acting on the drone.
Dynamic System Matrix#
The dynamics of the drone can be represented in a state-space format:
Where:
\(\mathbf{x}\) is the state vector.
\(\mathbf{u}\) is the input vector (like motor thrusts).
\(\mathbf{y}\) is the output vector (like measured position and orientation).
\(A\) is the system matrix.
\(B\) is the input matrix.
\(C\) is the output matrix.
\(D\) is the direct transmission matrix.
2. Control System#
Control Inputs#
The control inputs for the drone include thrust \(U_1\) and torques \(U_2, U_3, U_4\). These are calculated as:
3. Trajectory Generation#
The desired trajectory as a function of time \(t\) is:
4. Linear Parameter Varying (LPV) Systems#
LPV systems are described by:
5. Model Predictive Control (MPC)#
MPC uses a dynamic model to optimize future control actions. The objective function is:
Subject to:
Where:
\(x_k\): system state at step \(k\).
\(u_k\): control input at step \(k\).
\(x_{\text{ref}}, u_{\text{ref}}\): reference state and input.
\(Q, R\): weighting matrices.
\(N\): prediction horizon.
\(x_{\min}, x_{\max}, u_{\min}, u_{\max}\): state/input bounds.