CM und Degree-Steurung implementiert

This commit is contained in:
Kevin Frantz 2017-04-17 19:35:56 +00:00
parent 50001662b3
commit 2c90bc7db6
3 changed files with 16 additions and 9 deletions

Binary file not shown.

View File

@ -49,10 +49,6 @@ def autopilot():
sleep(0.5);
except KeyboardInterrupt:
print("Verlasse Autopilot...")
def turnDegree():
#degree = input();
core.turnDegree(90);
return;
def doIt(order):
switcher = {
'w': lambda: core.forward(),
@ -63,7 +59,8 @@ def doIt(order):
'i': lambda: core.printValues(),
'h': lambda: help(),
'q': lambda: autopilot(),
'x': lambda: turnDegree(),
'x': lambda: core.turnDegree(int(input("Grad:"))),
'w': lambda: core.runCm(int(input("cm:"))),
}
func = switcher.get(order, lambda: print("Der gewuenschte Befehl steht nicht zur Verfuegung"))
return func();
@ -71,9 +68,9 @@ print("Herzlich Willkommen im manuellen Controll-Interface!\n")
try:
while True:
core.setSensorValues()
input=getch.getch();
print("Erinaco>>{0}".format(input))
doIt(input);
modus=getch.getch();
print("Erinaco>>{0}".format(modus))
doIt(modus);
except KeyboardInterrupt:
print("Verlasse Erinaco...")
core.__del__();

View File

@ -10,6 +10,7 @@ class Motion(object):
self.motorRight=MOTOR(23,18,1) #Initialisierung des linken Motors
self.motorLeft=MOTOR(24,25,0) #Initialisierung des rechten Motors
self.FULLTURNTIME=4.5; #Dauer welche fuer eine 360 Grad wendebenoetigt wird in Sekunden
self.SEKPERMETER=6.9;
def turnLeft(self):
self.motorRight.forward()
self.motorLeft.backward()
@ -25,9 +26,18 @@ class Motion(object):
def stop(self):
self.motorRight.stop()
self.motorLeft.stop()
def runCm(self,cm):
if cm<0:
self.backward();
cm=cm*-1;
else:
self.forward();
sleep((self.SEKPERMETER/100)*cm);
self.stop();
def turnDegree(self,degree):
if degree<0:
self.turnLeft();
self.turnLeft();
degree=degree*-1;
else:
self.turnRight();
sleep((self.FULLTURNTIME/360)*degree);