-
Notifications
You must be signed in to change notification settings - Fork 8
/
test_replay.py
75 lines (59 loc) · 2.23 KB
/
test_replay.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
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
from client import SynchronousClient, HUD, PraseArgs, Frame, Agent
from mapping import MapViewer
from recording import RecordUtil
from risk_analysis import ISpace
import time
import numpy as np
import os
import pickle
import time
if __name__ == "__main__":
args = PraseArgs()
args.map = 'Town01'
record_folder = os.getcwd()+ "/results/Good/Intersection/"
record_filename = record_folder+"interseciton_close_obj_yield.pkl"
#"interseciton_close_no_obj.pkl"
#"interseciton_close_obj.pkl"
#"overtake_close_obj.pkl"
#"overtake_close_no_obj.pkl"
#"overtake_baseline_no_obj.pkl"
#"interseciton_baseline_no_obj.pkl"
recorder = RecordUtil()
recorder.load_from_file(record_filename)
dt = 0.05
client = SynchronousClient(args, dt =dt )
info_space = ISpace(client, None, [])
frame = Frame(args.width, args.height)
hud = HUD(args.width, args.height)
map_view = MapViewer(args)
map_view.start(client, follow_ego=True)
try:
shadow_list, danger_zone, cur_frame = recorder.replay_frame(0, client)
client.setup_spectator()
client.add_RGB_camera(visualize=True, fps=20, fov=100)
#client.add_lidar(fps=20, h_fov=360)
num_frame = recorder.num_frame
for _ in range(100):
client.tick()
hud.tick_record(cur_frame)
map_view.tick(client)
shadow_plot = info_space.get_shadow_for_plot(shadow_list)
client.render()
map_view.render(frame, shadow_list=shadow_plot, dangerzone_list=danger_zone)
hud.render(frame)
frame.update_frame()
for i in range(num_frame):
shadow_list, danger_zone, cur_frame = recorder.replay_frame(i, client)
client.tick()
hud.tick_record(cur_frame)
map_view.tick(client)
shadow_plot = info_space.get_shadow_for_plot(shadow_list)
client.render()
map_view.render(frame, shadow_list=shadow_plot, dangerzone_list=danger_zone)
hud.render(frame)
frame.update_frame()
#time.sleep(dt*2)
input(i)
finally:
client.destroy()