Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nav2_collision_monitor/src/collision_monitor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ CollisionMonitor::on_shutdown(const rclcpp_lifecycle::State & /*state*/)
void CollisionMonitor::cmdVelInCallbackStamped(geometry_msgs::msg::TwistStamped::SharedPtr msg)
{
// If message contains NaN or Inf, ignore
if (!nav2_util::validateTwist(*msg)) {
if (!nav2_util::validateTwist(msg->twist)) {
RCLCPP_ERROR(get_logger(), "Velocity message contains NaNs or Infs! Ignoring as invalid!");
return;
}
Expand Down
4 changes: 4 additions & 0 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,10 @@
void ControllerServer::publishVelocity(const geometry_msgs::msg::TwistStamped & velocity)
{
auto cmd_vel = std::make_unique<geometry_msgs::msg::TwistStamped>(velocity);
if (!nav2_util::validateTwist(cmd_vel->twist)) {
RCLCPP_ERROR(get_logger(), "Velocity message contains NaNs or Infs! Ignoring as invalid!");

Check warning on line 762 in nav2_controller/src/controller_server.cpp

View check run for this annotation

Codecov / codecov/patch

nav2_controller/src/controller_server.cpp#L762

Added line #L762 was not covered by tests
return;
}
if (vel_publisher_->is_activated() && vel_publisher_->get_subscription_count() > 0) {
vel_publisher_->publish(std::move(cmd_vel));
}
Expand Down
1 change: 0 additions & 1 deletion nav2_util/include/nav2_util/robot_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ bool getTransform(
* @return True if valid, false if contains unactionable values
*/
[[nodiscard]] bool validateTwist(const geometry_msgs::msg::Twist & msg);
[[nodiscard]] bool validateTwist(const geometry_msgs::msg::TwistStamped & msg);

} // end namespace nav2_util

Expand Down
5 changes: 0 additions & 5 deletions nav2_util/src/robot_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,4 @@ bool validateTwist(const geometry_msgs::msg::Twist & msg)
return true;
}

bool validateTwist(const geometry_msgs::msg::TwistStamped & msg)
{
return validateTwist(msg.twist);
}

} // end namespace nav2_util
Loading