| Algorithm 2. Execution Procedure of the PSMC Position Controller |
| Input: Current UAV state Desired reference , System matrices MPC horizons: prediction horizon , control horizon Weighting matrices Input and state constraints PSO parameters Compute tracking error: Linearize nonlinear UAV dynamics at operating point : Obtain linear system: Construct standard MPC cost function: Formulate MPC constraints: State limits: Input limits: Terminal condition: optional Solve convex MPC optimization problem to obtain Initialize PSO search around : Define particle positions as perturbations around Define PSO objective function: Run PSO optimizer (see Algorithm 1) to minimize Obtain best particle Compute final control input: Apply to UAV system Wait for next sampling interval and repeat Output: Optimized control input |