Brickies robot zeichen Versuche
This commit is contained in:
parent
0d1a84761a
commit
65f84c61a2
1 changed files with 26 additions and 14 deletions
40
iqrobot.py
40
iqrobot.py
|
@ -55,8 +55,9 @@ class IQRobot:
|
|||
(red, green, blue, colorIntensity) = self.colorSensor.get_rgb_intensity()
|
||||
return colorIntensity
|
||||
|
||||
def drehe(self, grad=90):
|
||||
self.motionSensor.reset_yaw_angle()
|
||||
def drehe(self, grad=90, with_reset=True):
|
||||
if with_reset:
|
||||
self.motionSensor.reset_yaw_angle()
|
||||
steering = 100 if grad > 0 else -100
|
||||
self.movementMotors.start(steering=steering, speed=10)
|
||||
while abs(self.motionSensor.get_yaw_angle()) < abs(grad):
|
||||
|
@ -69,16 +70,23 @@ class IQRobot:
|
|||
radius=9.5
|
||||
stift_versatz=2.2
|
||||
if self.typ == "brickies":
|
||||
radius=11.5
|
||||
stift_versatz=0.5
|
||||
radius=17.4
|
||||
stift_versatz=0.3
|
||||
self.fahre_gerade(-radius - stift_versatz)
|
||||
self.drehe(grad)
|
||||
self.fahre_gerade(radius - stift_versatz)
|
||||
|
||||
def fahre_gerade(self, cm):
|
||||
def fahre_gerade(self, cm, zeichne=False):
|
||||
if zeichne:
|
||||
self.bewege_stift(1) # Stift runter
|
||||
self.motionSensor.reset_yaw_angle()
|
||||
if self.typ == "brickies":
|
||||
cm = -cm
|
||||
self.movementMotors.move(cm)
|
||||
if zeichne:
|
||||
self.bewege_stift(-1) # Stift hoch
|
||||
versatz = self.motionSensor.get_yaw_angle()
|
||||
self.drehe(grad=-versatz)
|
||||
|
||||
def buchstabe_zu_segmenten(self, buchstabe):
|
||||
# Segmente um Buchstaben zu schreiben
|
||||
|
@ -95,7 +103,8 @@ class IQRobot:
|
|||
if self.typ == "backstein":
|
||||
self.frontMotorRight.run_for_rotations(richtung*0.4)
|
||||
if self.typ == "brickies":
|
||||
self.bothFrontMotors.move(-richtung*0.2, unit='rotations')
|
||||
#print("bewege stift brickies")
|
||||
self.bothFrontMotors.move(-richtung*0.2, unit='rotations', speed=5)
|
||||
|
||||
def schreibe_buchstabe(self, buchstabe):
|
||||
print("Schreibe " + buchstabe)
|
||||
|
@ -106,10 +115,9 @@ class IQRobot:
|
|||
for segment_nummer, segment in enumerate(segmente):
|
||||
print("Segment: " + str(segment) + " , Segment Nummer: " + str(segment_nummer))
|
||||
if segment==1:
|
||||
self.bewege_stift(1) # Stift runter
|
||||
self.fahre_gerade(5)
|
||||
if segment==1:
|
||||
self.bewege_stift(-1) # Stift hoch
|
||||
self.fahre_gerade(5, zeichne=True)
|
||||
else:
|
||||
self.fahre_gerade(5)
|
||||
if segment_nummer != 2 and segment_nummer != 6:
|
||||
self.drehe_robot(grad_drehung) # drehe links
|
||||
|
||||
|
@ -161,10 +169,14 @@ class IQRobot:
|
|||
#self.schreibeL()
|
||||
#self.schreibeL(schreibe=False, zurueck=True)
|
||||
self.movementMotors.set_default_speed(10)
|
||||
self.schreibe_buchstabe("L")
|
||||
self.schreibe_buchstabe("E")
|
||||
self.schreibe_buchstabe("G")
|
||||
self.schreibe_buchstabe("O")
|
||||
self.bewege_stift(-1)
|
||||
self.fahre_gerade(4, zeichne=True)
|
||||
self.drehe_robot()
|
||||
self.fahre_gerade(4, zeichne=True)
|
||||
#self.schreibe_buchstabe("L")
|
||||
#self.schreibe_buchstabe("E")
|
||||
#self.schreibe_buchstabe("G")
|
||||
#self.schreibe_buchstabe("O")
|
||||
|
||||
print("successfully loaded the IQ Lego teams code :)")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue