-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathleftRightCheck
More file actions
28 lines (26 loc) · 771 Bytes
/
Copy pathleftRightCheck
File metadata and controls
28 lines (26 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# call checkObstacleLFR to get an obstacle array
# DO NOT call checkObstacle. It's called by checkObstacleLFR
# put the distance you want as the parameter
def checkObstacle(thresholdDistance, Direction):
if Direction == "Forward":
Distance = getObstacle("middle")
elif Direction == "Left":
turnLeft(0.5,1.5)
Distance = getObstacle("middle")
turnRight(0.5,1.5)
elif Direction == "Right":
turnRight(0.5,1.5)
Distance = getObstacle("middle")
turnLeft(0.5,1.5)
else:
return 1
if Distance < thresholdDistance:
return 0
else:
return 1
def checkObstacleLFR(thresholdDistance):
a = [0,0,0]
a[0] = checkObstacle(thresholdDistance,"Left")
a[2] = checkObstacle(thresholdDistance,"Right")
a[1] = checkObstacle(thresholdDistance,"Forward")
return a