-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.py
53 lines (46 loc) · 1.47 KB
/
tester.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
53
from websocket import create_connection
import json
import time
from game import GameState
from utils import *
def connect():
global ws0, ws1
ws0 = create_connection("ws://0.0.0.0:9000/data0")
ws1 = create_connection("ws://0.0.0.0:9000/data1")
def compass(x=37.484724, y=-122.148309, acc=0.0, heading=108.79, vel=0.01):
data = {"action": "compass", "args": str([x, y, acc, heading, vel])}
ws0.send(json.dumps(data))
# ws1.send(json.dumps(data))
def ghost(x=37.484724, y=-122.148309, acc=0.0, heading=108.79, vel=0.0):
data = {"action": "ghost", "args": str([x, y, acc, heading, vel])}
ws0.send(json.dumps(data))
# ws1.send(json.dumps(data))
def test():
connect()
compass()
time.sleep(1)
compass(vel=0.05)
time.sleep(10)
compass(vel=0.00)
time.sleep(1)
print repr(ws0.recv())
# print repr(ws1.recv())
def test_coord():
state = GameState(1,1)
pt = [0, 0]
state.pt_to_geo(pt)
print "origin ", pt
pt = [1, 0]
state.pt_to_geo(pt)
print "x limit ", pt
pt = [0, 1]
state.pt_to_geo(pt)
print "y limit ", pt
def test_angle():
state = GameState(1,1)
print "Convert 45 to simple ", state.angle_to_simp(45)
print "Convert 45 to geo ", state.angle_to_geo(45)
print "Convert 90 to simple ", state.angle_to_simp(90)
print "Convert 90 to geo ", state.angle_to_geo(90)
print "Convert 270 to simple ", state.angle_to_simp(270)
print "Convert 270 to geo ", state.angle_to_geo(270)