Skip to content

Commit

Permalink
Fix floating point comparison in JTC (backport #879)
Browse files Browse the repository at this point in the history
* Fix floating point comparison in JTC

* Fix format

---------

Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
  • Loading branch information
christophfroehlich and christophfroehlich committed Dec 4, 2023
1 parent 416d767 commit 493990d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +1467,11 @@ bool JointTrajectoryController::validate_trajectory_msg(
{
for (size_t i = 0; i < trajectory.points.back().velocities.size(); ++i)
{
if (trajectory.points.back().velocities.at(i) != 0.)
if (fabs(trajectory.points.back().velocities.at(i)) > std::numeric_limits<float>::epsilon())
{
RCLCPP_ERROR(
get_node()->get_logger(), "Velocity of last trajectory point of joint %s is not zero: %f",
get_node()->get_logger(),
"Velocity of last trajectory point of joint %s is not zero: %.15f",
trajectory.joint_names.at(i).c_str(), trajectory.points.back().velocities.at(i));
return false;
}
Expand Down

0 comments on commit 493990d

Please sign in to comment.