MCPcopy Create free account
hub / github.com/OpenDriveLab/TCP / gen_single_route

Function gen_single_route

tools/gen_data.py:15–113  ·  view source on GitHub ↗
(route_folder)

Source from the content-addressed store, hash-verified

13
14
15def gen_single_route(route_folder):
16
17 length = len(os.listdir(os.path.join(route_folder, 'measurements')))
18 if length < INPUT_FRAMES + FUTURE_FRAMES:
19 return
20
21 seq_future_x = []
22 seq_future_y = []
23 seq_future_theta = []
24 seq_future_feature = []
25 seq_future_action = []
26 seq_future_action_mu = []
27 seq_future_action_sigma = []
28 seq_future_only_ap_brake = []
29
30
31 seq_input_x = []
32 seq_input_y = []
33 seq_input_theta = []
34
35 seq_front_img = []
36 seq_feature = []
37 seq_value = []
38 seq_speed = []
39
40 seq_action = []
41 seq_action_mu = []
42 seq_action_sigma = []
43
44 seq_x_target = []
45 seq_y_target = []
46 seq_target_command = []
47
48 seq_only_ap_brake = []
49
50 full_seq_x = []
51 full_seq_y = []
52 full_seq_theta = []
53
54 full_seq_feature = []
55 full_seq_action = []
56 full_seq_action_mu = []
57 full_seq_action_sigma = []
58 full_seq_only_ap_brake = []
59
60 for i in range(length):
61 with open(os.path.join(route_folder, "measurements", f"{str(i).zfill(4)}.json"), "r") as read_file:
62 measurement = json.load(read_file)
63 full_seq_x.append(measurement['y'])
64 full_seq_y.append(measurement['x'])
65 full_seq_theta.append(measurement['theta'])
66
67
68 roach_supervision_data = np.load(os.path.join(route_folder, "supervision", f"{str(i).zfill(4)}.npy"), allow_pickle=True).item()
69 full_seq_feature.append(roach_supervision_data['features'])
70 full_seq_action.append(roach_supervision_data['action'])
71 full_seq_action_mu.append(roach_supervision_data['action_mu'])
72 full_seq_action_sigma.append(roach_supervision_data['action_sigma'])

Callers 1

gen_sub_folderFunction · 0.85

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected