schreibe Lego mit Segmenten Backsteinrobot
This commit is contained in:
parent
e29586681a
commit
b654633332
2 changed files with 15 additions and 7 deletions
18
iqrobot.py
18
iqrobot.py
|
@ -18,7 +18,7 @@ class IQRobot:
|
|||
self.movementMotors: MotorPair = MotorPair(leftMotorPort, rightMotorPort)
|
||||
#self.colorSensor: ColorSensor = ColorSensor(colorSensorPort)
|
||||
#self.frontMotorLeft: Motor = Motor("C")
|
||||
self.frontMotorRight: Motor = Motor("B")
|
||||
self.frontMotorRight: Motor = Motor("E")
|
||||
self.motionSensor: MotionSensor = MotionSensor()
|
||||
|
||||
|
||||
|
@ -50,6 +50,13 @@ class IQRobot:
|
|||
self.movementMotors.stop()
|
||||
|
||||
|
||||
def drehe_backstein_robot(self, grad=90):
|
||||
radius=9.5
|
||||
stift_versatz=2.2
|
||||
self.movementMotors.move(-radius - stift_versatz)
|
||||
self.drehe(grad)
|
||||
self.movementMotors.move(radius - stift_versatz)
|
||||
|
||||
def buchstabe_zu_segmenten(self, buchstabe):
|
||||
# Segmente um Buchstaben zu schreiben
|
||||
# 5_
|
||||
|
@ -65,19 +72,20 @@ class IQRobot:
|
|||
self.frontMotorRight.run_for_rotations(richtung*0.4)
|
||||
|
||||
def schreibe_buchstabe(self, buchstabe):
|
||||
print(f"Schreibe {buchstabe}")
|
||||
print("Schreibe " + buchstabe)
|
||||
segmente = self.buchstabe_zu_segmenten(buchstabe)
|
||||
grad_drehung=90
|
||||
grad_drehung=-90
|
||||
self.movementMotors.move(2)
|
||||
self.drehe(grad_drehung)
|
||||
for segment, segment_nummer in enumerate(segmente):
|
||||
print("Segment: " + str(segment) + " , Segment Nummer: " + str(segment_nummer))
|
||||
if segment==1:
|
||||
self.bewege_stift(-1)
|
||||
self.movementMotors.move(5)
|
||||
if segment==1:
|
||||
self.bewege_stift(1)
|
||||
if segment_nummer+1 != 3:
|
||||
self.drehe(grad_drehung)
|
||||
if (segment_nummer+1) != 3:
|
||||
self.drehe_backstein_robot(grad_drehung)
|
||||
|
||||
|
||||
def schreibeL(self, schreibe=True, zurueck=False):
|
||||
|
|
4
main.py
4
main.py
|
@ -73,8 +73,8 @@ dh auch an die Funktionen im importierten Code übergeben werde
|
|||
|
||||
# Definiere an welchen Ports die Sensoren angeschlossen sind
|
||||
COLOR_SENSOR_PORT = 'E' #not implemented yet
|
||||
LEFT_MOTOR_PORT = 'E'
|
||||
RIGHT_MOTOR_PORT = 'F'
|
||||
LEFT_MOTOR_PORT = 'F'
|
||||
RIGHT_MOTOR_PORT = 'B'
|
||||
|
||||
# Initialisieren des Hubs, der Aktoren und Sensoren
|
||||
hub = PrimeHub()
|
||||
|
|
Loading…
Reference in a new issue