Schreibe L mit Movement und HubMotor
This commit is contained in:
parent
31510f9e21
commit
e57d4afba6
2 changed files with 30 additions and 7 deletions
28
iqrobot.py
28
iqrobot.py
|
@ -16,7 +16,8 @@ class IQRobot:
|
||||||
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.hubMotor: Motor = Motor("F")
|
||||||
|
|
||||||
|
|
||||||
def show(self, image: str):
|
def show(self, image: str):
|
||||||
|
@ -38,9 +39,34 @@ class IQRobot:
|
||||||
(red, green, blue, colorIntensity) = self.colorSensor.get_rgb_intensity()
|
(red, green, blue, colorIntensity) = self.colorSensor.get_rgb_intensity()
|
||||||
return colorIntensity
|
return colorIntensity
|
||||||
|
|
||||||
|
def schreibeL(self):
|
||||||
|
print("Schreibe L")
|
||||||
|
self.hubMotor.run_for_rotations(-0.06)
|
||||||
|
self.movementMotors.move(5)
|
||||||
|
self.rightMotor.run_for_degrees(90)
|
||||||
|
self.movementMotors.move(2)
|
||||||
|
self.hubMotor.run_for_rotations(0.06)
|
||||||
|
|
||||||
|
# Fahre 5 cm rückwerts
|
||||||
|
# dann drehe nach rechts 90°
|
||||||
|
# und fahre 2cm fohrwärts
|
||||||
|
#stift hoch
|
||||||
|
|
||||||
|
def schreibeE(self):
|
||||||
|
print("Schreibe E")
|
||||||
|
|
||||||
|
def schreibeG(self):
|
||||||
|
print("Schreibe G")
|
||||||
|
|
||||||
|
|
||||||
|
def schreibeO(self):
|
||||||
|
print("Schreibe O")
|
||||||
|
|
||||||
|
def schreibeLego(self):
|
||||||
|
self.schreibeL()
|
||||||
|
self.schreibeE()
|
||||||
|
self.schreibeG()
|
||||||
|
self.schreibeO()
|
||||||
|
|
||||||
print("successfully loaded the IQ Lego teams code :)")
|
print("successfully loaded the IQ Lego teams code :)")
|
||||||
|
|
||||||
|
|
9
main.py
9
main.py
|
@ -72,8 +72,8 @@ dh auch an die Funktionen im importierten Code übergeben werde
|
||||||
|
|
||||||
# Definiere an welchen Ports die Sensoren angeschlossen sind
|
# Definiere an welchen Ports die Sensoren angeschlossen sind
|
||||||
COLOR_SENSOR_PORT = 'E'
|
COLOR_SENSOR_PORT = 'E'
|
||||||
LEFT_MOTOR_PORT = 'A'
|
LEFT_MOTOR_PORT = 'D'
|
||||||
RIGHT_MOTOR_PORT = 'B'
|
RIGHT_MOTOR_PORT = 'A'
|
||||||
|
|
||||||
# Initialisieren des Hubs, der Aktoren und Sensoren
|
# Initialisieren des Hubs, der Aktoren und Sensoren
|
||||||
hub = PrimeHub()
|
hub = PrimeHub()
|
||||||
|
@ -83,10 +83,7 @@ iqRobot: iq.IQRobot = iq.IQRobot(hub, LEFT_MOTOR_PORT, RIGHT_MOTOR_PORT, COLOR_S
|
||||||
|
|
||||||
# Führe Funktionen aus unser Robot Klasse aus:
|
# Führe Funktionen aus unser Robot Klasse aus:
|
||||||
iqRobot.show('HAPPY')
|
iqRobot.show('HAPPY')
|
||||||
iqRobot.driveForward_for_sec(2.0)
|
iqRobot.schreibeLego()
|
||||||
colorIntensity = iqRobot.getColorIntensity()
|
|
||||||
print("Farbintensität: " + str(colorIntensity))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue