16 #ifndef NAV2_SMOOTHER__NAV2_SMOOTHER_HPP_
17 #define NAV2_SMOOTHER__NAV2_SMOOTHER_HPP_
22 #include <unordered_map>
25 #include "nav2_core/smoother.hpp"
26 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
27 #include "nav2_costmap_2d/costmap_subscriber.hpp"
28 #include "nav2_costmap_2d/costmap_topic_collision_checker.hpp"
29 #include "nav2_costmap_2d/footprint_subscriber.hpp"
30 #include "nav2_msgs/action/smooth_path.hpp"
31 #include "nav2_ros_common/lifecycle_node.hpp"
32 #include "nav2_ros_common/tf2_factories.hpp"
33 #include "nav2_util/robot_utils.hpp"
34 #include "nav2_ros_common/simple_action_server.hpp"
35 #include "pluginlib/class_list_macros.hpp"
36 #include "pluginlib/class_loader.hpp"
38 namespace nav2_smoother
49 using SmootherMap = std::unordered_map<std::string, nav2_core::Smoother::Ptr>;
55 explicit SmootherServer(
const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
72 nav2::CallbackReturn
on_configure(
const rclcpp_lifecycle::State & state)
override;
88 nav2::CallbackReturn
on_activate(
const rclcpp_lifecycle::State & state)
override;
98 nav2::CallbackReturn
on_deactivate(
const rclcpp_lifecycle::State & state)
override;
108 nav2::CallbackReturn
on_cleanup(
const rclcpp_lifecycle::State & state)
override;
115 nav2::CallbackReturn
on_shutdown(
const rclcpp_lifecycle::State & state)
override;
117 using Action = nav2_msgs::action::SmoothPath;
118 using ActionResult = Action::Result;
126 bool goalReceived(std::shared_ptr<const Action::Goal> goal);
145 bool findSmootherId(
const std::string & c_name, std::string & name);
152 bool validate(
const nav_msgs::msg::Path & path);
155 typename ActionServer::SharedPtr action_server_;
158 nav2::TransformBuffer::SharedPtr tf_;
159 nav2::TransformListener::SharedPtr transform_listener_;
162 nav2::Publisher<nav_msgs::msg::Path>::SharedPtr plan_publisher_;
165 pluginlib::ClassLoader<nav2_core::Smoother> lp_loader_;
166 SmootherMap smoothers_;
167 std::vector<std::string> default_ids_;
168 std::vector<std::string> default_types_;
169 std::vector<std::string> smoother_ids_;
170 std::vector<std::string> smoother_types_;
171 std::string smoother_ids_concat_, current_smoother_;
174 std::shared_ptr<nav2_costmap_2d::CostmapSubscriber> costmap_sub_;
175 std::shared_ptr<nav2_costmap_2d::FootprintSubscriber> footprint_sub_;
176 std::shared_ptr<nav2_costmap_2d::CostmapTopicCollisionChecker> collision_checker_;
A lifecycle node wrapper to enable common Nav2 needs such as manipulating parameters.
An action server wrapper to make applications simpler using Actions.
This class hosts variety of plugins of different algorithms to smooth or refine a path from the expos...
nav2::CallbackReturn on_deactivate(const rclcpp_lifecycle::State &state) override
Deactivates member variables.
~SmootherServer()
Destructor for nav2_smoother::SmootherServer.
bool loadSmootherPlugins()
Loads smoother plugins from parameter file.
nav2::CallbackReturn on_activate(const rclcpp_lifecycle::State &state) override
Activates member variables.
bool validate(const nav_msgs::msg::Path &path)
Validate that the path contains a meaningful path for smoothing.
SmootherServer(const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
A constructor for nav2_smoother::SmootherServer.
nav2::CallbackReturn on_cleanup(const rclcpp_lifecycle::State &state) override
Calls clean up states and resets member variables.
bool goalReceived(std::shared_ptr< const Action::Goal > goal)
Goal received callback to validate a new goal before acceptance.
nav2::CallbackReturn on_shutdown(const rclcpp_lifecycle::State &state) override
Called when in Shutdown state.
nav2::CallbackReturn on_configure(const rclcpp_lifecycle::State &state) override
Configures smoother parameters and member variables.
bool findSmootherId(const std::string &c_name, std::string &name)
Find the valid smoother ID name for the given request.
void smoothPlan()
SmoothPath action server callback. Handles action server updates and spins server until goal is reach...