-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
executable file
·71 lines (61 loc) · 1.73 KB
/
client.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
import pygame
import time
import subprocess
import ConfigParser
import rov
TEXT_RED = "\033[91m"
TEXT_GREEN = "\033[92m"
TEXT_BLUE = "\033[94m"
TEXT_END = "\033[0m"
VERBOSE = True
def starbar(value):
retval = "[" + (TEXT_GREEN if value > 0 else TEXT_RED)
value = int(round(abs(value)*10.0))
counter = 0
for i in range(value):
retval += '*'
counter += 1
while counter < 10:
retval += ' '
counter += 1
retval += "%s%s" % (TEXT_END, "]")
return retval
if __name__ == "__main__":
pygame.init()
if pygame.joystick.get_count() == 1:
gamepad = pygame.joystick.Joystick(0)
else:
gamepad = pygame.joystick.Joystick(1)
gamepad.init()
r = rov.Rov(cfg="temp_settings.cfg")
r.mode_change("default")
while True:
pygame.event.pump()
buttons = 0x00
for i in range(0,8):
buttons = buttons | (gamepad.get_button(i) << i)
parameters = {'lh': gamepad.get_axis(0) * 100, \
'lv': gamepad.get_axis(1) * -100, \
'rh': gamepad.get_axis(3) * 100, \
'rv': gamepad.get_axis(2) * -100, \
'dh': gamepad.get_axis(4) * 100, \
'dv': gamepad.get_axis(5) * 100, \
'buttons': buttons}
r.go(parameters)
r.command()
if VERBOSE:
print "\n\n\n\n\n"
for v in r.report():
print starbar(v)
print "Buttons: ", buttons
print "PID: ",
for i in r.pid:
print i,
print "\nDCM: ",
for i in r.dcm:
print i,
print
time.sleep(0.04)
gamepad.quit()
pygame.quit()