Linting businessbot.py

pull/382/head
Hel Gibbons 2022-05-30 17:02:27 +01:00
rodzic 3bdb313f3d
commit fe9446aea3
1 zmienionych plików z 6 dodań i 9 usunięć

Wyświetl plik

@ -111,21 +111,18 @@ while True:
x /= scalar
x /= 3.5
x -= 1.0
print("Object detected at x: {:.2f}, y: {:.2f}".format(x, y))
# Our robot will try and keep the object a goal distance in front of it.
# If the object gets closer it will reverse, if the object gets further away it will drive forward.
scale = (target_distance - GOAL_DISTANCE) / SPEED_RANGE
spd = max(min(scale, 1.0), -1.0) * DRIVING_SPEED
print("Distance is {:.1f} mm. Speed is {:.2f}".format(target_distance, spd))
left.speed(spd - (x * TURNING_SPEED))
right.speed(spd + (x * TURNING_SPEED))
right.speed(spd + (x * TURNING_SPEED))
else:
left.coast()
right.coast()
right.coast()