You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# If the robot is to stop, stop the motors. Otherwise, leave the motors on and return.
658
668
ifnotStop==False:
659
-
self.steer.stop()
669
+
self.steer.stop()
670
+
671
+
defTriangleAvoid(self, Heading, Distance, Speed):
672
+
"""
673
+
Moves the robot in a specified direction at a specified speed for a certian number of centimeters, while using the gyro sensor to keep the robot moving in a straight line.
674
+
675
+
``Heading``: The angle at which to drive, with the direction the gyro was last calibrated in being zero.
676
+
``Distance``: The distance to drive, in centimeters (positive only).
677
+
``Speed``: The speed at which to drive, in motor percentage (same speed units as EV3-G). A negative value will make the robot drive backwards.
678
+
``Stop``: Stop motors after completion. If ``FALSE``, motors will continue running after ``Distance`` has been traveled. Otherwise, motors will stop after ``Distance`` cm.
679
+
"""
680
+
# Ensure values are within reasonable limits, and change them if necessary (Idiotproofing).
681
+
ifDistance<=0:
682
+
print("Distance must be greater than zero. Use negative speed to drive backwards.")
683
+
return
684
+
elifDistance>265:
685
+
# The longest distance on an FLL table (diagonal) is about 265cm.
686
+
ifself.ForFLL:
687
+
print("Please don't use silly distances (max = 265cm)")
688
+
return
689
+
ifSpeed>75:
690
+
Speed=75
691
+
print("Speed must be between -75 and 75 (inclusive).")
692
+
elifSpeed<-75:
693
+
Speed=-75
694
+
print("Speed must be between -75 and 75 (inclusive).")
695
+
ifnotself.us:
696
+
print("Avoidance Functions need the US sensor to work.")
697
+
return
698
+
699
+
# "Reset" motor encoders by subtracting start values
0 commit comments