-
Notifications
You must be signed in to change notification settings - Fork 8
/
get_danger_zone.py
66 lines (42 loc) · 1.54 KB
/
get_danger_zone.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
from recording import RecordUtil
from scipy.io import savemat
import os
import numpy as np
from client import SynchronousClient, HUD, PraseArgs, Frame, Agent
from risk_analysis import ISpace
args = PraseArgs()
args.map = 'Town01'
#filename = 'interseciton_close_no_obj'
#filename = 'interseciton_baseline_no_obj'
#filename = 'interseciton_close_obj_pass'
filename = 'interseciton_close_obj_yield'
#filename = 'overtake_baseline_no_obj'
#filename = 'overtake_close_no_obj'
#filename = 'overtake_close_obj_evade_before_overtake'
#filename = 'overtake_close_obj_evade_after_overtake'
record_folder = os.getcwd()+ "/results/Good/Intersection/"
record_filename = record_folder+filename+".pkl"
i = 143
save_to = '/hdd/GoogleDrive/Research/Safe Active Perception/Figures/Results/Intersection/'+filename+'_'+str(i)+'.mat'
client = SynchronousClient(args)
info_space = ISpace(client, None, [])
record = RecordUtil()
record.load_from_file(record_filename)
num_frame = record.num_frame
# ego's information
traj = np.zeros((7, num_frame))
frame = record.record.frame_list[i]
mdic = {}
for (i, danger_zone) in enumerate(frame.danger_zone):
for j, polygon in enumerate(danger_zone.coverage_list):
name = "danger_"+str(i)+'_'+str(j)
array = np.array([polygon[0], polygon[1]])
mdic[name] = array
shadow_plot = info_space.get_shadow_for_plot(frame.shadow)
for i, shadow in enumerate(shadow_plot):
name = "shadow_"+str(i)
array = np.array([shadow[0], shadow[1]])
mdic[name] = array
#print(mdic)
savemat(save_to, mdic)
client.destroy()