Skip to content

Commit

Permalink
Fix segfault in totg (moveit#1861)
Browse files Browse the repository at this point in the history
Ensure acos argument in valid range
  • Loading branch information
Dale-Koenig authored and v4hn committed Mar 31, 2020
1 parent 6b80d7a commit ac84701
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class CircularPathSegment : public PathSegment
const Eigen::VectorXd start_direction = (intersection - start).normalized();
const Eigen::VectorXd end_direction = (end - intersection).normalized();

// check if directions are divergent
if ((start_direction - end_direction).norm() < 0.000001)
{
length_ = 0.0;
Expand All @@ -122,7 +121,7 @@ class CircularPathSegment : public PathSegment
}

// directions must be different at this point so angle is always non-zero
const double angle = acos(start_direction.dot(end_direction));
const double angle = acos(std::max(-1.0, start_direction.dot(end_direction)));
const double start_distance = (start - intersection).norm();
const double end_distance = (end - intersection).norm();

Expand Down

0 comments on commit ac84701

Please sign in to comment.