force_move: Avoid divide by zero in move time calculation

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-03-31 09:00:23 -04:00
parent 75b73b09d6
commit 60ff2e9dc1
1 changed files with 1 additions and 1 deletions

View File

@ -12,7 +12,7 @@ STALL_TIME = 0.100
# Calculate a move's accel_t, cruise_t, and cruise_v # Calculate a move's accel_t, cruise_t, and cruise_v
def calc_move_time(dist, speed, accel): def calc_move_time(dist, speed, accel):
dist = abs(dist) dist = abs(dist)
if not accel: if not accel or not dist:
return 0., dist / speed, speed return 0., dist / speed, speed
max_cruise_v2 = dist * accel max_cruise_v2 = dist * accel
if max_cruise_v2 < speed**2: if max_cruise_v2 < speed**2: