Skip to content

Commit

Permalink
updated ultrasonic function
Browse files Browse the repository at this point in the history
  • Loading branch information
valenmoore committed May 6, 2024
1 parent 4e2edf6 commit 52aa092
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def simple_check(ultra):
for i in range(2):
for j in range(2):
# check two times if you can get around obstacle
rotate_to_heading(orig_angle, (orig_angle + (90 * turn_dir)) % 360) # turn in chosen direction
rotate_to_heading(orig_angle, (orig_angle + (80 * turn_dir)) % 360) # turn in chosen direction
drive.drive_forward()
time.sleep(forward_time)
angle = gps.get_heading()
Expand All @@ -161,7 +161,7 @@ def simple_check(ultra):
return True # check ultrasonics, return true if they are clear
turn_dir *= -1 # try the other direction, currently are facing towards obstacle
angle = gps.get_heading()
rotate_to_heading(angle, (orig_angle + (90 * turn_dir)) % 360) # turn in new chosen direction in order to move back
rotate_to_heading(angle, (orig_angle + (80 * turn_dir)) % 360) # turn in new chosen direction in order to move back
drive.drive_forward()
time.sleep(forward_time * 2) # drive back to where you started and repeat loop
return False # return false if you can't get unstuck, give up
Expand Down

0 comments on commit 52aa092

Please sign in to comment.