%% Advance Driving Scenario Simulation

% Copyright 2018 The MathWorks, Inc.

%%
% Create a driving scenario. Use the default sample time of 0.01 second.
scenario = drivingScenario;
%%
% Add a straight, 30-meter road to the scenario. The road has two lanes.
roadCenters = [0 0; 30 0];
road(scenario,roadCenters,'Lanes',lanespec(2));
%%
% Add a vehicle that travels in the left lane at a constant speed of 30
% meters per second. Plot the scenario before running the simulation.
v = vehicle(scenario,'ClassID',1);
waypoints = [5 2; 25 2];
speed = 30; % m/s
smoothTrajectory(v,waypoints,speed)

plot(scenario)
%%
% Call the |advance| function in a loop to advance the simulation one time
% step at a time. Pause every 0.01 second to observe the motion of the
% vehicle on the plot.
while advance(scenario)
    pause(0.01)
end