OLD 7: Nav Algorithm
Last updated
Was this helpful?
Was this helpful?
def obstacle_count(self):
"""scans and estimates the number of obstacles within sight"""
self.wide_scan()
found_something = False
counter = 0
for ang, distance in enumerate(self.scan):
if distance and distance < 200 and not found_something:
found_something = True
counter += 1
print("Object # %d found, I think" % counter)
if distance and distance > 200 and found_something:
found_something = False
print("\n----I SEE %d OBJECTS----\n" % counter)# create two variables, left_total and right_total
# loop from self.MIDPOINT - 60 to self.MIDPOINT
# add up the numbers to right_total
# loop from self.MIDPOINT to self.MIDPOINT + 60
# add up the numbers to left_total
# if right is bigger:
# turn right
# if left is bigger:
# turn left