function [scenario, egoVehicle] = EventBased()
% createDrivingScenario Returns the drivingScenario defined in the Designer

% Generated by MATLAB(R) 9.10 (R2021a) and Automated Driving Toolbox 3.3 (R2021a).
% Generated on: 18-Feb-2021 13:44:16

% Construct a drivingScenario object.
scenario = drivingScenario('StopTime', 58);

% Add all road segments
roadCenters = [0 -0.004 0;
    50 -0.004 0;
    100 -0.004 0;
    250 19.996 0;
    1176 -10.004 0];
laneSpecification = lanespec(2);
road(scenario, roadCenters, 'Lanes', laneSpecification, 'Name', 'Road');

% Add the ego vehicle
egoVehicle = vehicle(scenario, ...
    'ClassID', 1, ...
    'Position', [49.377164354145 -1.92058185617664 0], ...
    'Mesh', driving.scenario.carMesh);
waypoints = [49.377164354145 -1.92058185617664 0;
    99.8800000000001 -0.780000000000001 0;
    249.68 19.02 0;
    397.07 34.62 0.01;
    499.86 40.23 0;
    503.195 40.276 0.01;
    504.62 40.29 0.01;
    511.13 40.49 0.01;
    516.28 40.5 0.01;
    525.43 40.68 0.01;
    532.3 40.7 0;
    555.4 41.3 0.01;
    565.05 41.38 0.01;
    598.8 40.9 0;
    623.3 40.2 0;
    625.845 40.151 0.01;
    647.85 39.51 0.01;
    654.34 39.23 0.01;
    678.88 38 0.01;
    706.39 36.69 0.01;
    735.01 34.94 0.01;
    772.21 32.64 0.01;
    818.92 28.72 0.01;
    861.12 24.51 0.01;
    902.28 20.66 0.01;
    943.15 16.46 0.01;
    983.95 11.95 0.01;
    1023.91 7.02 0.01;
    1097 -2 0;
    1175.5 -11.7 0];
speed = [12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12];
trajectory(egoVehicle, waypoints, speed);

% Add the non-ego actors
x = vehicle(scenario, ...
    'ClassID', 1, ...
    'Position', [69.7127954565438 -2.01435095590372 0], ...
    'Mesh', driving.scenario.carMesh);
waypoints = [69.7127954565438 -2.01435095590372 0;
    100.43 -0.870000000000001 0;
    249.53 18.93 0;
    499.86 40.13 0;
    506.25 40.15 0.01;
    518.38 40.22 0.01;
    530.02 40.59 0.01;
    542.83 40.86 0.01;
    555.85 41.32 0.01;
    567.87 41.27 0.01;
    579.04 41.22 0.01;
    590.87 40.96 0.01;
    603.48 40.6 0.01;
    616.54 40.38 0.01;
    628.31 40.2 0.01;
    638.89 39.88 0.01;
    650.57 39.5 0.01;
    662.21 39.1 0.01;
    673.17 38.63 0.01;
    683.61 38.11 0.01;
    695.11 37.75 0.01;
    748.29 34.54 0.01;
    799.35 30.55 0.01;
    853.89 25.67 0.01;
    907.9 20.36 0.01;
    958.44 14.82 0.01;
    1008.91 9.08 0.01;
    1058.59 2.89 0.01;
    1105.29 -2.78 0.01;
    1152.44 -8.96 0.01;
    1175.49 -12.18 0.01];
speed = [12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12];
waittime = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0];
trajectory(x, waypoints, speed, waittime);

x = vehicle(scenario, ...
    'ClassID', 1, ...
    'Position', [8.06036850609539 -1.77142933629482 0.01], ...
    'Mesh', driving.scenario.carMesh);
waypoints = [8.06036850609539 -1.77142933629482 0.01;
    21.5 0.7 0;
    51.6 2.4 0;
    101.1 2 0;
    253.3 22.8 0;
    331.8 33 0;
    400.54 39.22 0;
    435.54 40.32 0;
    472.44 41.12 0;
    486.6 40.6 0;
    494.5 40.8 0;
    508.9 41.5 0;
    522.7 41 0;
    531.7 40.5 0;
    550.9 41.2 0;
    598.3 40.5 0;
    643.6 39.8 0;
    688.2 37.6 0;
    797.4 31 0;
    892.9 21.9 0;
    1043.6 4.6 0;
    1128.7 -5.6 0;
    1174.9 -11.8 0];
speed = [15;15;15;15;15.5;15.75;16;16.5;21;22.5;22.5;22.5;22.5;22.5;22.5;22.5;22.5;22.5;22.5;22.5;22.5;45;22.5];
yaw =  [-2;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN];
trajectory(x, waypoints, speed, 'Yaw', yaw);

x = vehicle(scenario, ...
    'ClassID', 1, ...
    'Mesh', driving.scenario.carMesh);
waypoints = [0 0 0;
    51.4299999999999 -0.530000000000001 0;
    102.73 -0.530000000000001 0;
    250.43 19.67 0;
    501.93 41.07 0;
    512.89 41.2 0.01;
    522.6 41.26 0.01;
    592.3 41 0;
    609.48 40.7 0.01;
    677.7 38.1 0;
    715 36.7 0;
    857.5 25.7 0;
    909.3 20.2 0;
    937.7 17.2 0;
    959.9 15.1 0;
    988.4 12 0;
    1043.5 5.1 0;
    1082.2 0 0;
    1175.9 -11.6 0];
speed = [12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12];
trajectory(x, waypoints, speed);

