turnDegree-Funktion hinzugefuegt

This commit is contained in:
Kevin Frantz 2017-04-17 18:51:13 +00:00
parent f817e73fa9
commit 62bf65aa33
4 changed files with 32 additions and 21 deletions

Binary file not shown.

View File

@ -78,7 +78,6 @@ class Autopilot(CORE):
self.statusTest();
CORE.turnRight(self);
def forward(self):
self.moveStatus=1;
self.statusTest();
CORE.forward(self);

View File

@ -49,6 +49,10 @@ 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(),
@ -59,6 +63,7 @@ def doIt(order):
'i': lambda: core.printValues(),
'h': lambda: help(),
'q': lambda: autopilot(),
'x': lambda: turnDegree(),
}
func = switcher.get(order, lambda: print("Der gewuenschte Befehl steht nicht zur Verfuegung"))
return func();

View File

@ -1,27 +1,34 @@
from aktoren.motor import Motor as MOTOR
from time import sleep;
"""
Diese Klasse stellt alle Motion-Funktionen fuer den Erinaco Roboter zur Verfuegung.
@author kf
@since 2017-04-15
"""
class Motion(object):
def __init__(self):
self.motorRight=MOTOR(23,18,1) #Initialisierung des linken Motors
self.motorLeft=MOTOR(24,25,0) #Initialisierung des rechten Motors
def turnLeft(self):
self.motorRight.forward()
self.motorLeft.backward()
def turnRight(self):
self.motorRight.backward()
self.motorLeft.forward()
def forward(self):
self.motorRight.forward()
self.motorLeft.forward()
def backward(self):
self.motorRight.backward()
self.motorLeft.backward()
def stop(self):
self.motorRight.stop()
self.motorLeft.stop()
def __init__(self):
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
def turnLeft(self):
self.motorRight.forward()
self.motorLeft.backward()
def turnRight(self):
self.motorRight.backward()
self.motorLeft.forward()
def forward(self):
self.motorRight.forward()
self.motorLeft.forward()
def backward(self):
self.motorRight.backward()
self.motorLeft.backward()
def stop(self):
self.motorRight.stop()
self.motorLeft.stop()
def turnDegree(self,degree):
if degree<0:
self.turnLeft();
else:
self.turnRight();
sleep((self.FULLTURNTIME/360)*degree);
self.stop();