-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
executable file
·46 lines (39 loc) · 1.4 KB
/
app.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
import argparse
from flask import Flask, Blueprint
# from brain import brain_blueprints
from eye import eye_blueprints
app = Flask(__name__)
# This is the handle monitor of Robot Server on Darkchess Robot
@app.route("/", methods=["GET"])
def main():
frame = eye.get_frame(url, 1)
board = eye.board(frame)
color = set_color(board)
com_action = ai.action(board, color)
return arm_command(com_action, board)
def parse_args():
parser = argparse.ArgumentParser(description="Mode for running the app")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--default-mode",
action="store_true",
help="Run robot server and Request API for 'brain' & 'eye'.",
)
group.add_argument(
"--api-mode",
action="store_true",
help="Only run API server without robot server.",
)
group.add_argument(
"--local-mode",
action="store_true",
help="Run robot server and Call local function for 'brain' & 'eye' directly.",
)
return parser.parse_args()
if __name__ == "__main__":
args = parse_args()
if args.default_mode or args.api_mode:
app.register_blueprint(brain_blueprints, url_prefix="/brain")
app.register_blueprint(eye_blueprints, url_prefix="/eye")
if not args.api_mode:
app.run(host="0.0.0.0", port=8080)