2017-04-15 02:42:23 +02:00
|
|
|
from aktoren.motor import Motor as MOTOR
|
2017-04-17 20:51:13 +02:00
|
|
|
from time import sleep;
|
2017-04-15 02:42:23 +02:00
|
|
|
"""
|
|
|
|
Diese Klasse stellt alle Motion-Funktionen fuer den Erinaco Roboter zur Verfuegung.
|
|
|
|
@author kf
|
|
|
|
@since 2017-04-15
|
|
|
|
"""
|
|
|
|
class Motion(object):
|
2017-04-17 20:51:13 +02:00
|
|
|
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
|
2017-04-17 21:35:56 +02:00
|
|
|
self.SEKPERMETER=6.9;
|
2017-04-17 20:51:13 +02:00
|
|
|
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()
|
2017-04-17 21:35:56 +02:00
|
|
|
def runCm(self,cm):
|
|
|
|
if cm<0:
|
|
|
|
self.backward();
|
|
|
|
cm=cm*-1;
|
|
|
|
else:
|
|
|
|
self.forward();
|
|
|
|
sleep((self.SEKPERMETER/100)*cm);
|
|
|
|
self.stop();
|
2017-04-17 20:51:13 +02:00
|
|
|
def turnDegree(self,degree):
|
|
|
|
if degree<0:
|
2017-04-17 21:35:56 +02:00
|
|
|
self.turnLeft();
|
|
|
|
degree=degree*-1;
|
2017-04-17 20:51:13 +02:00
|
|
|
else:
|
|
|
|
self.turnRight();
|
|
|
|
sleep((self.FULLTURNTIME/360)*degree);
|
|
|
|
self.stop();
|