87
# Change the scanned direction
if
scanDir == 1: scanDir =
elif
scanDir == -1: scanDir =
# Restore scanned location
scanPos +=
scanDir*2
print(scanList)
# If the distance of the nearest obstacle in front is less than the threshold
if
min(scanList) < rangeKeep:
# If the closest obstacle is on the left
if
scanList.index(min(scanList)) == 0:
# Then, turn right
scGear.moveAngle(2, -30)
# If the closest obstacle is right ahead
elif
scanList.index(min(scanList)) == 1:
# See the value on the left and right to determine which is larger
if
scanList[0] < scanList[2]:
# Full rudder to the right and move
scGear.moveAngle(2, -45)
else:
# Otherwise, full rudder to the left and move
scGear.moveAngle(2, 45)
# If the closest obstacle is on the right
elif
scanList.index(min(scanList)) == 2:
# Then, turn left
scGear.moveAngle(2, 30)
if
max(scanList) < rangeKeep
move.motor_lef(1, 1, 80)
move.motor_right(1, 1, 80)
# If the distance of the nearest obstacle in front is greater than the threshold, the car moves backward
else:
move.motor_left(1, 0, 80)
move.motor_right(1, 0, 80)
-1
1
or
min(scanList) < rangeKeep/3:
Need help?
Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?