added option to sest maximum speed

This commit is contained in:
Simon Pirkelmann 2019-06-10 23:16:56 +02:00
parent 79f4fcc032
commit 441e55000a

View File

@ -6,7 +6,8 @@ pygame.display.set_mode((640, 480))
rc_socket = socket.socket()
try:
rc_socket.connect(('192.168.1.101', 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
except socket.error:
print("could not connect to socket")
@ -14,24 +15,25 @@ except socket.error:
while True:
u1 = 0
u2 = 0
vmax = 0.5
events = pygame.event.get()
for event in events:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
u1 = 1.0
u2 = -1.0
u1 = vmax
u2 = -vmax
print("turn left: ({},{})".format(u1, u2))
elif event.key == pygame.K_RIGHT:
u1 = -1.0
u2 = 1.0
u1 = -vmax
u2 = vmax
print("turn right: ({},{})".format(u1, u2))
elif event.key == pygame.K_UP:
u1 = -1.0
u2 = -1.0
u1 = -vmax
u2 = -vmax
print("forward: ({},{})".format(u1, u2))
elif event.key == pygame.K_DOWN:
u1 = 1.0
u2 = 1.0
u1 = vmax
u2 = vmax
print("forward: ({},{})".format(u1, u2))
rc_socket.send('({},{})\n'.format(u1, u2))
elif event.type == pygame.KEYUP: