Skip to content

Commit

Permalink
check norm in inspection points divide by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-cunningham committed Dec 16, 2024
1 parent 382a4d1 commit 20c8f45
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions safe_autonomy_simulation/sims/inspection/inspection_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,15 @@ def _generate_points(
else:
point_weights = []
for pos in point_positions:
dot_prod = np.dot(-self.priority_vector, pos) / (
np.linalg.norm(-self.priority_vector) * np.linalg.norm(pos)
)
if (
np.linalg.norm(-self.priority_vector) != 0
and np.linalg.norm(pos) != 0
):
dot_prod = np.dot(-self.priority_vector, pos) / (
np.linalg.norm(-self.priority_vector) * np.linalg.norm(pos)
)
else:
dot_prod = np.dot(-self.priority_vector, pos)
if dot_prod <= 0:
point_weights.append(np.arccos(dot_prod) / np.pi)
else:
Expand Down

0 comments on commit 20c8f45

Please sign in to comment.