15 #include "nav2_waypoint_follower/plugins/wait_at_waypoint.hpp"
20 #include "pluginlib/class_list_macros.hpp"
22 #include "nav2_ros_common/node_utils.hpp"
24 namespace nav2_waypoint_follower
27 : waypoint_pause_duration_(0),
37 const nav2::LifecycleNode::WeakPtr & parent,
38 const std::string & plugin_name)
40 auto node = parent.lock();
42 throw std::runtime_error{
"Failed to lock node in wait at waypoint plugin!"};
44 logger_ = node->get_logger();
45 clock_ = node->get_clock();
47 waypoint_pause_duration_ = node->declare_or_get_parameter(
48 plugin_name +
".waypoint_pause_duration", 0);
49 is_enabled_ = node->declare_or_get_parameter(
50 plugin_name +
".enabled",
true);
52 if (waypoint_pause_duration_ == 0) {
56 "Waypoint pause duration is set to zero, disabling task executor plugin.");
57 }
else if (!is_enabled_) {
59 logger_,
"Waypoint task executor plugin is disabled.");
64 const geometry_msgs::msg::PoseStamped & ,
const int & curr_waypoint_index)
70 logger_,
"Arrived at %i'th waypoint, sleeping for %i milliseconds",
72 waypoint_pause_duration_);
73 clock_->sleep_for(std::chrono::milliseconds(waypoint_pause_duration_));
77 PLUGINLIB_EXPORT_CLASS(
Base class for creating a plugin in order to perform a specific task at waypoint arrivals.
Simple plugin based on WaypointTaskExecutor, let's robot to sleep for a specified amount of time at w...
WaitAtWaypoint()
Construct a new Wait At Waypoint Arrival object.
void initialize(const nav2::LifecycleNode::WeakPtr &parent, const std::string &plugin_name)
declares and loads parameters used (waypoint_pause_duration_)
~WaitAtWaypoint()
Destroy the Wait At Waypoint Arrival object.
bool processAtWaypoint(const geometry_msgs::msg::PoseStamped &curr_pose, const int &curr_waypoint_index)
Override this to define the body of your task that you would like to execute once the robot arrived t...