Vincenz's Stuff
This commit is contained in:
parent
377195855a
commit
3b2ed61e01
1 changed files with 18 additions and 4 deletions
20
iqrobot.py
20
iqrobot.py
|
@ -1,6 +1,6 @@
|
|||
# LEGO type:standard slot:6 autostart
|
||||
|
||||
from spike import PrimeHub, Motor, MotorPair, ColorSensor, DistanceSensor
|
||||
from spike import PrimeHub, Motor, MotorPair, ColorSensor, DistanceSensor, MotionSensor
|
||||
from spike.control import wait_for_seconds
|
||||
|
||||
HELLO = "HELLO IQ"
|
||||
|
@ -71,12 +71,26 @@ class IQRobot:
|
|||
print("Farbintensität: " + str(colorIntensity))
|
||||
'''
|
||||
|
||||
def rotateRobot(self,degrees,speed) :
|
||||
#Lasse den Roboter bei Bedarf um eine bestimmte Anzahl an Grad sanft und behutsam nach Links oder Rechts drehen,
|
||||
# um den Nutzer zu befriedigen
|
||||
self.motionSensor.reset_yaw_angle()
|
||||
if (degrees > 0):
|
||||
self.leftMotor.start(speed)
|
||||
self.rightMotor.start(-speed)
|
||||
elif (degrees < 0):
|
||||
self.leftMotor.start(-speed)
|
||||
self.rightMotor.start(speed)
|
||||
while (self.motionSensor.get_yaw_angle() > degrees) :
|
||||
self.leftMotor.stop()
|
||||
self.rightMotor.stop()
|
||||
|
||||
def moveStick(self,degrees) :
|
||||
#Bewege sanft und langsam die Schleuderstange am hinteren Rumpf des Geräts
|
||||
self.stickMotor.run_for_degrees(degrees)
|
||||
|
||||
def moveGabel(self,degrees) :
|
||||
#Bewege sanft und langsam die Schleuderstange am hinteren Rumpf des Geräts
|
||||
#Bewege sanft und langsam die ungewöhnlich große sich bewegende Stange am vorderen Rumpf des Geräts
|
||||
self.gabelMotor.run_for_degrees(degrees)
|
||||
|
||||
def getDistance (self) :
|
||||
|
@ -87,4 +101,4 @@ class IQRobot:
|
|||
cmDistance = self.distanceSensor.get_distance_cm(short_range=True)
|
||||
return cmDistance
|
||||
|
||||
print("Loading library IQRobot in version " + VERSION)
|
||||
print("Loading library IQRobot in version " + VERSION)from spike import PrimeHub, Motor, MotorPair, ColorSensor, MotionSensor
|
Loading…
Reference in a new issue