-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
49 lines (39 loc) · 1.59 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
49
class Config():
""" class for loading and holding the config parameters for both the heatmap and slam map
"""
def __init__(self, config_filepath=""):
# variables
self.map_width = 0.0 # in meters
self.map_height = 0.0 # in meters
self.map_resolution = 0.0 # in meters
self.slam_origin = (0, 0) # map indecies
self.slam_rotation = 0 # in degrees
self.slam_uncertainty_cutoff = 0 # in slam map values
if config_filepath != "":
self.load_from_file(config_filepath)
def load_from_file(self, filepath):
""" load the config parameters from a file
input:
filepath - filepath to the config file
"""
config_file = open(filepath, "r")
config_dict = {}
# load everything from the file
line = "none"
while line:
line = config_file.readline()
# check for lines of only whitespace
if len(line.strip()) == 0:
continue
# process this line
line_list = line.split("=")
key = line_list[0].strip()
value = eval(line_list[1].strip())
config_dict[key] = value
# load from the dictionary into the variables
self.map_width = config_dict["map_width"]
self.map_height = config_dict["map_height"]
self.map_resolution = config_dict["map_resolution"]
self.slam_origin = config_dict["slam_origin"]
self.slam_rotation = config_dict["slam_rotation"]
self.slam_uncertainty_cutoff = config_dict["slam_uncertainty_cutoff"]