Skip to content

Commit

Permalink
Remove ValueError #16
Browse files Browse the repository at this point in the history
  • Loading branch information
RexBerry committed Feb 8, 2023
1 parent 9064191 commit de2fd8f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions flight/avoidance/obstacle_avoidance.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ async def calculate_avoidance_velocity(
# No obstacles found
return None

if len(obstacle_data) == 1:
raise ValueError(
"Expected obstacle_data to have a length of 0 or at least 2; "
f"got a length of {len(obstacle_data)}"
)
if len(obstacle_data) < 2:
# Need at least 2 data points to calculate velocity of the obstacle
return None

# Get position of drone
drone_position: mavsdk.telemetry.Position = await anext(drone.telemetry.position())
Expand Down

0 comments on commit de2fd8f

Please sign in to comment.