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