16 #ifndef NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__REGULATED_PURE_PURSUIT_CONTROLLER_HPP_
17 #define NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__REGULATED_PURE_PURSUIT_CONTROLLER_HPP_
25 #include "nav2_core/controller.hpp"
26 #include "nav2_ros_common/lifecycle_node.hpp"
27 #include "pluginlib/class_loader.hpp"
28 #include "pluginlib/class_list_macros.hpp"
29 #include "geometry_msgs/msg/pose.hpp"
30 #include "std_msgs/msg/bool.hpp"
31 #include "nav2_regulated_pure_pursuit_controller/collision_checker.hpp"
32 #include "nav2_regulated_pure_pursuit_controller/parameter_handler.hpp"
33 #include "nav2_regulated_pure_pursuit_controller/regulation_functions.hpp"
34 #include "nav2_regulated_pure_pursuit_controller/dynamic_window_pure_pursuit_functions.hpp"
35 #include "nav2_ros_common/tf2_factories.hpp"
37 namespace nav2_regulated_pure_pursuit_controller
65 const nav2::LifecycleNode::WeakPtr & parent,
66 std::string name, nav2::TransformBuffer::SharedPtr tf,
67 std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros)
override;
94 const geometry_msgs::msg::PoseStamped & pose,
95 const geometry_msgs::msg::Twist & velocity,
97 const nav_msgs::msg::Path & transformed_global_plan,
98 const geometry_msgs::msg::PoseStamped & global_goal)
override;
106 void newPathReceived(
const nav_msgs::msg::Path & raw_global_path)
override;
115 void setSpeedLimit(
const double & speed_limit,
const bool & percentage)
override;
117 void reset()
override;
133 const geometry_msgs::msg::PoseStamped & carrot_pose);
143 const geometry_msgs::msg::PoseStamped & carrot_pose,
double & angle_to_path,
144 double & x_vel_sign);
157 const geometry_msgs::msg::PoseStamped & robot_pose,
158 const geometry_msgs::msg::PoseStamped & goal_pose,
159 const geometry_msgs::msg::Twist & speed,
160 const nav_msgs::msg::Path & transformed_plan);
170 double & linear_vel,
double & angular_vel,
171 const double & angle_to_path,
const geometry_msgs::msg::Twist & curr_speed);
182 const double & curvature,
const geometry_msgs::msg::Twist & speed,
183 const double & pose_cost,
const nav_msgs::msg::Path & path,
184 double & linear_vel,
double & sign);
186 nav2::LifecycleNode::WeakPtr node_;
187 nav2::TransformBuffer::SharedPtr tf_;
188 std::string plugin_name_;
189 std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros_;
191 rclcpp::Logger logger_ {rclcpp::get_logger(
"RegulatedPurePursuitController")};
194 double control_duration_;
195 bool cancelling_ =
false;
196 bool finished_cancelling_ =
false;
197 bool is_rotating_to_heading_ =
false;
198 geometry_msgs::msg::Twist last_command_velocity_;
200 nav2::Publisher<geometry_msgs::msg::PointStamped>::SharedPtr carrot_pub_;
201 nav2::Publisher<geometry_msgs::msg::PointStamped>::SharedPtr curvature_carrot_pub_;
202 nav2::Publisher<std_msgs::msg::Bool>::SharedPtr is_rotating_to_heading_pub_;
203 nav2::Publisher<nav_msgs::msg::Path>::SharedPtr carrot_arc_pub_;
204 std::unique_ptr<nav2_regulated_pure_pursuit_controller::ParameterHandler> param_handler_;
205 std::unique_ptr<nav2_regulated_pure_pursuit_controller::CollisionChecker> collision_checker_;
controller interface that acts as a virtual base class for all controller plugins
Function-object for checking whether a goal has been reached.
A 2D costmap provides a mapping between points in the world and their associated "costs".
Regulated pure pursuit controller plugin.
void activate() override
Activate controller state machine.
bool shouldRotateToPath(const geometry_msgs::msg::PoseStamped &carrot_pose, double &angle_to_path, double &x_vel_sign)
Whether robot should rotate to rough path heading.
void deactivate() override
Deactivate controller state machine.
void cleanup() override
Cleanup controller state machine.
double getLookAheadDistance(const geometry_msgs::msg::Twist &)
Get lookahead distance.
void newPathReceived(const nav_msgs::msg::Path &raw_global_path) override
nav2_core newPathReceived - Receives a new plan from the Planner Server
void rotateToHeading(double &linear_vel, double &angular_vel, const double &angle_to_path, const geometry_msgs::msg::Twist &curr_speed)
Create a smooth and kinematically smoothed rotation command.
bool shouldRotateToGoalHeading(nav2_core::GoalChecker *goal_checker, const geometry_msgs::msg::PoseStamped &robot_pose, const geometry_msgs::msg::PoseStamped &goal_pose, const geometry_msgs::msg::Twist &speed, const nav_msgs::msg::Path &transformed_plan)
Whether robot should rotate to final goal orientation.
~RegulatedPurePursuitController() override=default
Destrructor for nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController.
geometry_msgs::msg::TwistStamped computeVelocityCommands(const geometry_msgs::msg::PoseStamped &pose, const geometry_msgs::msg::Twist &velocity, nav2_core::GoalChecker *, const nav_msgs::msg::Path &transformed_global_plan, const geometry_msgs::msg::PoseStamped &global_goal) override
Compute the best command given the current pose and velocity, with possible debug information.
RegulatedPurePursuitController()=default
Constructor for nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController.
void setSpeedLimit(const double &speed_limit, const bool &percentage) override
Limits the maximum linear speed of the robot.
void applyConstraints(const double &curvature, const geometry_msgs::msg::Twist &speed, const double &pose_cost, const nav_msgs::msg::Path &path, double &linear_vel, double &sign)
apply regulation constraints to the system
std::unique_ptr< geometry_msgs::msg::PointStamped > createCarrotMsg(const geometry_msgs::msg::PoseStamped &carrot_pose)
Creates a PointStamped message for visualization.
bool cancel() override
Cancel the current control action.
void configure(const nav2::LifecycleNode::WeakPtr &parent, std::string name, nav2::TransformBuffer::SharedPtr tf, std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmap_ros) override
Configure controller state machine.
void reset() override
Reset the state of the controller if necessary after task is exited.