methode move stick hinzugefügt

This commit is contained in:
vilenne 2023-03-01 17:38:39 +01:00
parent fc3e54a5a4
commit a55bd56f0c

View file

@ -11,13 +11,13 @@ damit man dann später auch wieder Code Completion hat bei Nutzung der Variablen
''' '''
class IQRobot: class IQRobot:
def __init__(self, hub: PrimeHub, leftMotorPort: str, rightMotorPort: str, colorSensorPort: str): def __init__(self, hub: PrimeHub, leftMotorPort: str, rightMotorPort: str, colorSensorPort: str, stickMotorPort: str):
self.hub: PrimeHub = hub self.hub: PrimeHub = hub
self.leftMotor: Motor = Motor(leftMotorPort) self.leftMotor: Motor = Motor(leftMotorPort)
self.rightMotor: Motor = Motor(rightMotorPort) self.rightMotor: Motor = Motor(rightMotorPort)
self.movementMotors: MotorPair = MotorPair(leftMotorPort, rightMotorPort) self.movementMotors: MotorPair = MotorPair(leftMotorPort, rightMotorPort)
self.colorSensor: ColorSensor = ColorSensor(colorSensorPort) self.colorSensor: ColorSensor = ColorSensor(colorSensorPort)
self.stickMotor: Motor = Motor(stickMotorPort)
def show(self, image: str): def show(self, image: str):
''' '''
@ -40,6 +40,7 @@ class IQRobot:
def main(self): def main(self):
self.moveStick(30)
if self.colorSensor.get_reflected_light() > 1: if self.colorSensor.get_reflected_light() > 1:
self.show('ANGRY') self.show('ANGRY')
else: else:
@ -49,8 +50,12 @@ class IQRobot:
colorIntensity = self.getColorIntensity() colorIntensity = self.getColorIntensity()
print("Farbintensität: " + str(colorIntensity)) print("Farbintensität: " + str(colorIntensity))
def moveStick(self,degrees) :
#Bewege sanft und langsam die Schleuderstange am hinteren Rumpf des Geräts
self.stickMotor.run_for_degrees(degrees)
print("successfully loaded the IQ Lego teams code :)") print("successfully loaded the IQ Lego teams code :)")