forked from Telos4/RoboRally
changed forward, backward and turning directions in keyboard control script such that it fits the model and the camera image
This commit is contained in:
parent
480e1f523c
commit
0d14738671
|
@ -6,8 +6,10 @@ 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.4.1', 1234)) # connect to robot
|
||||||
#rc_socket.connect(('192.168.1.101', 1234)) # connect to robot
|
rc_socket.connect(('192.168.1.101', 1234)) # connect to robot
|
||||||
|
#rc_socket.connect(('192.168.1.102', 1234)) # connect to robot
|
||||||
|
#rc_socket.connect(('192.168.1.103', 1234)) # connect to robot
|
||||||
except socket.error:
|
except socket.error:
|
||||||
print("could not connect to socket")
|
print("could not connect to socket")
|
||||||
|
|
||||||
|
@ -20,21 +22,21 @@ while True:
|
||||||
for event in events:
|
for event in events:
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_LEFT:
|
if event.key == pygame.K_LEFT:
|
||||||
u1 = vmax
|
u1 = -vmax
|
||||||
u2 = -vmax
|
u2 = vmax
|
||||||
print("turn left: ({},{})".format(u1, u2))
|
print("turn left: ({},{})".format(u1, u2))
|
||||||
elif event.key == pygame.K_RIGHT:
|
elif event.key == pygame.K_RIGHT:
|
||||||
u1 = -vmax
|
u1 = vmax
|
||||||
u2 = vmax
|
u2 = -vmax
|
||||||
print("turn right: ({},{})".format(u1, u2))
|
print("turn right: ({},{})".format(u1, u2))
|
||||||
elif event.key == pygame.K_UP:
|
elif event.key == pygame.K_UP:
|
||||||
u1 = -vmax
|
u1 = vmax
|
||||||
u2 = -vmax
|
u2 = vmax
|
||||||
print("forward: ({},{})".format(u1, u2))
|
print("forward: ({},{})".format(u1, u2))
|
||||||
elif event.key == pygame.K_DOWN:
|
elif event.key == pygame.K_DOWN:
|
||||||
u1 = vmax
|
u1 = -vmax
|
||||||
u2 = vmax
|
u2 = -vmax
|
||||||
print("forward: ({},{})".format(u1, u2))
|
print("backward: ({},{})".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:
|
||||||
print("key released, resetting: ({},{})".format(u1, u2))
|
print("key released, resetting: ({},{})".format(u1, u2))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user