This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNode.m
More file actions
47 lines (37 loc) · 1.56 KB
/
Node.m
File metadata and controls
47 lines (37 loc) · 1.56 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
classdef Node
%NODE Every node of a tree contains the state/action information,
%source/target properties
properties
sourceNodeID
sourceEdgeName
id
state
actions
targetNodeID
UnsafetyValue
end
methods
function obj = Node(sourceNodeID,sourceEdgeName,id,state,actions,UnsafetyValue)
%NODE Construct an instance of this class
% Detailed explanation goes here
obj.sourceNodeID = sourceNodeID;
obj.sourceEdgeName = sourceEdgeName;
obj.id = id;
obj.state = state;
obj.actions = actions;
obj.targetNodeID = [];
obj.UnsafetyValue = UnsafetyValue;
end
function newNode = expand(obj,action,deltaT,count,VehiclesOther,OtherVehicleStateDistributions)
newState = action{1}.apply(obj.state,deltaT);
newUnsafetyValues = [];
for idx = 1:length(OtherVehicleStateDistributions)
OtherVehicleStateDistribution = OtherVehicleStateDistributions(idx);
newUnsafetyValue = Maneuver.calculateUnsafety(newState,VehiclesOther(idx).d,OtherVehicleStateDistribution);
newUnsafetyValues = [newUnsafetyValues newUnsafetyValue];
end
newUnsafetyValue = max(newUnsafetyValues);
newNode = Node(obj.id,action,count,newState,obj.actions,newUnsafetyValue);
end
end
end