21022024 #20

Merged
viernst merged 53 commits from 21022024 into energybrickies 2024-02-21 17:05:35 +00:00
Showing only changes of commit ad4b131af6 - Show all commits

View file

@ -87,13 +87,25 @@ class IQRobot:
def drehe(self, grad=90, with_reset=True):
if grad == 0 or grad == 360 :
print("nichts zu tun")
return
if with_reset:
self.motionSensor.reset_yaw_angle()
steering = 100 if grad > 0 else -100
#steering = 100 if grad > 0 else -100
toleranz = 0
aktuell = self.motionSensor.get_yaw_angle()
ziel = grad
steering = 100 if ziel > aktuell else -100
self.movementMotors.start(steering=steering, speed=10)
while abs(self.motionSensor.get_yaw_angle()) < abs(grad):
differenz = ziel - aktuell
print ("Start Ziel: {}, Aktuell: {}".format(ziel, aktuell))
while abs(differenz) > toleranz :
aktuell = self.motionSensor.get_yaw_angle()
differenz = ziel - aktuell
pass
self.movementMotors.stop()
print ("Final Ziel: {}, Aktuell: {}".format(ziel, aktuell))
def fahre_gerade(self, cm):
@ -129,7 +141,29 @@ class IQRobot:
self.drehe(grad)
self.fahre_gerade_geregelt(strecke2 - self.abstand_rad_front)
def fahre_gerade_aus(self, cm,speed):
self.motionSensor.reset_yaw_angle()
self.movementMotors.move_tank(amount=cm,left_speed=speed, right_speed=speed)
drehung = self.motionSensor.get_yaw_angle()
print(drehung)
if drehung > 0:
richtung = -1
else:
richtung = 1
while abs(drehung) > 2:
self.movementMotors.move(amount=richtung * 0.1, steering=100)
drehung = self.motionSensor.get_yaw_angle()
print(drehung)
print("successfully loaded the IQ Lego teams code :)")