-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKpp5_Generate.m
More file actions
50 lines (39 loc) · 1.41 KB
/
Kpp5_Generate.m
File metadata and controls
50 lines (39 loc) · 1.41 KB
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
45
46
47
48
49
50
%be careful to only clear the objects that we create each time so that
%if this script is called from within the simulation program it doesn;t
%clear other peoples data
clear c;
clear VehicleMgr;
clear CaravanController;
clear allCars;
clear target;
c = Caravan;
cc = CaravanController.getInstance;
vm = VehicleMgr.getInstance;
%create a max size (why not?) caravan of cars
for i = 1:CaravanControllerSetup.MaxCaravanSize
allCars(i) = Vehicle;
allCars(i).id = i;
allCars(i).velocity = c.maxSpeed;
%space cars out
if i == 1
allCars(i).posY = 10.0; %starting location
else
allCars(i).posY = allCars(i-1).posY - allCars(i-1).length - c.minVehicleSpacing ;
end
% have one car in the middle of the pack rapidly decelerate
if i == 4
% allCars(i).acceleration = -32; % 1g of deceleration
% TODO doesn't look like acceleration/deceleration is hooked up...
% allCars(i).velocity = 20; % ...for now just set velocity a lot lower
allCars(i).targetRate = -32;
end
%put all cars in caravan lane
allCars(i).lane = 5;
allCars(i).caravanNumber = 1; % non-zero caravan number
c.AddToVehicleList(allCars(i));
end
%give the caravan a place to go...all the way to the end
c.destination = 100;
%add caravan to caravan controller
cc.AddCaravan(c);
vm.AddVehicles(allCars);