mirror of
https://github.com/kevinveenbirkenbach/erinaco.git
synced 2024-11-23 14:31:04 +01:00
CM und Degree-Steurung implementiert
This commit is contained in:
parent
50001662b3
commit
2c90bc7db6
Binary file not shown.
@ -49,10 +49,6 @@ 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(),
|
||||||
@ -63,7 +59,8 @@ 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(),
|
'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"))
|
func = switcher.get(order, lambda: print("Der gewuenschte Befehl steht nicht zur Verfuegung"))
|
||||||
return func();
|
return func();
|
||||||
@ -71,9 +68,9 @@ print("Herzlich Willkommen im manuellen Controll-Interface!\n")
|
|||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
core.setSensorValues()
|
core.setSensorValues()
|
||||||
input=getch.getch();
|
modus=getch.getch();
|
||||||
print("Erinaco>>{0}".format(input))
|
print("Erinaco>>{0}".format(modus))
|
||||||
doIt(input);
|
doIt(modus);
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Verlasse Erinaco...")
|
print("Verlasse Erinaco...")
|
||||||
core.__del__();
|
core.__del__();
|
||||||
|
10
motion.py
10
motion.py
@ -10,6 +10,7 @@ class Motion(object):
|
|||||||
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
|
||||||
self.FULLTURNTIME=4.5; #Dauer welche fuer eine 360 Grad wendebenoetigt wird in Sekunden
|
self.FULLTURNTIME=4.5; #Dauer welche fuer eine 360 Grad wendebenoetigt wird in Sekunden
|
||||||
|
self.SEKPERMETER=6.9;
|
||||||
def turnLeft(self):
|
def turnLeft(self):
|
||||||
self.motorRight.forward()
|
self.motorRight.forward()
|
||||||
self.motorLeft.backward()
|
self.motorLeft.backward()
|
||||||
@ -25,9 +26,18 @@ class Motion(object):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
self.motorRight.stop()
|
self.motorRight.stop()
|
||||||
self.motorLeft.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):
|
def turnDegree(self,degree):
|
||||||
if degree<0:
|
if degree<0:
|
||||||
self.turnLeft();
|
self.turnLeft();
|
||||||
|
degree=degree*-1;
|
||||||
else:
|
else:
|
||||||
self.turnRight();
|
self.turnRight();
|
||||||
sleep((self.FULLTURNTIME/360)*degree);
|
sleep((self.FULLTURNTIME/360)*degree);
|
||||||
|
Loading…
Reference in New Issue
Block a user