-
Notifications
You must be signed in to change notification settings - Fork 2
/
states.py
executable file
·89 lines (75 loc) · 2.26 KB
/
states.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
""" Global States """
import signal
class ExecState:
def __init__(self):
# exec states
self.client = None
self.world = None
self.G = None
self.first_frame_id = 0
self.first_sim_elapsed_time = 0
self.sim_start_time = 0
self.num_frames = 0
self.elapsed_time = 0
self.end = False
self.proc_state = None
class ScenarioState:
"""
A state object stores raw data and events captured from the simulator,
including vehicular states.
Pass a reference to this object to Scenario.run_test() as a parameter.
"""
def __init__(self):
# exec states
self.client = None
self.world = None
self.G = None
self.distance = 0
self.trace_graph_important = []
self.first_frame_id = 0
self.first_sim_elapsed_time = 0
self.sim_start_time = 0
self.num_frames = 0
self.elapsed_time = 0
self.end = False
self.other = None
self.closest_car = None
self.mutation = 0
# failure states
self.spawn_failed = False
self.spawn_failed_object = None
# error states
self.crashed = False
self.collision_to = None
self.stuck = False
self.stuck_duration = 0
self.laneinvaded = False
self.laneinvasion_event = []
self.speeding = False
self.speed = []
self.speed_lim = []
self.on_red = False
self.on_red_speed = []
self.red_violation = False
# other error states, e.g., segfault
self.other_error = False
self.other_error_val = 0
self.signal = 0
# control states
self.cont_throttle = []
self.cont_brake = []
self.cont_steer = []
self.steer_angle_list = []
self.yaw_list = []
self.yaw_rate_list = []
self.lat_speed_list = []
self.lon_speed_list = []
self.min_dist = 99998
self.autoware_cmd = ""
self.autoware_universe_cmd = ""
self.autoware_goal = ""
self.drawn_points = set()
def sig_handler(self, signum, frame):
print("[-] something happened: {}".format(signal.signum.name))
self.other = True
self.signal = signum