27. if min(scanList) < rangeKeep:
28. if scanList.index(min(scanList)) == 0: #The shortest distance detected on the left
29. '''
30. Turn right
31. '''
32. print('Turn right')
33. elif scanList.index(min(scanList)) == 1: #The shortest distance detected in the middle
34. if scanList[0] < scanList[2]:
35. '''
36. If the detected distance on the left is shorter than the right, turn to the right
37. '''
38. print('Turn right')
39. else:
40. '''''
41. Otherwise, turn left
42. '''
43. print('Turn left')
44. elif scanList.index(min(scanList)) == 2: #The shortest distance detected on the right
45. '''
46. Turn Left
47. '''
48. print('Turn Left')
49. if max(scanList) < rangeKeep:
50. '''
51. If the distances in the left, center, and right directions are all closer than rangeKeep, reverse
52. '''
53. print('reverse')
54. else:
55. '''
56. All three directions are farther than rangeKeep
57. '''
58. print('Go forward')