-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·49 lines (38 loc) · 1.27 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from interface import Interface
from settings import HOST, PORT
import argparse
import socket
sys.path.append("../atp")
from channel import Channel
from math import pi
def callback(visu, name, args):
if name == "pos":
#visu.moveRotateRobot(args["x"]*100+150, args["y"]*100+100, -args["theta"]/pi*180)
visu.moveRotateRobot((args["x"]+1.5-0.15)*200, (-args["y"]+1-0.15)*200, 90-(args["theta"]/pi*180))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("host", nargs="?", help="Set host to connect.")
parser.add_argument("port", nargs="?", help="Set port to connect.")
args = parser.parse_args()
if args.host:
host = args.host
else:
host = HOST
if args.port:
port = args.port
else:
port = PORT
print("Connecting to %s:%s…" %(host, port))
sock = socket.socket()
sock.connect((host, port))
f = sock.makefile(mode='rw')
print("Launching interface…")
inter = Interface()
print("Creating channel…")
channel = Channel(f.buffer, lambda name, args, visu = inter:
callback(visu, name, args), proto = "asserv")
print("All done!")
sys.exit(inter.getAppHandle().exec_())