/
config.py
48 lines (33 loc) · 1.52 KB
/
config.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
import os
import configparser
import donkey as dk
import keras
if int(keras.__version__.split('.')[0]) < 2:
raise ImportError('You need keras version 2.0.0 or higher. Run "pip install keras --upgrade"')
config = configparser.ConfigParser()
my_path = os.path.expanduser('~/mydonkey/')
sessions_path = os.path.join(my_path, 'sessions')
models_path = os.path.join(my_path, 'models')
datasets_path = os.path.join(my_path, 'datasets')
results_path = os.path.join(my_path, 'results')
def parse_config(config_path):
config_path = os.path.expanduser(config_path)
config.read(config_path)
cfg={}
vehicle = config['vehicle']
cfg['vehicle_id'] = vehicle.get('id')
cfg['vehicle_loop_delay'] = vehicle.getfloat('loop_delay')
camera = config['camera']
cfg['camera_loop_delay'] = camera.getfloat('loop_delay')
t_act = config['throttle_actuator']
cfg['throttle_actuator_channel'] = t_act.getint('channel')
cfg['throttle_actuator_min_pulse'] = t_act.getint('min_pulse')
cfg['throttle_actuator_max_pulse'] = t_act.getint('max_pulse')
cfg['throttle_actuator_zero_pulse'] = t_act.getint('zero_pulse')
s_act = config['steering_actuator']
cfg['steering_actuator_channel'] = s_act.getint('channel')
cfg['steering_actuator_min_pulse'] = s_act.getint('left_pulse')
cfg['steering_actuator_max_pulse'] = s_act.getint('right_pulse')
pilot = config['pilot']
cfg['pilot_model_path'] = os.path.expanduser(pilot.get('model_path'))
return cfg