Compare commits

..

2 Commits

5 changed files with 53 additions and 4 deletions

27
KeyPressModule.py Normal file
View File

@ -0,0 +1,27 @@
import pygame
def init():
pygame.init()
win = pygame.display.set_mode((100,100))
def getKey(keyName):
ans = False
for eve in pygame.event.get():pass
keyInput = pygame.key.get_pressed()
myKey = getattr(pygame,'K_{}'.format(keyName))
if keyInput [myKey]:
ans = True
pygame.display.update()
return ans
def main():
if getKey('LEFT'):
print('Key Left was pressed')
if getKey('RIGHT'):
print('Key Right was pressed')
if __name__ == '__main__':
init()
while True:
main()

View File

@ -30,7 +30,7 @@ def main():
if curveVal>-0.08: curveVal=0
car.motion.skt_drive(0.4,-curveVal*sen,0.05)
turn_value = -curveVal*sen
print("Curve Value : " + str(curveVal) + "Turn Value : "+ str(turn_value))
print("Curve Value : " + str(curveVal) + " Turn Value : "+ str(round(turn_value,2))
cv2.waitKey(1)

22
RobotMain2.py Normal file
View File

@ -0,0 +1,22 @@
from kuukar.kuukar import kuukar
import KeyPressModule as kp
car = kuukar()
kp.init()
def main(self):
if kp.getKey('UP'):
car.motion.skt_drive(0.4,0.0,0.05)
elif kp.getKey('DOWN'):
car.motion.skt_drive(-0.4,0.0,0.05)
elif kp.getKey('LEFT'):
car.motion.skt_drive(0.5,0.3,0.05)
elif kp.getKey('RIGHT'):
car.motion.skt_drive(0.5,-0.3,0.05)
else:
car.motion.stop()
if __name__ == '__main__':
while True:
main()

View File

@ -16,7 +16,7 @@ class cv:
def _cv_loop(self):
while True:
img = self.capture_image()
stop_sign = self.detect_sign(img)
##stop_sign = self.detect_sign(img)
def get_road_curve(self, frame):
pass

View File

@ -132,8 +132,8 @@ class motion:
self.motor_write(MOTOR_FL_F, MOTOR_FL_R, abs(leftSpeed))
self.motor_write(MOTOR_FR_F, MOTOR_FR_R, abs(rightSpeed))
##self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed)
##self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed)
self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed)
self.motor_write(MOTOR_RR_F, MOTOR_RR_R, speed)
time.sleep(t)