adjust roam speed
This commit is contained in:
parent
15ef7493c7
commit
1ae7b3dbb2
|
@ -105,8 +105,11 @@ class motion:
|
||||||
self.__roam_handle()
|
self.__roam_handle()
|
||||||
|
|
||||||
def __roam_handle(self):
|
def __roam_handle(self):
|
||||||
sensitivity = 35
|
sensitivity = 65
|
||||||
self.drive(23)
|
turn_speed = 30
|
||||||
|
drive_speed = 30
|
||||||
|
|
||||||
|
self.drive(drive_speed)
|
||||||
f_dist = self.sensors.sonar_get_distance(1)
|
f_dist = self.sensors.sonar_get_distance(1)
|
||||||
if 0 < f_dist < sensitivity: # Close to collision, turn the vehicle
|
if 0 < f_dist < sensitivity: # Close to collision, turn the vehicle
|
||||||
print("collision")
|
print("collision")
|
||||||
|
@ -115,24 +118,24 @@ class motion:
|
||||||
if l_dist < sensitivity: # Left side is blocked
|
if l_dist < sensitivity: # Left side is blocked
|
||||||
if r_dist < sensitivity: # Both side are blocked, do a full 180deg turn
|
if r_dist < sensitivity: # Both side are blocked, do a full 180deg turn
|
||||||
print("full turn")
|
print("full turn")
|
||||||
self.turn(30, 2*TURN_TIME_FS_90DEG_MS)
|
self.turn(30, 2)
|
||||||
self.drive(23)
|
self.drive(23)
|
||||||
else:
|
else:
|
||||||
# Right Side is Free, turn right
|
# Right Side is Free, turn right
|
||||||
print("right turn")
|
print("right turn")
|
||||||
self.turn(30, TURN_TIME_FS_90DEG_MS)
|
self.turn(turn_speed, 1)
|
||||||
self.drive(23)
|
self.drive(drive_speed)
|
||||||
elif r_dist < sensitivity: # Right side is blocked, left side is free, turn left
|
elif r_dist < sensitivity: # Right side is blocked, left side is free, turn left
|
||||||
print("right left")
|
print("right left")
|
||||||
self.turn(-30, TURN_TIME_FS_90DEG_MS)
|
self.turn(-turn_speed, 1)
|
||||||
self.drive(23)
|
self.drive(drive_speed)
|
||||||
else: # Both Side are free, randomize a direction
|
else: # Both Side are free, randomize a direction
|
||||||
print("turn random")
|
print("turn random")
|
||||||
right: bool = randint(0, 1)
|
right: bool = randint(0, 1)
|
||||||
if right:
|
if right:
|
||||||
self.turn(30, TURN_TIME_FS_90DEG_MS)
|
self.turn(turn_speed, 1)
|
||||||
self.drive(23)
|
self.drive(drive_speed)
|
||||||
else:
|
else:
|
||||||
self.turn(-23, TURN_TIME_FS_90DEG_MS)
|
self.turn(-turn_speed, 1)
|
||||||
self.drive(30)
|
self.drive(drive_speed)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
Loading…
Reference in New Issue