15 #include "nav2_waypoint_follower/plugins/wait_at_waypoint.hpp"
20 #include "pluginlib/class_list_macros.hpp"
22 #include "nav2_util/node_utils.hpp"
24 namespace nav2_waypoint_follower
27 : waypoint_pause_duration_(0),
37 const rclcpp_lifecycle::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();
46 nav2_util::declare_parameter_if_not_declared(
48 plugin_name +
".waypoint_pause_duration",
49 rclcpp::ParameterValue(0));
50 nav2_util::declare_parameter_if_not_declared(
52 plugin_name +
".enabled",
53 rclcpp::ParameterValue(
true));
55 plugin_name +
".waypoint_pause_duration",
56 waypoint_pause_duration_);
58 plugin_name +
".enabled",
60 if (waypoint_pause_duration_ == 0) {
64 "Waypoint pause duration is set to zero, disabling task executor plugin.");
65 }
else if (!is_enabled_) {
67 logger_,
"Waypoint task executor plugin is disabled.");
72 const geometry_msgs::msg::PoseStamped & ,
const int & curr_waypoint_index)
78 logger_,
"Arrived at %i'th waypoint, sleeping for %i milliseconds",
80 waypoint_pause_duration_);
81 clock_->sleep_for(std::chrono::milliseconds(waypoint_pause_duration_));
85 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 rclcpp_lifecycle::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...