Main Content

Quadrotor Trajectory Tracking Using Iterative Learning Control

R2026b
Since R2025a

This example demonstrates quadrotor trajectory tracking control using the Iterative Learning Control (ILC) block in Simulink® Control Design™. ILC is used in the outer-loop position control for quadrotor trajectory tracking. The quadrotor is commanded to track a circular trajectory, the vehicle is also subjected to external aerodynamic disturbance caused by wind bias. This example uses ILC over repeated iterations and the controller learns to minimize error and improve tracking of a given reference signal.

Quadrotor Model

This example demonstrates the quadrotor trajectory control using PID augmented by ILC controller. Quadrotor use two-loop cascaded control. The outer-loop control the position of the vehicle in x-y-z in the inertial frame. The inner-loop controls the attitude of the vehicle yaw-pitch-roll also in inertial frame. You use Iterative learning control in the outer loop along with the PID for position control. The inner-loop use a stand-alone PID controller.

For a 6-DOF quadrotor model, consider the following:

  • u,v,w are the vehicle velocity in the body frame.

  • p,q,r are the angular velocity of the vehicle in body frame.

  • Roll-ϕ,Pitch-θ,Yaw-ψare defined in vehicle-2, vehicle-1 and vehicle frame respectively.

  • x,y,z is the vehicle translation motion in inertial frame.

This example uses simplified quadrotor dynamics that with the following assumptions:

  • Assume the Roll-ϕ and Pitch-θangles are small and hence body rates are approximately equal to inertial rates,

[ϕ˙θ˙ψ˙]=[p˙q˙r˙]

  • Assume affect of Coriolis components are negligible, qr,pr,pq0.

  • In this example you will control position and attitude. Heading angle Yaw-ψis assumed to be held zero.

With these simplifying assumptions, the quadrotor model can be written as [1],

  • Outer-Loop quadrotor dynamics for position in inertial frame:

x¨=-cos(ϕ)sin(θ)Fmy¨=sin(ϕ)Fmz¨=g-cos(ϕ)cos(θ)Fm

  • Inner-Loop quadrotor dynamics of attitude angles in inertial frame:

ϕ¨=1Jxτϕθ¨=1Jyτθψ¨=1Jzτψ

Here, F=f1+f2+f3+f4 is the total propeller forces,τϕ,τθ,τψare the torques applied to the quadrotor, m is vehicle mass, and g=9.81 is the gravitational constant.

Two-Loop Controller for Quadrotor Trajectory Tracking

The following image shows the two-loop cascaded control architecture for the quadrotor. The outer loop generates the translation forces to control the position of the vehicle. The inner loop tracks the reference attitude angles and generates body torques.

Simplifying the outer-loop translation equation of motion, you can define following control terms.

ux=-cos(ϕ)sin(θ)Fmuy=sin(ϕ)Fmuz=g-cos(ϕ)cos(θ)Fm

Here, ux, uy, and uz are the outputs of the outer-loop PID controller for quadrotor position. Using these three outer-loop control signals, you can solve for the commanded roll ϕd, pitch θd, and yaw ψd as reference signals for inner-loop control.

ϕd=tan-1(uycos(θ)g-uz)θd=tan-1(uxuz-g)ψd=0.

The inner loop implements a PID controller to track the commanded reference attitude angles ϕd, θd, and ψd.

Quadrotor Trajectory Tracking

The goal of this example is to have the quadrotor track a circular trajectory. The quadrotor starts at initial position [x0,y0,z0]=[301] in the inertial frame and executes a circle of radius R=3m. The time for quadrotor to complete one circle trajectory is Tspan=15sec.

% Set the Circular trajectory radius
R = 3;

% Quadrotor initial condition in inertial frame
IC = [3 0 -1]; % In North-East-Down co-ordinate frame

Outer Loop Position Control PID

The outer-loop control for the quadrotor tracks the reference trajectory in the x-y-z frame. The following image shows the three-axis independent controller for the quadrotor. The controller gains can be tuned one at a time using the successive loop closure method.

The individual control loops in X, Y, and Z, have baseline PID controllers designed to track the trajectory, such that xxd, yyd, and zzd.

uξ=kpξ(ξd-ξ)+kdξ(ξd˙-ξ˙)+kIξ(ξd-ξ)dt

Here, state ξ=[xyz]andξd=[xdydzd].

