-
Notifications
You must be signed in to change notification settings - Fork 7
/
simulation_traj.m
44 lines (37 loc) · 1.49 KB
/
simulation_traj.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
T = readtable('D:\我的資料-20210125\電機四上\智慧型汽車導論\final project\trajectory_A.csv');
num_frame = 101;
frameA = 1;
frameB = frameA + num_frame;
frameC = frameB + num_frame;
frameD = frameC + num_frame;
frameE = frameD + num_frame;
scenario = drivingScenario('SampleTime',0.05);
% add road
roadcenters = [0 -70 0; 0 400 0];
road(scenario,roadcenters, 'Lanes', lanespec(2, 'Width', 15));
% add vehicle 1103 A
v = vehicle(scenario,'ClassID',1, 'Name', 'A');
waypoints = table2array(T(frameA:frameA+num_frame-1, 3:4));
speeds = table2array(T(frameA:frameA+num_frame-1, 5));
trajectory(v,waypoints,speeds);
% add vehicle 1121 B
v = vehicle(scenario,'ClassID',1, 'Name', 'B');
waypoints = table2array(T(frameB:frameB+num_frame-1, 3:4));
speeds = table2array(T(frameB:frameB+num_frame-1, 5));
trajectory(v,waypoints,speeds);
% add vehicle 1096 C
v = vehicle(scenario,'ClassID',1, 'Name', 'C');
waypoints = table2array(T(frameC:frameC+num_frame-1, 3:4));
speeds = table2array(T(frameC:frameC+num_frame-1, 5));
trajectory(v,waypoints,speeds);
% add vehicle 1084 D
v = vehicle(scenario,'ClassID',1, 'Name', 'D');
waypoints = table2array(T(frameD:frameD+num_frame-1, 3:4));
speeds = table2array(T(frameD:frameD+num_frame-1, 5));
trajectory(v,waypoints,speeds);
% add vehicle 1119 E
v = vehicle(scenario,'ClassID',1, 'Name', 'E');
waypoints = table2array(T(frameE:frameE+num_frame-1, 3:4));
speeds = table2array(T(frameE:frameE+num_frame-1, 5));
trajectory(v,waypoints,speeds);
drivingScenarioDesigner(scenario)