forked from RoboCupULaval/UI-Debug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (41 loc) · 1.96 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
# Under MIT License, see LICENSE.txt
import sys
import argparse
import warnings
from configparser import ParsingError, ConfigParser
from PyQt5.QtWidgets import QApplication
from Controller.MainController import MainController
__author__ = 'RoboCupULaval'
def argumentParser(argument):
""" Argument parser """
parser = argparse.ArgumentParser(description='option pour initialiser le UI-debug')
parser.add_argument('path_field_config', metavar='use_type', type=str, default='../StrategyIA/config/field/sim.cfg',
help='Path to the field config file in the StratetyIA config/field folder.')
parser.add_argument('team_color', metavar='team_color', type=str, default='blue',
help='team_color, set the color to use for the ports')
args_ = parser.parse_args(argument)
return args_
def load_config(path):
config_parser = ConfigParser(allow_no_value=False)
try:
print("Loading", path, " port configuration file.")
config_parser.read_file(open(path))
except FileNotFoundError:
raise RuntimeError("Impossible de lire le fichier de configuration.")
except ParsingError:
raise RuntimeError("Le fichier de configuration est mal configuré.\nExiting!")
return {s: dict(config_parser.items(s)) for s in config_parser.sections()}["COMMUNICATION"]
if __name__ == '__main__':
args = argumentParser(None)
app = QApplication(sys.argv)
config = load_config(args.path_field_config)
# DO NOT TOUCH EVER THEY ARE HARDCODED BOTH IN THE IA AND IN UI-DEBUG
if args.team_color == "blue":
ui_cmd_sender_port = 14444 # DO NOT TOUCH
ui_cmd_receiver_port = 15555 # DO NOT TOUCH
else:
ui_cmd_sender_port = 16666 # DO NOT TOUCH
ui_cmd_receiver_port = 17777 # DO NOT TOUCH
f = MainController(args.team_color, int(config["vision_port"]), int(config["referee_port"]), ui_cmd_sender_port, ui_cmd_receiver_port)
f.show()
sys.exit(app.exec())