Specify tuned controller gains for the X and Y control loops.

% X-axis PID gains
Kp_x = 1;
Kd_x = 0.97;
Ki_x = 0.01;

% Y-Axis PID Gains
Kp_y = 0.1;
Kd_y = 2.5;
Ki_y = 0.01;

Iterative Learning Control Overview

The X and Y outer-loop position control are augmented with ILC control. Where as height (Z) is a standalone PID controller, designed to maintain the height at Z=1m. The quadrotor repeats the circular trajectory for K iterations. The ILC controller goal is to iteratively improve tracking performance. A brief description of ILC control is as follows, for more details see Iterative Learning Control.

Iterative learning control (ILC) is an improvement in run-to-run control. It uses frequent measurements in the form of the error trajectory from the previous batch to update the control signal for the subsequent batch run. The focus of ILC has been on improving the performance of systems that execute a single, repeated operation, starting at the same initial operating condition. This focus includes many practical industrial systems in manufacturing, robotics, and chemical processing, where mass production on an assembly line entails repetition.

  • Suitable for repetitive task + repetitive disturbances.

  • Use knowledge from previous iteration to improve next iteration.

A general model based ILC control update is as follows [2],

uk+1(t)=Q(q)[uk(t)+L(q)ek(t+1)]

Where L is learning function based on the system model G. In this example you use inverse model ILC, which use learning function L=G-1. where G is the input-output relation for LTI system, in the lifted form as follows yk=Guk+d.

ILC Modes

At runtime, ILC switches between two modes: control and reset. In the control mode, ILC outputs uk(t)at the desired time points and measures the error between the desired reference r(t) and output yk(t). At the end of the control mode, ILC calculates the new control sequence uk+1(t) to use in the next iteration. In the reset mode, ILC output is 0. The reset mode must be long enough such that the return to home controller in this mode brings the plant back to its initial condition.

ILC Design

To design an ILC controller, configure these parameters:

  • Sample time and iteration duration — These parameters determine how many control actions ILC provides in control mode. If the sample time is too large, ILC might not provide sufficient compensation. If the sample time is too small, ILC might take too many resources. In particular, it might create a large memory footprint when using model-based ILC.

  • Model information — This example use model based ILC. A nominal closed loop model information is necessary to design the ILC controller.

  • ILC gains — The controller gains determine how well ILC learns between iterations. If the ILC gains are too big, it might make the closed-loop system unstable (robustness). If the ILC gains are too small, it might lead to slower convergence (performance).

  • Low-pass filter time constant — The optional low-pass filter removes control chatter, which might otherwise be amplified during learning. By default, this filter it is not enabled in the ILC block.

Define the parameters for the ILC block.

% Sample Time
Ts = 0.05;

% Single iteration duration
Tspan = 15;

In this example, you use a model-based ILC approach. The nominal discrete model for the X and Y axes has the following state-space matrices.

A = [1 0.05;-0.02 0.97];
B = [0;0.05];
C = eye(2);

Specify the ILC gains for the X and Y axes.

gamma_x = 0.3;
gamma_y = 0.08;

ILC implements a low-pass filter to remove high-gain control oscillations. This filter adds a tradeoff between rate of convergence and robustness. Specify the time constant for the filter.

% Filter Coeff
Filter_coeff = 2;

Inner-Loop Attitude Control PID

The inner-loop controllers for the quadrotor track the reference attitudes. The roll, pitch, and yaw control loops each have baseline PID controllers designed to track their respective reference attitudes such that ϕϕd, θθd, and ψψd.

τξ=kpξ(ξd-ξ)+kdξ(ξd˙-ξ˙)+kIξ(ξd-ξ)dt

where ξ=[ϕθψ]andξd=[ϕdθdψd]

you do not augment the baseline PID in the inner loop with ILC. The PID controller gains kpξ, kdξ, and kIξcan be tuned one at a time using successive loop closures. In this example, you use PID autotuning in for the PID Controller block.

Simulate Model and Plot Results

To make the problem more challenging, you add an external wind disturbance to the vehicle. The disturbance is also repetitive in nature and adds drag in Y direction. The wind disturbance in Y direction is modeled as follows,

fdragY=12Cdρuy2ifx>0,elsefdragY=0

where Cd=0.1 is coefficient of drag, ρ=1kgm3 is density of air and uy is vehicle velocity in Y direction.

Simulate the model for 10 iterations. In the first iteration, ILC controller outputs 0 in the control mode because it just starts learning. Therefore, the closed-loop control performance displayed in the first iteration comes from the nominal controller, which serves as the baseline for the comparison.

mdl = "quadTrajTrackingILC";
open_system(mdl)
simout = sim(mdl);

Figure UAV Animation contains an axes object. The axes object with xlabel East, ylabel North contains 6 objects of type patch, line, scatter.

As the iterations progress, the ILC controller improves the reference tacking performance in both the X and Y direction.

Plot the quadrotor tracking performance in the X direction.

figure
hold on
grid on
plot(simout.tout,simout.x.Data)
plot(simout.tout,simout.r.Data(:,1),Color="r")
xlabel("Time (sec)")
ylabel("X")
legend("X Position","X Reference", ...
Location="northoutside",Orientation="horizontal")

Figure contains an axes object. The axes object with xlabel Time (sec), ylabel X contains 3 objects of type line. These objects represent X Position, X Reference.

Plot the quadrotor tracking performance in the Y direction.

figure
hold on
grid on
plot(simout.tout,simout.y.Data)
plot(simout.tout,simout.r.Data(:,2),Color="r")
xlabel("Time (sec)")
ylabel("Y")
legend("Y Position","Y Reference", ...
Location="northoutside",Orientation="horizontal")

Figure contains an axes object. The axes object with xlabel Time (sec), ylabel Y contains 3 objects of type line. These objects represent Y Position, Y Reference.

Get the final trajectory index.

final_traj_idx = find(simout.tout >=180);

Plot the quadrotor trajectory in the XY plane

figure
hold on
plot(simout.x.Data(1:final_traj_idx(1)-1), ...
simout.y.Data(1:final_traj_idx(1)-1),"--")
plot(simout.x.Data(final_traj_idx), ...
simout.y.Data(final_traj_idx),LineWidth=2,Color="b")
plot(simout.r.Data(final_traj_idx,1), ...
simout.r.Data(final_traj_idx,2),LineWidth=2,Color="r")
xlabel("X Position")
ylabel("Y Position")

% Plot Wind disturbance vector plot
quiver(simout.x.data(:,1),simout.y.data(:,1), ...
simout.wind.Data(:,1),simout.wind.Data(:,2),Color = "m")
axis equal

legend("All Iterations","Final Iteration", ...
"Reference","Wind distrubance",Location="best")

Figure contains an axes object. The axes object with xlabel X Position, ylabel Y Position contains 4 objects of type line, quiver. These objects represent All Iterations, Final Iteration, Reference, Wind distrubance.

Plot the control effort in the outer-loop PID+ILC controller.

figure
f = tiledlayout(2,2,TileSpacing="tight");

Plot ILC control effort for the X direction.

nexttile
plot(squeeze(simout.ux_ilc.Data))
xlabel("Time")
ylabel("u")
title("ILC Control X-axis")

Plot PID control effort for the X direction.

nexttile
plot(squeeze(simout.ux_pid.data))
xlabel("Time")
ylabel("u")
title("PID Control X-axis")

Plot ILC control effort for the Y direction.

nexttile
plot(squeeze(simout.uy_ilc.data))
xlabel("Time")
ylabel("u");
title("ILC Control Y-axis")

Plot PID control effort for the Y direction.

nexttile
plot(squeeze(simout.uy_pid.data))
xlabel("Time")
ylabel("u")
title("PID Control Y-axis")

Figure contains 4 axes objects. Axes object 1 with title ILC Control X-axis, xlabel Time, ylabel u contains an object of type line. Axes object 2 with title PID Control X-axis, xlabel Time, ylabel u contains an object of type line. Axes object 3 with title ILC Control Y-axis, xlabel Time, ylabel u contains an object of type line. Axes object 4 with title PID Control Y-axis, xlabel Time, ylabel u contains an object of type line.

As iterations progress, the ILC controller learns to compensate for the tracking error and the nominal PID control effort is reduced to a minimum.

Reference

[1] Beard, Randal. "Quadrotor dynamics and control rev 0.1." (2008).

[2] Bristow, Douglas A., Marina Tharayil, and Andrew G. Alleyne. “A Survey of Iterative Learning Control.” IEEE Control Systems 26, no. 3 (June 2006): 96–114.

See Also

Topics