This repository was archived by the owner on Nov 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
52 lines (38 loc) · 1.43 KB
/
main.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
""" Author: Sean Wu 104502551 NCU CSIE 3B
An assignment of Computational Intelligence in NCU, Taiwan
to implement the very simple fuzzy system with a car simulation.
This file is the entry point of whole project.
GitLab: https://gitlab.com/GLaDOS1105/fuzzy-car
"""
import collections
import pathlib
import sys
from PySide2.QtWidgets import QApplication
from fuzzy_car.gui import gui_base
def main():
""" Create GUI application and read testing case data. """
sys.argv += ['--style', 'fusion']
app = QApplication(sys.argv)
window = gui_base.GUIBase(read_case_file())
window.show()
sys.exit(app.exec_())
def read_case_file(folderpath='data'):
""" Read every data of testing case in "folderpath" folder. Return the
dictionary containing dataset.
"""
dataset = {}
folderpath = pathlib.Path(folderpath)
for filepath in folderpath.glob("*.txt"):
with filepath.open() as casefile:
contents = [tuple(map(float, line.split(',')))
for line in casefile]
dataset[filepath.stem] = {
"start_pos": (contents[0][0], contents[0][1]),
"start_angle": contents[0][2],
"end_area_lt": contents[1], # ending area - left-top
"end_area_rb": contents[2], # ending area - right-bottom
"route_edge": contents[3:]
}
return collections.OrderedDict(sorted(dataset.items()))
if __name__ == '__main__':
main()