fixed a bug in keyboard remote controller
This commit is contained in:
parent
6ebb9338c0
commit
4bff8e1df5
|
@ -6,12 +6,14 @@ pygame.display.set_mode((640, 480))
|
||||||
|
|
||||||
rc_socket = socket.socket()
|
rc_socket = socket.socket()
|
||||||
try:
|
try:
|
||||||
rc_socket.connect(('192.168.4.1', 1234)) # connect to robot
|
rc_socket.connect(('192.168.1.101', 1234)) # connect to robot
|
||||||
except socket.error:
|
except socket.error:
|
||||||
print("could not connect to socket")
|
print("could not connect to socket")
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
u1 = 0
|
||||||
|
u2 = 0
|
||||||
events = pygame.event.get()
|
events = pygame.event.get()
|
||||||
for event in events:
|
for event in events:
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
|
@ -33,7 +35,5 @@ while True:
|
||||||
print("forward: ({},{})".format(u1, u2))
|
print("forward: ({},{})".format(u1, u2))
|
||||||
rc_socket.send('({},{})\n'.format(u1, u2))
|
rc_socket.send('({},{})\n'.format(u1, u2))
|
||||||
elif event.type == pygame.KEYUP:
|
elif event.type == pygame.KEYUP:
|
||||||
u1 = 0
|
|
||||||
u2 = 0
|
|
||||||
print("key released, resetting: ({},{})".format(u1, u2))
|
print("key released, resetting: ({},{})".format(u1, u2))
|
||||||
rc_socket.send('({},{})\n'.format(u1, u2))
|
rc_socket.send('({},{})\n'.format(u1, u2))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user