-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdata_utils.py
More file actions
165 lines (155 loc) · 7.67 KB
/
data_utils.py
File metadata and controls
165 lines (155 loc) · 7.67 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import tensorflow as tf
#### Example field definition
# Features of road graph.
roadgraph_features = {
'roadgraph_samples/dir':
tf.io.FixedLenFeature([20000, 3], tf.float32, default_value=None),
'roadgraph_samples/id':
tf.io.FixedLenFeature([20000, 1], tf.int64, default_value=None),
'roadgraph_samples/type':
tf.io.FixedLenFeature([20000, 1], tf.int64, default_value=None),
'roadgraph_samples/valid':
tf.io.FixedLenFeature([20000, 1], tf.int64, default_value=None),
'roadgraph_samples/xyz':
tf.io.FixedLenFeature([20000, 3], tf.float32, default_value=None),
}
# Features of other agents.
state_features = {
'state/id':
tf.io.FixedLenFeature([128], tf.float32, default_value=None),
'state/type':
tf.io.FixedLenFeature([128], tf.float32, default_value=None),
'state/is_sdc':
tf.io.FixedLenFeature([128], tf.int64, default_value=None),
'state/tracks_to_predict':
tf.io.FixedLenFeature([128], tf.int64, default_value=None),
'state/current/bbox_yaw':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/height':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/length':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/timestamp_micros':
tf.io.FixedLenFeature([128, 1], tf.int64, default_value=None),
'state/current/valid':
tf.io.FixedLenFeature([128, 1], tf.int64, default_value=None),
'state/current/vel_yaw':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/velocity_x':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/velocity_y':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/speed':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/width':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/x':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/y':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/current/z':
tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
'state/future/bbox_yaw':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/height':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/length':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/timestamp_micros':
tf.io.FixedLenFeature([128, 80], tf.int64, default_value=None),
'state/future/valid':
tf.io.FixedLenFeature([128, 80], tf.int64, default_value=None),
'state/future/vel_yaw':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/velocity_x':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/velocity_y':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/width':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/x':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/y':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/future/z':
tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
'state/past/bbox_yaw':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/height':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/length':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/timestamp_micros':
tf.io.FixedLenFeature([128, 10], tf.int64, default_value=None),
'state/past/valid':
tf.io.FixedLenFeature([128, 10], tf.int64, default_value=None),
'state/past/vel_yaw':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/velocity_x':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/velocity_y':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/speed':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/width':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/x':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/y':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'state/past/z':
tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
'scenario/id':
tf.io.FixedLenFeature([1], tf.string, default_value=None),
}
# Features of traffic lights.
traffic_light_features = {
'traffic_light_state/current/state':
tf.io.FixedLenFeature([1, 16], tf.int64, default_value=None),
'traffic_light_state/current/valid':
tf.io.FixedLenFeature([1, 16], tf.int64, default_value=None),
'traffic_light_state/current/x':
tf.io.FixedLenFeature([1, 16], tf.float32, default_value=None),
'traffic_light_state/current/y':
tf.io.FixedLenFeature([1, 16], tf.float32, default_value=None),
'traffic_light_state/current/z':
tf.io.FixedLenFeature([1, 16], tf.float32, default_value=None),
'traffic_light_state/past/state':
tf.io.FixedLenFeature([10, 16], tf.int64, default_value=None),
'traffic_light_state/past/valid':
tf.io.FixedLenFeature([10, 16], tf.int64, default_value=None),
'traffic_light_state/past/x':
tf.io.FixedLenFeature([10, 16], tf.float32, default_value=None),
'traffic_light_state/past/y':
tf.io.FixedLenFeature([10, 16], tf.float32, default_value=None),
'traffic_light_state/past/z':
tf.io.FixedLenFeature([10, 16], tf.float32, default_value=None),
}
features_description = {}
features_description.update(roadgraph_features)
features_description.update(state_features)
features_description.update(traffic_light_features)
# road label
road_label = {1:'LaneCenter-Freeway', 2:'LaneCenter-SurfaceStreet', 3:'LaneCenter-BikeLane', 6:'RoadLine-BrokenSingleWhite',
7:'RoadLine-SolidSingleWhite', 8:'RoadLine-SolidDoubleWhite', 9:'RoadLine-BrokenSingleYellow', 10:'RoadLine-BrokenDoubleYellow',
11:'Roadline-SolidSingleYellow', 12:'Roadline-SolidDoubleYellow', 13:'RoadLine-PassingDoubleYellow', 15:'RoadEdgeBoundary',
16:'RoadEdgeMedian', 17:'StopSign', 18:'Crosswalk', 19:'SpeedBump'}
road_line_map = {1:['xkcd:grey', 'solid', 14], 2:['xkcd:grey', 'solid', 14], 3:['xkcd:grey', 'solid', 10], 6:['w', 'dashed', 2],
7:['w', 'solid', 2], 8:['w', 'solid', 2], 9:['xkcd:yellow', 'dashed', 4], 10:['xkcd:yellow', 'dashed', 2],
11:['xkcd:yellow', 'solid', 2], 12:['xkcd:yellow', 'solid', 3], 13:['xkcd:yellow', 'dotted', 1.5], 15:['y', 'solid', 4.5],
16:['y', 'solid', 4.5], 17:['r', '.', 40], 18:['b', 'solid', 13], 19:['xkcd:orange', 'solid', 13]}
# traffic light label
light_label = {0:'Unknown', 1:'Arrow_Stop', 2:'Arrow_Caution', 3:'Arrow_Go', 4:'Stop', 5:'Caution', 6:'Go', 7:'Flashing_Stop', 8:'Flashing_Caution'}
light_state_map = {0:'k', 1:'r', 2:'y', 3:'g', 4:'r', 5:'y', 6:'g', 7:'r', 8:'y'}
from waymo_open_dataset.protos import scenario_pb2
_ObjectType = scenario_pb2.Track.ObjectType
ALL_AGENT_TYPES = [
_ObjectType.TYPE_VEHICLE,
_ObjectType.TYPE_PEDESTRIAN,
_ObjectType.TYPE_CYCLIST,
]
agent_color={
_ObjectType.TYPE_VEHICLE:'r',
_ObjectType.TYPE_PEDESTRIAN:'g',
_ObjectType.TYPE_CYCLIST:'b'
}