Skip to content

Commit 6c31951

Browse files
authored
Merge pull request #81 from CleoQc/DexterOS
fix turn block
2 parents 95eec85 + f86a7b9 commit 6c31951

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Software/Python/easygopigo3.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def forward(self):
106106
self.set_motor_dps(self.MOTOR_LEFT + self.MOTOR_RIGHT,
107107
self.get_speed())
108108

109-
def drive_cm(self, dist, blocking=False):
109+
def drive_cm(self, dist, blocking=True):
110110
# dist is in cm
111111
# if dist is negative, this becomes a backward move
112112

@@ -130,10 +130,10 @@ def drive_cm(self, dist, blocking=False):
130130
StartPositionRight + WheelTurnDegrees) is False:
131131
time.sleep(0.1)
132132

133-
def drive_inches(self, dist, blocking=False):
133+
def drive_inches(self, dist, blocking=True):
134134
self.drive_cm(dist * 2.54, blocking)
135135

136-
def drive_degrees(self, degrees, blocking=False):
136+
def drive_degrees(self, degrees, blocking=True):
137137
# these degrees are meant to be wheel rotations.
138138
# 360 degrees would be a full wheel rotation
139139
# not the same as turn_degrees() which is a robot rotation
@@ -256,7 +256,7 @@ def close_eyes(self):
256256
self.close_left_eye()
257257
self.close_right_eye()
258258

259-
def turn_degrees(self, degrees):
259+
def turn_degrees(self, degrees,blocking=True):
260260
# this is the method to use if you want the robot to turn 90 degrees
261261
# or any other amount. This method is based on robot orientation
262262
# and not wheel rotation
@@ -276,6 +276,12 @@ def turn_degrees(self, degrees):
276276
(StartPositionLeft + WheelTurnDegrees))
277277
self.set_motor_position(self.MOTOR_RIGHT,
278278
(StartPositionRight - WheelTurnDegrees))
279+
280+
if blocking:
281+
while self.target_reached(
282+
StartPositionLeft + WheelTurnDegrees,
283+
StartPositionRight - WheelTurnDegrees) is False:
284+
time.sleep(0.1)
279285

280286

281287
# the following functions may be redundant

0 commit comments

Comments
 (0)