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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions nav2_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ find_package(nav2_common REQUIRED)
find_package(nav2_costmap_2d REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(nav_2d_msgs REQUIRED)
find_package(nav_2d_utils REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rcl_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
Expand Down Expand Up @@ -42,9 +40,6 @@ target_link_libraries(${library_name} PUBLIC
${nav2_msgs_TARGETS}
nav2_util::nav2_util_core
nav2_ros_common::nav2_ros_common
${nav_2d_msgs_TARGETS}
nav_2d_utils::conversions
nav_2d_utils::tf_help
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
Expand Down Expand Up @@ -86,7 +81,6 @@ target_link_libraries(simple_progress_checker PUBLIC
)
target_link_libraries(simple_progress_checker PRIVATE
nav2_util::nav2_util_core
nav_2d_utils::conversions
pluginlib::pluginlib
)

Expand All @@ -107,7 +101,6 @@ target_link_libraries(pose_progress_checker PUBLIC
target_link_libraries(pose_progress_checker PRIVATE
angles::angles
nav2_util::nav2_util_core
nav_2d_utils::conversions
pluginlib::pluginlib
)

Expand Down Expand Up @@ -218,8 +211,6 @@ ament_export_dependencies(
nav2_costmap_2d
nav2_msgs
nav2_util
nav_2d_msgs
nav_2d_utils
pluginlib
rclcpp
rclcpp_lifecycle
Expand Down
14 changes: 7 additions & 7 deletions nav2_controller/include/nav2_controller/controller_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#include "tf2_ros/transform_listener.hpp"
#include "nav2_msgs/action/follow_path.hpp"
#include "nav2_msgs/msg/speed_limit.hpp"
#include "nav_2d_utils/odom_subscriber.hpp"
#include "nav2_ros_common/lifecycle_node.hpp"
#include "nav2_ros_common/simple_action_server.hpp"
#include "nav2_util/robot_utils.hpp"
#include "nav2_util/odometry_utils.hpp"
#include "nav2_util/twist_publisher.hpp"
#include "pluginlib/class_loader.hpp"
#include "pluginlib/class_list_macros.hpp"
Expand Down Expand Up @@ -208,12 +208,12 @@ class ControllerServer : public nav2::LifecycleNode
* @param Twist The current Twist from odometry
* @return Twist Twist after thresholds applied
*/
nav_2d_msgs::msg::Twist2D getThresholdedTwist(const nav_2d_msgs::msg::Twist2D & twist)
geometry_msgs::msg::Twist getThresholdedTwist(const geometry_msgs::msg::Twist & twist)
{
nav_2d_msgs::msg::Twist2D twist_thresh;
twist_thresh.x = getThresholdedVelocity(twist.x, min_x_velocity_threshold_);
twist_thresh.y = getThresholdedVelocity(twist.y, min_y_velocity_threshold_);
twist_thresh.theta = getThresholdedVelocity(twist.theta, min_theta_velocity_threshold_);
geometry_msgs::msg::Twist twist_thresh;
twist_thresh.linear.x = getThresholdedVelocity(twist.linear.x, min_x_velocity_threshold_);
twist_thresh.linear.y = getThresholdedVelocity(twist.linear.y, min_y_velocity_threshold_);
twist_thresh.angular.z = getThresholdedVelocity(twist.angular.z, min_theta_velocity_threshold_);
return twist_thresh;
}

Expand All @@ -233,7 +233,7 @@ class ControllerServer : public nav2::LifecycleNode
std::unique_ptr<nav2::NodeThread> costmap_thread_;

// Publishers and subscribers
std::unique_ptr<nav_2d_utils::OdomSubscriber> odom_sub_;
std::unique_ptr<nav2_util::OdomSmoother> odom_sub_;
std::unique_ptr<nav2_util::TwistPublisher> vel_publisher_;
nav2::Subscription<nav2_msgs::msg::SpeedLimit>::SharedPtr speed_limit_sub_;

Expand Down
2 changes: 0 additions & 2 deletions nav2_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
<depend>nav2_costmap_2d</depend>
<depend>nav2_msgs</depend>
<depend>nav2_util</depend>
<depend>nav_2d_msgs</depend>
<depend>nav_2d_utils</depend>
<depend>pluginlib</depend>
<depend>rcl_interfaces</depend>
<depend>rclcpp</depend>
Expand Down
1 change: 0 additions & 1 deletion nav2_controller/plugins/pose_progress_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <memory>
#include <vector>
#include "angles/angles.h"
#include "nav_2d_utils/conversions.hpp"
#include "geometry_msgs/msg/pose_stamped.hpp"
#include "geometry_msgs/msg/pose.hpp"
#include "nav2_ros_common/node_utils.hpp"
Expand Down
1 change: 0 additions & 1 deletion nav2_controller/plugins/simple_progress_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <string>
#include <memory>
#include <vector>
#include "nav_2d_utils/conversions.hpp"
#include "geometry_msgs/msg/pose_stamped.hpp"
#include "geometry_msgs/msg/pose.hpp"
#include "nav2_ros_common/node_utils.hpp"
Expand Down
4 changes: 2 additions & 2 deletions nav2_controller/plugins/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ament_add_gtest(pctest progress_checker.cpp)
target_link_libraries(pctest simple_progress_checker pose_progress_checker nav_2d_utils::conversions)
target_link_libraries(pctest simple_progress_checker pose_progress_checker)

ament_add_gtest(gctest goal_checker.cpp)
target_link_libraries(gctest simple_goal_checker stopped_goal_checker nav_2d_utils::conversions)
target_link_libraries(gctest simple_goal_checker stopped_goal_checker)
1 change: 0 additions & 1 deletion nav2_controller/plugins/test/goal_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "gtest/gtest.h"
#include "nav2_controller/plugins/simple_goal_checker.hpp"
#include "nav2_controller/plugins/stopped_goal_checker.hpp"
#include "nav_2d_utils/conversions.hpp"
#include "nav2_util/geometry_utils.hpp"
#include "nav2_ros_common/lifecycle_node.hpp"
#include "eigen3/Eigen/Geometry"
Expand Down
1 change: 0 additions & 1 deletion nav2_controller/plugins/test/progress_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "gtest/gtest.h"
#include "nav2_controller/plugins/simple_progress_checker.hpp"
#include "nav2_controller/plugins/pose_progress_checker.hpp"
#include "nav_2d_utils/conversions.hpp"
#include "nav2_ros_common/lifecycle_node.hpp"
#include "nav2_util/geometry_utils.hpp"

Expand Down
33 changes: 17 additions & 16 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include "lifecycle_msgs/msg/state.hpp"
#include "nav2_core/controller_exceptions.hpp"
#include "nav_2d_utils/conversions.hpp"
#include "nav_2d_utils/tf_help.hpp"
#include "nav2_ros_common/node_utils.hpp"
#include "nav2_util/geometry_utils.hpp"
#include "nav2_controller/controller_server.hpp"
Expand Down Expand Up @@ -65,6 +63,9 @@ ControllerServer::ControllerServer(const rclcpp::NodeOptions & options)
declare_parameter("publish_zero_velocity", rclcpp::ParameterValue(true));
declare_parameter("costmap_update_timeout", 0.30); // 300ms

declare_parameter("odom_topic", rclcpp::ParameterValue("odom"));
Copy link
Member

@SteveMacenski SteveMacenski Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these 2x aren't in the configuration guide for the controller server, we need to add them

declare_parameter("odom_duration", rclcpp::ParameterValue(0.3));

// The costmap node is used in the implementation of the controller
costmap_ros_ = std::make_shared<nav2_costmap_2d::Costmap2DROS>(
"local_costmap", std::string{get_namespace()},
Expand Down Expand Up @@ -125,8 +126,11 @@ ControllerServer::on_configure(const rclcpp_lifecycle::State & state)
get_parameter("min_theta_velocity_threshold", min_theta_velocity_threshold_);
RCLCPP_INFO(get_logger(), "Controller frequency set to %.4fHz", controller_frequency_);

std::string speed_limit_topic;
std::string speed_limit_topic, odom_topic;
get_parameter("speed_limit_topic", speed_limit_topic);
get_parameter("odom_topic", odom_topic);
double odom_duration;
get_parameter("odom_duration", odom_duration);
get_parameter("failure_tolerance", failure_tolerance_);
get_parameter("use_realtime_priority", use_realtime_priority_);
get_parameter("publish_zero_velocity", publish_zero_velocity_);
Expand Down Expand Up @@ -219,7 +223,7 @@ ControllerServer::on_configure(const rclcpp_lifecycle::State & state)
get_logger(),
"Controller Server has %s controllers available.", controller_ids_concat_.c_str());

odom_sub_ = std::make_unique<nav_2d_utils::OdomSubscriber>(node);
odom_sub_ = std::make_unique<nav2_util::OdomSmoother>(node, odom_duration, odom_topic);
vel_publisher_ = std::make_unique<nav2_util::TwistPublisher>(node, "cmd_vel");

double costmap_update_timeout_dbl;
Expand Down Expand Up @@ -624,15 +628,15 @@ void ControllerServer::computeAndPublishVelocity()
throw nav2_core::FailedToMakeProgress("Failed to make progress");
}

nav_2d_msgs::msg::Twist2D twist = getThresholdedTwist(odom_sub_->getTwist());
geometry_msgs::msg::Twist twist = getThresholdedTwist(odom_sub_->getRawTwist());

geometry_msgs::msg::TwistStamped cmd_vel_2d;

try {
cmd_vel_2d =
controllers_[current_controller_]->computeVelocityCommands(
pose,
nav_2d_utils::twist2Dto3D(twist),
twist,
goal_checkers_[current_goal_checker_].get());
last_valid_cmd_time_ = now();
cmd_vel_2d.header.frame_id = costmap_ros_->getBaseFrameID();
Expand Down Expand Up @@ -665,10 +669,9 @@ void ControllerServer::computeAndPublishVelocity()

// Find the closest pose to current pose on global path
geometry_msgs::msg::PoseStamped robot_pose_in_path_frame;
rclcpp::Duration tolerance(rclcpp::Duration::from_seconds(costmap_ros_->getTransformTolerance()));
if (!nav_2d_utils::transformPose(
costmap_ros_->getTfBuffer(), current_path_.header.frame_id, pose,
robot_pose_in_path_frame, tolerance))
if (!nav2_util::transformPoseInTargetFrame(
pose, robot_pose_in_path_frame, *costmap_ros_->getTfBuffer(),
current_path_.header.frame_id, costmap_ros_->getTransformTolerance()))
{
throw nav2_core::ControllerTFError("Failed to transform robot pose to path frame");
}
Expand Down Expand Up @@ -793,14 +796,12 @@ bool ControllerServer::isGoalReached()
return false;
}

nav_2d_msgs::msg::Twist2D twist = getThresholdedTwist(odom_sub_->getTwist());
geometry_msgs::msg::Twist velocity = nav_2d_utils::twist2Dto3D(twist);
geometry_msgs::msg::Twist velocity = getThresholdedTwist(odom_sub_->getRawTwist());

geometry_msgs::msg::PoseStamped transformed_end_pose;
rclcpp::Duration tolerance(rclcpp::Duration::from_seconds(costmap_ros_->getTransformTolerance()));
nav_2d_utils::transformPose(
costmap_ros_->getTfBuffer(), costmap_ros_->getGlobalFrameID(),
end_pose_, transformed_end_pose, tolerance);
nav2_util::transformPoseInTargetFrame(
end_pose_, transformed_end_pose, *costmap_ros_->getTfBuffer(),
costmap_ros_->getGlobalFrameID(), costmap_ros_->getTransformTolerance());

return goal_checkers_[current_goal_checker_]->isGoalReached(
pose.pose, transformed_end_pose.pose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "nav2_ros_common/node_utils.hpp"
#include "nav2_ros_common/simple_action_server.hpp"
#include "nav2_util/twist_publisher.hpp"
#include "nav_2d_utils/odom_subscriber.hpp"
#include "nav2_util/odometry_utils.hpp"
#include "opennav_docking/controller.hpp"
#include "opennav_docking/utils.hpp"
#include "opennav_docking/types.hpp"
Expand Down Expand Up @@ -264,7 +264,7 @@ class DockingServer : public nav2::LifecycleNode
rclcpp::Time action_start_time_;

std::unique_ptr<nav2_util::TwistPublisher> vel_publisher_;
std::unique_ptr<nav_2d_utils::OdomSubscriber> odom_sub_;
std::unique_ptr<nav2_util::OdomSmoother> odom_sub_;
typename DockingActionServer::SharedPtr docking_action_server_;
typename UndockingActionServer::SharedPtr undocking_action_server_;

Expand Down
1 change: 0 additions & 1 deletion nav2_docking/opennav_docking/src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "opennav_docking/controller.hpp"
#include "nav2_util/geometry_utils.hpp"
#include "nav2_ros_common/node_utils.hpp"
#include "nav_2d_utils/conversions.hpp"
#include "tf2/utils.hpp"

namespace opennav_docking
Expand Down
7 changes: 5 additions & 2 deletions nav2_docking/opennav_docking/src/docking_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ DockingServer::DockingServer(const rclcpp::NodeOptions & options)
declare_parameter("dock_backwards", rclcpp::PARAMETER_BOOL);
declare_parameter("dock_prestaging_tolerance", 0.5);
declare_parameter("odom_topic", "odom");
declare_parameter("odom_duration", 0.3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

declare_parameter("rotation_angular_tolerance", 0.05);
}

Expand Down Expand Up @@ -83,7 +84,9 @@ DockingServer::on_configure(const rclcpp_lifecycle::State & state)
// Create odom subscriber for backward blind docking
std::string odom_topic;
get_parameter("odom_topic", odom_topic);
odom_sub_ = std::make_unique<nav_2d_utils::OdomSubscriber>(node, odom_topic);
double odom_duration;
get_parameter("odom_duration", odom_duration);
odom_sub_ = std::make_unique<nav2_util::OdomSmoother>(node, odom_duration, odom_topic);

// Create the action servers for dock / undock
docking_action_server_ = node->create_action_server<DockRobot>(
Expand Down Expand Up @@ -464,7 +467,7 @@ void DockingServer::rotateToDock(const geometry_msgs::msg::PoseStamped & dock_po
}

auto current_vel = std::make_unique<geometry_msgs::msg::TwistStamped>();
current_vel->twist.angular.z = odom_sub_->getTwist().theta;
current_vel->twist.angular.z = odom_sub_->getRawTwist().angular.z;

auto command = std::make_unique<geometry_msgs::msg::TwistStamped>();
command->header = robot_pose.header;
Expand Down
1 change: 0 additions & 1 deletion nav2_dwb_controller/dwb_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ target_link_libraries(dwb_core PUBLIC
nav2_util::nav2_util_core
${nav_2d_msgs_TARGETS}
nav_2d_utils::conversions
nav_2d_utils::tf_help
${nav_msgs_TARGETS}
pluginlib::pluginlib
rclcpp::rclcpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class DWBLocalPlanner : public nav2_core::Controller
bool prune_plan_;
double prune_distance_;
bool debug_trajectory_details_;
rclcpp::Duration transform_tolerance_{0, 0};
double transform_tolerance_{0};
bool shorten_transformed_plan_;
double forward_prune_distance_;

Expand Down
22 changes: 10 additions & 12 deletions nav2_dwb_controller/dwb_core/src/dwb_local_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "dwb_msgs/msg/critic_score.hpp"
#include "nav_2d_msgs/msg/twist2_d.hpp"
#include "nav_2d_utils/conversions.hpp"
#include "nav_2d_utils/tf_help.hpp"
#include "nav2_util/geometry_utils.hpp"
#include "nav2_ros_common/lifecycle_node.hpp"
#include "nav2_ros_common/node_utils.hpp"
Expand Down Expand Up @@ -112,8 +111,7 @@ void DWBLocalPlanner::configure(
std::string traj_generator_name;

double transform_tolerance;
node->get_parameter(dwb_plugin_name_ + ".transform_tolerance", transform_tolerance);
transform_tolerance_ = rclcpp::Duration::from_seconds(transform_tolerance);
node->get_parameter(dwb_plugin_name_ + ".transform_tolerance", transform_tolerance_);
RCLCPP_INFO(logger_, "Setting transform_tolerance to %f", transform_tolerance);

node->get_parameter(dwb_plugin_name_ + ".prune_plan", prune_plan_);
Expand Down Expand Up @@ -293,9 +291,9 @@ DWBLocalPlanner::prepareGlobalPlan(

goal_pose.header.frame_id = global_plan_.header.frame_id;
goal_pose.pose = global_plan_.poses.back().pose;
nav_2d_utils::transformPose(
tf_, costmap_ros_->getGlobalFrameID(), goal_pose,
goal_pose, transform_tolerance_);
nav2_util::transformPoseInTargetFrame(
goal_pose, goal_pose, *tf_,
costmap_ros_->getGlobalFrameID(), transform_tolerance_);
}

nav_2d_msgs::msg::Twist2DStamped
Expand Down Expand Up @@ -470,9 +468,9 @@ DWBLocalPlanner::transformGlobalPlan(

// let's get the pose of the robot in the frame of the plan
geometry_msgs::msg::PoseStamped robot_pose;
if (!nav_2d_utils::transformPose(
tf_, global_plan_.header.frame_id, pose,
robot_pose, transform_tolerance_))
if (!nav2_util::transformPoseInTargetFrame(
pose, robot_pose, *tf_,
global_plan_.header.frame_id, transform_tolerance_))
{
throw nav2_core::
ControllerTFError("Unable to transform robot pose into global plan's frame");
Expand Down Expand Up @@ -538,9 +536,9 @@ DWBLocalPlanner::transformGlobalPlan(
// frame to local
auto transformGlobalPoseToLocal = [&](const auto & global_plan_pose) {
geometry_msgs::msg::PoseStamped transformed_pose;
nav_2d_utils::transformPose(
tf_, transformed_plan.header.frame_id,
global_plan_pose, transformed_pose, transform_tolerance_);
nav2_util::transformPoseInTargetFrame(
global_plan_pose, transformed_pose, *tf_,
transformed_plan.header.frame_id, transform_tolerance_);
return transformed_pose;
};

Expand Down
6 changes: 2 additions & 4 deletions nav2_dwb_controller/dwb_critics/src/goal_align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <string>
#include "dwb_critics/alignment_util.hpp"
#include "pluginlib/class_list_macros.hpp"
#include "nav_2d_utils/parameters.hpp"

namespace dwb_critics
{
Expand All @@ -52,9 +51,8 @@ void GoalAlignCritic::onInit()
throw std::runtime_error{"Failed to lock node"};
}

forward_point_distance_ = nav_2d_utils::searchAndGetParam(
node,
dwb_plugin_name_ + "." + name_ + ".forward_point_distance", 0.325);
forward_point_distance_ = node->declare_or_get_parameter(dwb_plugin_name_ + "." + name_ +
".forward_point_distance", 0.325);
}

bool GoalAlignCritic::prepare(
Expand Down
Loading
Loading