-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_pipeline.py
105 lines (78 loc) · 2.97 KB
/
map_pipeline.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import sys, os
'''
This file is to run all the requisite scripts to create the 2 dimensional pcd for navigation maps.
Supplied to this must be the info required to properly name the files. See usage.
Sub-Scripts must take in a full file path, so this file makes full paths, passes to those scripts.
'''
def check_args(args):
if len(args) != 2:
print('Usage:\n$python map_pipeline.py \
map:[easy, medium, hard] ')
return False
else:
return True
def create_id(args):
return "_".join(args[1:])
def log_process(pid):
print("""
#################################
#
# Running
# {}
#
#################################
""".format(pid))
def run_create_video(dest):
os.system('python frames_to_mp4.py {}'.format(dest))
def run_openvslam(mp4, cam, msg_dest):
os.system('python run_openvslam.py {} {} {}'.format(mp4, cam, msg_dest))
def run_pcd_conversion(msg_file, pcd_dest):
os.system('python msg_to_pcd.py {} {}'.format(msg_file, pcd_dest))
def run_pcd_processing(pcd_file, two_dim_pcd_dest):
os.system('python post_process_pcd.py {} {}'.format(pcd_file, two_dim_pcd_dest))
def run_create_yaml(map_name):
os.system('python create_yaml.py {}'.format(map_name))
########
# #
# MAIN #
# #
########
def main(args):
# Check the arguments for validity
if not check_args(args):
exit()
map_id = create_id(args)
base = os.path.join('~','msc-project')
bot_type = sys.argv[1]
# Create mp4 from frames folder
mp4_save = os.path.join(base, 'videos', map_id+'.mp4')
log_process('Frames to MP4')
run_create_video(mp4_save)
# Run OpenVSLAM
map_msg_save = os.path.join(base, 'openvslam', 'build', map_id+'.msg') # Where to store openvslam output
cam_config_file = os.path.join(base, 'openvslam','build', 'msc-cam', 'aal_cam.yaml')
do = raw_input('Run OpenVSLAM? (y or n): ')
while do.lower() == 'y':
run_openvslam(mp4_save, cam_config_file, map_msg_save)
do = raw_input('\n\nRun openvslam again? (y or n): ')
# Create pcd from message pack
do = raw_input('Convert msg->pcd? (y or n): ')
pcd_save = os.path.join(base, 'pcd', map_id+'.pcd') # Save msg conversion
if do.lower() == 'y':
log_process('Messagepack to point cloud')
run_pcd_conversion(map_msg_save, pcd_save)
# Run post processing on pcd
do = raw_input('Run postprocessing on PCD file? (y or n): ')
two_dim_pcd = os.path.join(base, 'pcd', '2d', map_id+'.pcd')
if do.lower() == 'y':
log_process('Post Processing PCD')
run_pcd_processing(pcd_save, two_dim_pcd)
# do = raw_input('Ceate map yaml file? (y or n): ')
# if do.lower() == 'y':
# log_process('Creating yaml file.')
# run_create_yaml(map_id)
# Finish
return map_id
if __name__=='__main__':
map_id = main(sys.argv)
print('Pipeline finished. The identifier is:\n{}'.format(map_id))