Main Content

Simulate UAV Waypoint Following with Different Wind Conditions

This example shows how to create a UAV Scenario containing different wind conditions and use it in Simulink® to simulate a fixed-wing UAV following waypoints. This example uses a simplified kinematic model and control system similar to those in the Tuning Waypoint Follower for Fixed-Wing UAV example.

Create UAV Scenario with Wind Model Object

Create a uavScenario containing a test platform to simulate a no-wind scenario.

sceneNoWind = uavScenario;
uavPlatform("UAV",sceneNoWind);

Make a copy of the scenario, and add a steady wind object to the platform to simulate steady wind conditions.

sceneSteadyWind = copy(sceneNoWind);
plat = sceneSteadyWind.Platforms(1);
steadyWind = uavWindSteady(Velocity=[3.5 3.5 0]);
addWind(plat,steadyWind)

Create additional copy scenarios with gust and turbulence wind conditions. When adding wind turbulence, you must specify the noise sample time as an integer multiple of the scene sample time. In MATLAB®, the UpdateRate property of the uavScenario object controls the scene sample time. In Simulink, the Sample time parameter of the UAV Scenario Configuration block controls the scene sample time.

% Create scenario with gust wind
sceneGustWind = copy(sceneNoWind);
plat = sceneGustWind.Platforms(1);
gustWind = uavWindGust(GustAmplitude=[3.5 3.5 0],StartTime=30);
addWind(plat,gustWind)

% Create scenario with turbulence wind
sceneTurbulenceWind = copy(sceneNoWind);
plat = sceneTurbulenceWind.Platforms(1);
turbulenceWind = uavWindTurbulence(BandLimitedNoiseSampleTime=0.1);
addWind(plat,turbulenceWind)

Simulate UAV Waypoint Following with Wind Disturbance

Inspect the simulation model, which consists of four main sections: Waypoint Follower Controller, Low Fidelity Fixed Wing Kinematic Model, Wind Scenario, and Visualization and Logging.

The Tuning Waypoint Follower for Fixed-Wing UAV example contains a detailed explaination for each of these sections, except the Wind Scenario section. The Wind Scenario section contains the UAV Scenario blocks that enable you to load uavScenario objects containing different wind conditions into Simulink.

The controlled UAV in this example attempts to maintain constant air speed while following four preset waypoints. The wind velocity affects the UAV ground speed magnitude and direction during flight. This kinematic model contains no aerodynamic force.

modelName = "simulateUAVWaypointFollowingWithWind";
open_system(modelName)

Simulate the scenario with no wind, and visualize the results.

sceneConfig = modelName + "/UAV Scenario Configuration";
set_param(sceneConfig, UAVScenarioObject="sceneNoWind")
sim(modelName)

xNoWind = logsout{3}.Values.Data(:,1);
yNoWind = logsout{3}.Values.Data(:,2);
figure
plot(xNoWind,yNoWind)
hold on
scatter(xNoWind([1 end]),yNoWind([1 end]))
text(xNoWind(1)+100,yNoWind(1)+100,"Start",AffectAutoLimits="on")
text(xNoWind(end)+100,yNoWind(end)+100,"End",AffectAutoLimits="on")
xlabel("North (m)")
ylabel("East (m)")
title("Trajectory Under No Wind Condition")
axis equal

Simulate the scenario with steady wind, and visualize the results.

set_param(sceneConfig,UAVScenarioObject="sceneSteadyWind");
sim(modelName);

xSteadyWind = logsout{3}.Values.Data(:,1);
ySteadyWind = logsout{3}.Values.Data(:,2);
figure
plot(xSteadyWind,ySteadyWind)
hold on
scatter(xSteadyWind([1,end]),ySteadyWind([1,end]))
text(xSteadyWind(1)+100,ySteadyWind(1)+100,"Start",AffectAutoLimits="on");
text(xSteadyWind(end)+100,ySteadyWind(end)+100, "End",AffectAutoLimits="on");
xlabel("North (m)")
ylabel("East (m)")
title("Trajectory Under Steady Wind Condition")
axis equal

Simulate the scenario with wind gust and visualize the results.

set_param(sceneConfig,UAVScenarioObject="sceneGustWind")
sim(modelName)

xGustWind = logsout{3}.Values.Data(:,1);
yGustWind = logsout{3}.Values.Data(:,2);
figure()
plot(xGustWind, yGustWind)
hold on
scatter(xGustWind([1,end]),yGustWind([1,end]))
text(xGustWind(1)+100,yGustWind(1)+100,"Start",AffectAutoLimits="on");
text(xGustWind(end)+100,yGustWind(end)+100,"End",AffectAutoLimits="on");
xlabel("North (m)")
ylabel("East (m)")
title("Trajectory Under Gust Wind Condition")
axis equal

Simulate the scenario with turbulence wind and visualize the results.

set_param(sceneConfig,UAVScenarioObject="sceneTurbulenceWind");
sim(modelName);

xTurbulenceWind = logsout{3}.Values.Data(:,1);
yTurbulenceWind = logsout{3}.Values.Data(:,2);
figure()
plot(xGustWind,yGustWind)
hold on
scatter(xTurbulenceWind([1,end]),yTurbulenceWind([1,end]))
text(xTurbulenceWind(1)+100,yTurbulenceWind(1)+100,"Start",AffectAutoLimits="on");
text(xTurbulenceWind(end)+100,yTurbulenceWind(end)+100,"End",AffectAutoLimits="on");
xlabel("North (m)")
ylabel("East (m)")
title("Trajectory Under Turbulence Wind Condition")
axis equal

Plot the trajectory of the UAV under each of the wind conditions, and observe the results. The UAV in the no wind simulation follows the waypoint with consistent turn behavior at all four waypoints. The steady wind adds a constant shift to the ground speed computation, given the UAV is flying at a constant airspeed, which leads to irregular turns at all four waypoints because the difference in flight direction results in a different ground speed. Because you defined the wind gust with respect to the body frame of the UAV, the turns are consistently affected at the four waypoints. The wind turbulence adds random wind disturbance to the UAV, randomly perturbing the turns.

figure
plot(xNoWind,yNoWind)
hold on
plot(xSteadyWind,ySteadyWind)
plot(xGustWind,yGustWind)
plot(xTurbulenceWind,yTurbulenceWind)
legend(["NoWind","SteadyWind","GustWind","TurbulenceWind"])
xlabel("North (m)")
ylabel("East (m)")
title("Compare Trajectories Under Different Wind Conditions")
axis equal

Close the simulation model.

close_system(modelName,0)
dataDictionary = Simulink.data.dictionary.open(modelName + ".sldd");
discardChanges(dataDictionary)
close(dataDictionary)

Conclusion

The influence of wind on UAV operations is important when assessing the robustness of navigation algorithms. By leveraging the Simulink simulation environment, you can introduce a range of wind conditions to evaluate algorithm performance.