mirror of
https://github.com/kevinveenbirkenbach/erinaco.git
synced 2024-11-23 14:31:04 +01:00
turnDegree-Funktion hinzugefuegt
This commit is contained in:
parent
f817e73fa9
commit
62bf65aa33
Binary file not shown.
@ -78,7 +78,6 @@ class Autopilot(CORE):
|
|||||||
self.statusTest();
|
self.statusTest();
|
||||||
CORE.turnRight(self);
|
CORE.turnRight(self);
|
||||||
def forward(self):
|
def forward(self):
|
||||||
|
|
||||||
self.moveStatus=1;
|
self.moveStatus=1;
|
||||||
self.statusTest();
|
self.statusTest();
|
||||||
CORE.forward(self);
|
CORE.forward(self);
|
||||||
|
@ -49,6 +49,10 @@ def autopilot():
|
|||||||
sleep(0.5);
|
sleep(0.5);
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Verlasse Autopilot...")
|
print("Verlasse Autopilot...")
|
||||||
|
def turnDegree():
|
||||||
|
#degree = input();
|
||||||
|
core.turnDegree(90);
|
||||||
|
return;
|
||||||
def doIt(order):
|
def doIt(order):
|
||||||
switcher = {
|
switcher = {
|
||||||
'w': lambda: core.forward(),
|
'w': lambda: core.forward(),
|
||||||
@ -59,6 +63,7 @@ def doIt(order):
|
|||||||
'i': lambda: core.printValues(),
|
'i': lambda: core.printValues(),
|
||||||
'h': lambda: help(),
|
'h': lambda: help(),
|
||||||
'q': lambda: autopilot(),
|
'q': lambda: autopilot(),
|
||||||
|
'x': lambda: turnDegree(),
|
||||||
}
|
}
|
||||||
func = switcher.get(order, lambda: print("Der gewuenschte Befehl steht nicht zur Verfuegung"))
|
func = switcher.get(order, lambda: print("Der gewuenschte Befehl steht nicht zur Verfuegung"))
|
||||||
return func();
|
return func();
|
||||||
|
47
motion.py
47
motion.py
@ -1,27 +1,34 @@
|
|||||||
from aktoren.motor import Motor as MOTOR
|
from aktoren.motor import Motor as MOTOR
|
||||||
|
from time import sleep;
|
||||||
"""
|
"""
|
||||||
Diese Klasse stellt alle Motion-Funktionen fuer den Erinaco Roboter zur Verfuegung.
|
Diese Klasse stellt alle Motion-Funktionen fuer den Erinaco Roboter zur Verfuegung.
|
||||||
@author kf
|
@author kf
|
||||||
@since 2017-04-15
|
@since 2017-04-15
|
||||||
"""
|
"""
|
||||||
class Motion(object):
|
class Motion(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.motorRight=MOTOR(23,18,1) #Initialisierung des linken Motors
|
self.motorRight=MOTOR(23,18,1) #Initialisierung des linken Motors
|
||||||
self.motorLeft=MOTOR(24,25,0) #Initialisierung des rechten Motors
|
self.motorLeft=MOTOR(24,25,0) #Initialisierung des rechten Motors
|
||||||
def turnLeft(self):
|
self.FULLTURNTIME=4.5; #Dauer welche fuer eine 360 Grad wendebenoetigt wird in Sekunden
|
||||||
self.motorRight.forward()
|
def turnLeft(self):
|
||||||
self.motorLeft.backward()
|
self.motorRight.forward()
|
||||||
def turnRight(self):
|
self.motorLeft.backward()
|
||||||
self.motorRight.backward()
|
def turnRight(self):
|
||||||
self.motorLeft.forward()
|
self.motorRight.backward()
|
||||||
def forward(self):
|
self.motorLeft.forward()
|
||||||
self.motorRight.forward()
|
def forward(self):
|
||||||
self.motorLeft.forward()
|
self.motorRight.forward()
|
||||||
def backward(self):
|
self.motorLeft.forward()
|
||||||
self.motorRight.backward()
|
def backward(self):
|
||||||
self.motorLeft.backward()
|
self.motorRight.backward()
|
||||||
def stop(self):
|
self.motorLeft.backward()
|
||||||
self.motorRight.stop()
|
def stop(self):
|
||||||
self.motorLeft.stop()
|
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();
|
||||||
|
Loading…
Reference in New Issue
Block a user