-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect.py
60 lines (58 loc) · 1.54 KB
/
collect.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
#!/usr/bin/env python
import os
from carControl import carControl
os.environ['SDL_VIDEODRIVER'] = 'x11'
import pygame
import time
import thread
class collect_thread(thread.threading):
def __int__():
pygame.init()
pygame.display.set_mode((100,100))
self.car = carControl()
def run(self):
while True:
events = pygame.event.get()
for event in events:
if event.type == pygame.KEYDOWN:
input_key = pygame.key.get_pressed()
if input_key[pygame.K_w]:
car.carMoveForward()
time.sleep(0.25)
elif input_key[pygame.K_s] == 1:
#car = carControl()
car.carMoveBackward()
time.sleep(0.25)
elif input_key[pygame.K_a] == 1:
#car = carControl()
car.carTurnLeft()
time.sleep(0.25)
elif input_key[pygame.K_d] == 1:
#car = carControl()
car.carTurnRight()
time.sleep(0.25)
elif input_key[pygame.K_q] == 1:
#car = carControl()
car.cleanGPIO()
time.sleep(0.25)
'''elif event.type == pygame.KEYUP:
if input_key[pygame.K_w] :
#car = carControl()
car.carMoveForward()
time.sleep(0.25)
elif input_key[pygame.K_s] == 1:
#car = carControl()
car.carMoveBackward()
time.sleep(0.25)
elif input_key[pygame.K_a] == 1:
#car = carControl()
car.carTurnLeft()
time.sleep(0.25)
elif input_key[pygame.K_d] == 1:
#car = carControl()
car.carTurnRight()
time.sleep(0.25)
elif input_key[pygame.K_q] == 1:
#car = carControl()
car.cleanGPIO()
time.sleep(0.25)'''