From 62bf65aa3324b8ef8db7ad63266fb37ebf07ba30 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Mon, 17 Apr 2017 18:51:13 +0000 Subject: [PATCH] turnDegree-Funktion hinzugefuegt --- __pycache__/motion.cpython-36.pyc | Bin 1291 -> 1573 bytes autopilot.py | 1 - manual_controll.py | 5 ++++ motion.py | 47 +++++++++++++++++------------- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/__pycache__/motion.cpython-36.pyc b/__pycache__/motion.cpython-36.pyc index c74f263dd4d0145278431ac4586db2dac8a57e66..eddef263738036f4a9c6f16259f7e85530aed04f 100644 GIT binary patch literal 1573 zcmbtU&2G~`5Z<*N$8nRi4dqX8MzRF;feQzOiYOqYHkC>%Azv&vvq_!!C#<(cRK2Ay z!?W-PmN;?B190KQ%sOdO)FPy=wX?IH-I;G@zuo7pmiyiL_34Mn*iW|9EY!EK7f(?D z1D>#y2L>nINX*m1j9af-;qXR8yz47*m^7%$GV z9!HndXrwgWU@xAaP?!c7U{1_)7IK{F2zq8f9silY(38`h-pAF`4heEHeL&(N3Q5xe zc5Iz3&%zw{4)*p-H>Fhf@RO6-ho$MW*~gto*TzPa`FKA>%CS<WygXaoNTnI+;qWX}da+8D-zXSwZz@++84=TW^C%-a)4tjifWW0Z4;F z=_4Ur3nXi^+FY9d8;UN|yf~&Vjs~EiT#rKA3GO0(dlr9I)mufsEW{1b$$sxj^f@!; zr+Az2$Y+(0|CK$(rhBuyou*S6|Wi7)kEcCG_wd=e#w5K|6^-x-64_=-Pm!dOO2S=QDo%yYzqIqC Zq39{S=ej_p^Rfc|irxr)XieU<{{X?dCr1DP literal 1291 zcmbtUJ8#=C5GF<0mgPs%7us%JHPkB5H7HVa=+Zhs+M&=Q$UZueZHW#=yJ(Qj`5)a1 z^e<`cZohb01tH?n&6{uKnvQaJ?LPTZdu3hsmg~OL(w2jNZ;YKNDU$-d`oe~VvZ{t z*{&R57^Bf&J;lwdha~9u>KTdWC^RhtfgDagpPZI{MpRDIvvX56t^Glc403b}IUW6E zx`W&QybaG)Cc}wbr1?lExw#BMF630rGMSt3EH&Xwr;EhMQ0g>KhU%qO17$*th)jC3 zZ>1Npmj`REy~?{onxI=oYQKK{A}sGT^$6A1sx%=vu#->zvqqXi_M1Z7lb!recCuHUQQhJ` z>9L!Qn*EFYW6Vumwq@Viu&0y#ph*p!Cz*`n(vRaz!F)<~JB}~r$#m_}bbp$Ps2`D_ zJ72c|g}>E*^r$p7p%y4SoCP(Z$30Q~tfwE;qE0fw7b^2!MlV&cu4af diff --git a/autopilot.py b/autopilot.py index 8740500..66064fe 100644 --- a/autopilot.py +++ b/autopilot.py @@ -78,7 +78,6 @@ class Autopilot(CORE): self.statusTest(); CORE.turnRight(self); def forward(self): - self.moveStatus=1; self.statusTest(); CORE.forward(self); diff --git a/manual_controll.py b/manual_controll.py index acc91be..3d507fc 100644 --- a/manual_controll.py +++ b/manual_controll.py @@ -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(); diff --git a/motion.py b/motion.py index db1b440..598645d 100644 --- a/motion.py +++ b/motion.py @@ -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();