Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
planner_server.cpp
1 // Copyright (c) 2018 Intel Corporation
2 // Copyright (c) 2019 Samsung Research America
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #include <chrono>
17 #include <cmath>
18 #include <iomanip>
19 #include <iostream>
20 #include <limits>
21 #include <iterator>
22 #include <memory>
23 #include <string>
24 #include <vector>
25 #include <utility>
26 
27 #include "builtin_interfaces/msg/duration.hpp"
28 #include "lifecycle_msgs/msg/state.hpp"
29 #include "nav2_util/costmap.hpp"
30 #include "nav2_util/node_utils.hpp"
31 #include "nav2_util/geometry_utils.hpp"
32 #include "nav2_costmap_2d/cost_values.hpp"
33 #include "nav2_costmap_2d/footprint_collision_checker.hpp"
34 
35 #include "nav2_planner/planner_server.hpp"
36 
37 using namespace std::chrono_literals;
38 using rcl_interfaces::msg::ParameterType;
39 using std::placeholders::_1;
40 
41 namespace nav2_planner
42 {
43 
44 PlannerServer::PlannerServer(const rclcpp::NodeOptions & options)
45 : nav2_util::LifecycleNode("planner_server", "", options),
46  gp_loader_("nav2_core", "nav2_core::GlobalPlanner"),
47  default_ids_{"GridBased"},
48  default_types_{"nav2_navfn_planner/NavfnPlanner"},
49  costmap_(nullptr)
50 {
51  RCLCPP_INFO(get_logger(), "Creating");
52 
53  // Declare this node's parameters
54  declare_parameter("planner_plugins", default_ids_);
55  declare_parameter("expected_planner_frequency", 1.0);
56 
57  get_parameter("planner_plugins", planner_ids_);
58  if (planner_ids_ == default_ids_) {
59  for (size_t i = 0; i < default_ids_.size(); ++i) {
60  declare_parameter(default_ids_[i] + ".plugin", default_types_[i]);
61  }
62  }
63 
64  // Setup the global costmap
65  costmap_ros_ = std::make_shared<nav2_costmap_2d::Costmap2DROS>(
66  "global_costmap", std::string{get_namespace()}, "global_costmap");
67 }
68 
70 {
71  /*
72  * Backstop ensuring this state is destroyed, even if deactivate/cleanup are
73  * never called.
74  */
75  planners_.clear();
76  costmap_thread_.reset();
77 }
78 
79 nav2_util::CallbackReturn
80 PlannerServer::on_configure(const rclcpp_lifecycle::State & /*state*/)
81 {
82  RCLCPP_INFO(get_logger(), "Configuring");
83 
84  costmap_ros_->configure();
85  costmap_ = costmap_ros_->getCostmap();
86 
87  if (!costmap_ros_->getUseRadius()) {
88  collision_checker_ =
89  std::make_unique<nav2_costmap_2d::FootprintCollisionChecker<nav2_costmap_2d::Costmap2D *>>(
90  costmap_);
91  }
92 
93  // Launch a thread to run the costmap node
94  costmap_thread_ = std::make_unique<nav2_util::NodeThread>(costmap_ros_);
95 
96  RCLCPP_DEBUG(
97  get_logger(), "Costmap size: %d,%d",
98  costmap_->getSizeInCellsX(), costmap_->getSizeInCellsY());
99 
100  tf_ = costmap_ros_->getTfBuffer();
101 
102  planner_types_.resize(planner_ids_.size());
103 
104  auto node = shared_from_this();
105 
106  for (size_t i = 0; i != planner_ids_.size(); i++) {
107  try {
108  planner_types_[i] = nav2_util::get_plugin_type_param(
109  node, planner_ids_[i]);
110  nav2_core::GlobalPlanner::Ptr planner =
111  gp_loader_.createUniqueInstance(planner_types_[i]);
112  RCLCPP_INFO(
113  get_logger(), "Created global planner plugin %s of type %s",
114  planner_ids_[i].c_str(), planner_types_[i].c_str());
115  planner->configure(node, planner_ids_[i], tf_, costmap_ros_);
116  planners_.insert({planner_ids_[i], planner});
117  } catch (const pluginlib::PluginlibException & ex) {
118  RCLCPP_FATAL(
119  get_logger(), "Failed to create global planner. Exception: %s",
120  ex.what());
121  return nav2_util::CallbackReturn::FAILURE;
122  }
123  }
124 
125  for (size_t i = 0; i != planner_ids_.size(); i++) {
126  planner_ids_concat_ += planner_ids_[i] + std::string(" ");
127  }
128 
129  RCLCPP_INFO(
130  get_logger(),
131  "Planner Server has %s planners available.", planner_ids_concat_.c_str());
132 
133  double expected_planner_frequency;
134  get_parameter("expected_planner_frequency", expected_planner_frequency);
135  if (expected_planner_frequency > 0) {
136  max_planner_duration_ = 1 / expected_planner_frequency;
137  } else {
138  RCLCPP_WARN(
139  get_logger(),
140  "The expected planner frequency parameter is %.4f Hz. The value should to be greater"
141  " than 0.0 to turn on duration overrrun warning messages", expected_planner_frequency);
142  max_planner_duration_ = 0.0;
143  }
144 
145  // Initialize pubs & subs
146  plan_publisher_ = create_publisher<nav_msgs::msg::Path>("plan", 1);
147 
148  // Create the action servers for path planning to a pose and through poses
149  action_server_pose_ = std::make_unique<ActionServerToPose>(
151  "compute_path_to_pose",
152  std::bind(&PlannerServer::computePlan, this),
153  nullptr,
154  std::chrono::milliseconds(500),
155  true);
156 
157  action_server_poses_ = std::make_unique<ActionServerThroughPoses>(
159  "compute_path_through_poses",
160  std::bind(&PlannerServer::computePlanThroughPoses, this),
161  nullptr,
162  std::chrono::milliseconds(500),
163  true);
164 
165  return nav2_util::CallbackReturn::SUCCESS;
166 }
167 
168 nav2_util::CallbackReturn
169 PlannerServer::on_activate(const rclcpp_lifecycle::State & /*state*/)
170 {
171  RCLCPP_INFO(get_logger(), "Activating");
172 
173  plan_publisher_->on_activate();
174  action_server_pose_->activate();
175  action_server_poses_->activate();
176  costmap_ros_->activate();
177 
178  PlannerMap::iterator it;
179  for (it = planners_.begin(); it != planners_.end(); ++it) {
180  it->second->activate();
181  }
182 
183  auto node = shared_from_this();
184 
185  is_path_valid_service_ = node->create_service<nav2_msgs::srv::IsPathValid>(
186  "is_path_valid",
187  std::bind(
189  std::placeholders::_1, std::placeholders::_2));
190 
191  // Add callback for dynamic parameters
192  dyn_params_handler_ = node->add_on_set_parameters_callback(
193  std::bind(&PlannerServer::dynamicParametersCallback, this, _1));
194 
195  // create bond connection
196  createBond();
197 
198  return nav2_util::CallbackReturn::SUCCESS;
199 }
200 
201 nav2_util::CallbackReturn
202 PlannerServer::on_deactivate(const rclcpp_lifecycle::State & /*state*/)
203 {
204  RCLCPP_INFO(get_logger(), "Deactivating");
205 
206  action_server_pose_->deactivate();
207  action_server_poses_->deactivate();
208  plan_publisher_->on_deactivate();
209 
210  /*
211  * The costmap is also a lifecycle node, so it may have already fired on_deactivate
212  * via rcl preshutdown cb. Despite the rclcpp docs saying on_shutdown callbacks fire
213  * in the order added, the preshutdown callbacks clearly don't per se, due to using an
214  * unordered_set iteration. Once this issue is resolved, we can maybe make a stronger
215  * ordering assumption: https://github.com/ros2/rclcpp/issues/2096
216  */
217  costmap_ros_->deactivate();
218 
219  PlannerMap::iterator it;
220  for (it = planners_.begin(); it != planners_.end(); ++it) {
221  it->second->deactivate();
222  }
223 
224  dyn_params_handler_.reset();
225 
226  // destroy bond connection
227  destroyBond();
228 
229  return nav2_util::CallbackReturn::SUCCESS;
230 }
231 
232 nav2_util::CallbackReturn
233 PlannerServer::on_cleanup(const rclcpp_lifecycle::State & /*state*/)
234 {
235  RCLCPP_INFO(get_logger(), "Cleaning up");
236 
237  action_server_pose_.reset();
238  action_server_poses_.reset();
239  plan_publisher_.reset();
240  tf_.reset();
241 
242  costmap_ros_->cleanup();
243 
244  PlannerMap::iterator it;
245  for (it = planners_.begin(); it != planners_.end(); ++it) {
246  it->second->cleanup();
247  }
248 
249  planners_.clear();
250  costmap_thread_.reset();
251  costmap_ = nullptr;
252  return nav2_util::CallbackReturn::SUCCESS;
253 }
254 
255 nav2_util::CallbackReturn
256 PlannerServer::on_shutdown(const rclcpp_lifecycle::State &)
257 {
258  RCLCPP_INFO(get_logger(), "Shutting down");
259  return nav2_util::CallbackReturn::SUCCESS;
260 }
261 
262 template<typename T>
264  std::unique_ptr<nav2_util::SimpleActionServer<T>> & action_server)
265 {
266  if (action_server == nullptr || !action_server->is_server_active()) {
267  RCLCPP_DEBUG(get_logger(), "Action server unavailable or inactive. Stopping.");
268  return true;
269  }
270 
271  return false;
272 }
273 
275 {
276  // Don't compute a plan until costmap is valid (after clear costmap)
277  rclcpp::Rate r(100);
278  while (!costmap_ros_->isCurrent()) {
279  r.sleep();
280  }
281 }
282 
283 template<typename T>
285  std::unique_ptr<nav2_util::SimpleActionServer<T>> & action_server)
286 {
287  if (action_server->is_cancel_requested()) {
288  RCLCPP_INFO(get_logger(), "Goal was canceled. Canceling planning action.");
289  action_server->terminate_all();
290  return true;
291  }
292 
293  return false;
294 }
295 
296 template<typename T>
298  std::unique_ptr<nav2_util::SimpleActionServer<T>> & action_server,
299  typename std::shared_ptr<const typename T::Goal> goal)
300 {
301  if (action_server->is_preempt_requested()) {
302  goal = action_server->accept_pending_goal();
303  }
304 }
305 
306 template<typename T>
308  std::unique_ptr<nav2_util::SimpleActionServer<T>> & action_server,
309  typename std::shared_ptr<const typename T::Goal> goal,
310  geometry_msgs::msg::PoseStamped & start)
311 {
312  if (goal->use_start) {
313  start = goal->start;
314  } else if (!costmap_ros_->getRobotPose(start)) {
315  action_server->terminate_current();
316  return false;
317  }
318 
319  return true;
320 }
321 
322 template<typename T>
324  std::unique_ptr<nav2_util::SimpleActionServer<T>> & action_server,
325  geometry_msgs::msg::PoseStamped & curr_start,
326  geometry_msgs::msg::PoseStamped & curr_goal)
327 {
328  if (!costmap_ros_->transformPoseToGlobalFrame(curr_start, curr_start) ||
329  !costmap_ros_->transformPoseToGlobalFrame(curr_goal, curr_goal))
330  {
331  RCLCPP_WARN(
332  get_logger(), "Could not transform the start or goal pose in the costmap frame");
333  action_server->terminate_current();
334  return false;
335  }
336 
337  return true;
338 }
339 
340 template<typename T>
342  std::unique_ptr<nav2_util::SimpleActionServer<T>> & action_server,
343  const geometry_msgs::msg::PoseStamped & goal,
344  const nav_msgs::msg::Path & path,
345  const std::string & planner_id)
346 {
347  if (path.poses.size() == 0) {
348  RCLCPP_WARN(
349  get_logger(), "Planning algorithm %s failed to generate a valid"
350  " path to (%.2f, %.2f)", planner_id.c_str(),
351  goal.pose.position.x, goal.pose.position.y);
352  action_server->terminate_current();
353  return false;
354  }
355 
356  RCLCPP_DEBUG(
357  get_logger(),
358  "Found valid path of size %zu to (%.2f, %.2f)",
359  path.poses.size(), goal.pose.position.x,
360  goal.pose.position.y);
361 
362  return true;
363 }
364 
365 void
367 {
368  std::lock_guard<std::mutex> lock(dynamic_params_lock_);
369 
370  auto start_time = this->now();
371 
372  // Initialize the ComputePathToPose goal and result
373  auto goal = action_server_poses_->get_current_goal();
374  auto result = std::make_shared<ActionThroughPoses::Result>();
375  nav_msgs::msg::Path concat_path;
376 
377  try {
378  if (isServerInactive(action_server_poses_) || isCancelRequested(action_server_poses_)) {
379  return;
380  }
381 
382  waitForCostmap();
383 
384  getPreemptedGoalIfRequested(action_server_poses_, goal);
385 
386  if (goal->goals.size() == 0) {
387  RCLCPP_WARN(
388  get_logger(),
389  "Compute path through poses requested a plan with no viapoint poses, returning.");
390  action_server_poses_->terminate_current();
391  }
392 
393  // Use start pose if provided otherwise use current robot pose
394  geometry_msgs::msg::PoseStamped start;
395  if (!getStartPose(action_server_poses_, goal, start)) {
396  return;
397  }
398 
399  // Get consecutive paths through these points
400  geometry_msgs::msg::PoseStamped curr_start, curr_goal;
401  for (unsigned int i = 0; i != goal->goals.size(); i++) {
402  // Get starting point
403  if (i == 0) {
404  curr_start = start;
405  } else {
406  // pick the end of the last planning task as the start for the next one
407  // to allow for path tolerance deviations
408  curr_start = concat_path.poses.back();
409  curr_start.header = concat_path.header;
410  }
411  curr_goal = goal->goals[i];
412 
413  // Transform them into the global frame
414  if (!transformPosesToGlobalFrame(action_server_poses_, curr_start, curr_goal)) {
415  return;
416  }
417 
418  // Get plan from start -> goal
419  nav_msgs::msg::Path curr_path = getPlan(curr_start, curr_goal, goal->planner_id);
420 
421  // check path for validity
422  if (!validatePath(action_server_poses_, curr_goal, curr_path, goal->planner_id)) {
423  return;
424  }
425 
426  // Concatenate paths together
427  concat_path.poses.insert(
428  concat_path.poses.end(), curr_path.poses.begin(), curr_path.poses.end());
429  concat_path.header = curr_path.header;
430  }
431 
432  // Publish the plan for visualization purposes
433  result->path = concat_path;
434  publishPlan(result->path);
435 
436  auto cycle_duration = this->now() - start_time;
437  result->planning_time = cycle_duration;
438 
439  if (max_planner_duration_ && cycle_duration.seconds() > max_planner_duration_) {
440  RCLCPP_WARN(
441  get_logger(),
442  "Planner loop missed its desired rate of %.4f Hz. Current loop rate is %.4f Hz",
443  1 / max_planner_duration_, 1 / cycle_duration.seconds());
444  }
445 
446  action_server_poses_->succeeded_current(result);
447  } catch (std::exception & ex) {
448  RCLCPP_WARN(
449  get_logger(),
450  "%s plugin failed to plan through %zu points with final goal (%.2f, %.2f): \"%s\"",
451  goal->planner_id.c_str(), goal->goals.size(), goal->goals.back().pose.position.x,
452  goal->goals.back().pose.position.y, ex.what());
453  action_server_poses_->terminate_current();
454  }
455 }
456 
457 void
459 {
460  std::lock_guard<std::mutex> lock(dynamic_params_lock_);
461 
462  auto start_time = this->now();
463 
464  // Initialize the ComputePathToPose goal and result
465  auto goal = action_server_pose_->get_current_goal();
466  auto result = std::make_shared<ActionToPose::Result>();
467 
468  try {
469  if (isServerInactive(action_server_pose_) || isCancelRequested(action_server_pose_)) {
470  return;
471  }
472 
473  waitForCostmap();
474 
475  getPreemptedGoalIfRequested(action_server_pose_, goal);
476 
477  // Use start pose if provided otherwise use current robot pose
478  geometry_msgs::msg::PoseStamped start;
479  if (!getStartPose(action_server_pose_, goal, start)) {
480  return;
481  }
482 
483  // Transform them into the global frame
484  geometry_msgs::msg::PoseStamped goal_pose = goal->goal;
485  if (!transformPosesToGlobalFrame(action_server_pose_, start, goal_pose)) {
486  return;
487  }
488 
489  result->path = getPlan(start, goal_pose, goal->planner_id);
490 
491  if (!validatePath(action_server_pose_, goal_pose, result->path, goal->planner_id)) {
492  return;
493  }
494 
495  // Publish the plan for visualization purposes
496  publishPlan(result->path);
497 
498  auto cycle_duration = this->now() - start_time;
499  result->planning_time = cycle_duration;
500 
501  if (max_planner_duration_ && cycle_duration.seconds() > max_planner_duration_) {
502  RCLCPP_WARN(
503  get_logger(),
504  "Planner loop missed its desired rate of %.4f Hz. Current loop rate is %.4f Hz",
505  1 / max_planner_duration_, 1 / cycle_duration.seconds());
506  }
507 
508  action_server_pose_->succeeded_current(result);
509  } catch (std::exception & ex) {
510  RCLCPP_WARN(
511  get_logger(), "%s plugin failed to plan calculation to (%.2f, %.2f): \"%s\"",
512  goal->planner_id.c_str(), goal->goal.pose.position.x,
513  goal->goal.pose.position.y, ex.what());
514  action_server_pose_->terminate_current();
515  }
516 }
517 
518 nav_msgs::msg::Path
520  const geometry_msgs::msg::PoseStamped & start,
521  const geometry_msgs::msg::PoseStamped & goal,
522  const std::string & planner_id)
523 {
524  RCLCPP_DEBUG(
525  get_logger(), "Attempting to a find path from (%.2f, %.2f) to "
526  "(%.2f, %.2f).", start.pose.position.x, start.pose.position.y,
527  goal.pose.position.x, goal.pose.position.y);
528 
529  if (planners_.find(planner_id) != planners_.end()) {
530  return planners_[planner_id]->createPlan(start, goal);
531  } else {
532  if (planners_.size() == 1 && planner_id.empty()) {
533  RCLCPP_WARN_ONCE(
534  get_logger(), "No planners specified in action call. "
535  "Server will use only plugin %s in server."
536  " This warning will appear once.", planner_ids_concat_.c_str());
537  return planners_[planners_.begin()->first]->createPlan(start, goal);
538  } else {
539  RCLCPP_ERROR(
540  get_logger(), "planner %s is not a valid planner. "
541  "Planner names are: %s", planner_id.c_str(),
542  planner_ids_concat_.c_str());
543  }
544  }
545 
546  return nav_msgs::msg::Path();
547 }
548 
549 void
550 PlannerServer::publishPlan(const nav_msgs::msg::Path & path)
551 {
552  auto msg = std::make_unique<nav_msgs::msg::Path>(path);
553  if (plan_publisher_->is_activated() && plan_publisher_->get_subscription_count() > 0) {
554  plan_publisher_->publish(std::move(msg));
555  }
556 }
557 
559  const std::shared_ptr<nav2_msgs::srv::IsPathValid::Request> request,
560  std::shared_ptr<nav2_msgs::srv::IsPathValid::Response> response)
561 {
562  response->is_valid = true;
563 
564  if (request->path.poses.empty()) {
565  response->is_valid = false;
566  return;
567  }
568 
569  geometry_msgs::msg::PoseStamped current_pose;
570  unsigned int closest_point_index = 0;
571  if (costmap_ros_->getRobotPose(current_pose)) {
572  float current_distance = std::numeric_limits<float>::max();
573  float closest_distance = current_distance;
574  geometry_msgs::msg::Point current_point = current_pose.pose.position;
575  for (unsigned int i = 0; i < request->path.poses.size(); ++i) {
576  geometry_msgs::msg::Point path_point = request->path.poses[i].pose.position;
577 
578  current_distance = nav2_util::geometry_utils::euclidean_distance(
579  current_point,
580  path_point);
581 
582  if (current_distance < closest_distance) {
583  closest_point_index = i;
584  closest_distance = current_distance;
585  }
586  }
587 
592  std::unique_lock<nav2_costmap_2d::Costmap2D::mutex_t> lock(*(costmap_->getMutex()));
593  unsigned int mx = 0;
594  unsigned int my = 0;
595 
596  bool use_radius = costmap_ros_->getUseRadius();
597 
598  unsigned int cost = nav2_costmap_2d::FREE_SPACE;
599 
600  for (unsigned int i = closest_point_index; i < request->path.poses.size(); ++i) {
601  auto & position = request->path.poses[i].pose.position;
602  if (use_radius) {
603  if (costmap_->worldToMap(position.x, position.y, mx, my)) {
604  cost = costmap_->getCost(mx, my);
605  } else {
606  cost = nav2_costmap_2d::LETHAL_OBSTACLE;
607  }
608  } else {
609  nav2_costmap_2d::Footprint footprint = costmap_ros_->getRobotFootprint();
610  auto theta = tf2::getYaw(request->path.poses[i].pose.orientation);
611  cost = static_cast<unsigned int>(collision_checker_->footprintCostAtPose(
612  position.x, position.y, theta, footprint));
613  }
614 
615  if (use_radius &&
616  (cost == nav2_costmap_2d::LETHAL_OBSTACLE ||
617  cost == nav2_costmap_2d::INSCRIBED_INFLATED_OBSTACLE))
618  {
619  response->is_valid = false;
620  break;
621  } else if (cost == nav2_costmap_2d::LETHAL_OBSTACLE) {
622  response->is_valid = false;
623  break;
624  }
625  }
626  }
627 }
628 
629 rcl_interfaces::msg::SetParametersResult
630 PlannerServer::dynamicParametersCallback(std::vector<rclcpp::Parameter> parameters)
631 {
632  std::lock_guard<std::mutex> lock(dynamic_params_lock_);
633  rcl_interfaces::msg::SetParametersResult result;
634 
635  for (auto parameter : parameters) {
636  const auto & type = parameter.get_type();
637  const auto & name = parameter.get_name();
638 
639  if (type == ParameterType::PARAMETER_DOUBLE) {
640  if (name == "expected_planner_frequency") {
641  if (parameter.as_double() > 0) {
642  max_planner_duration_ = 1 / parameter.as_double();
643  } else {
644  RCLCPP_WARN(
645  get_logger(),
646  "The expected planner frequency parameter is %.4f Hz. The value should to be greater"
647  " than 0.0 to turn on duration overrrun warning messages", parameter.as_double());
648  max_planner_duration_ = 0.0;
649  }
650  }
651  }
652  }
653 
654  result.successful = true;
655  return result;
656 }
657 
658 } // namespace nav2_planner
659 
660 #include "rclcpp_components/register_node_macro.hpp"
661 
662 // Register the component with class_loader.
663 // This acts as a sort of entry point, allowing the component to be discoverable when its library
664 // is being loaded into a running process.
665 RCLCPP_COMPONENTS_REGISTER_NODE(nav2_planner::PlannerServer)
unsigned char getCost(unsigned int mx, unsigned int my) const
Get the cost of a cell in the costmap.
Definition: costmap_2d.cpp:266
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
Convert from world coordinates to map coordinates.
Definition: costmap_2d.cpp:287
unsigned int getSizeInCellsX() const
Accessor for the x size of the costmap in cells.
Definition: costmap_2d.cpp:501
unsigned int getSizeInCellsY() const
Accessor for the y size of the costmap in cells.
Definition: costmap_2d.cpp:506
An action server implements the behavior tree's ComputePathToPose interface and hosts various plugins...
void publishPlan(const nav_msgs::msg::Path &path)
Publish a path for visualization purposes.
void computePlan()
The action server callback which calls planner to get the path ComputePathToPose.
void getPreemptedGoalIfRequested(std::unique_ptr< nav2_util::SimpleActionServer< T >> &action_server, typename std::shared_ptr< const typename T::Goal > goal)
Check if an action server has a preemption request and replaces the goal with the new preemption goal...
nav2_util::CallbackReturn on_cleanup(const rclcpp_lifecycle::State &state) override
Reset member variables.
void waitForCostmap()
Wait for costmap to be valid with updated sensor data or repopulate after a clearing recovery....
~PlannerServer()
A destructor for nav2_planner::PlannerServer.
bool isServerInactive(std::unique_ptr< nav2_util::SimpleActionServer< T >> &action_server)
Check if an action server is valid / active.
void isPathValid(const std::shared_ptr< nav2_msgs::srv::IsPathValid::Request > request, std::shared_ptr< nav2_msgs::srv::IsPathValid::Response > response)
The service callback to determine if the path is still valid.
void computePlanThroughPoses()
The action server callback which calls planner to get the path ComputePathThroughPoses.
bool transformPosesToGlobalFrame(std::unique_ptr< nav2_util::SimpleActionServer< T >> &action_server, geometry_msgs::msg::PoseStamped &curr_start, geometry_msgs::msg::PoseStamped &curr_goal)
Transform start and goal poses into the costmap global frame for path planning plugins to utilize.
bool getStartPose(std::unique_ptr< nav2_util::SimpleActionServer< T >> &action_server, typename std::shared_ptr< const typename T::Goal > goal, geometry_msgs::msg::PoseStamped &start)
Get the starting pose from costmap or message, if valid.
rcl_interfaces::msg::SetParametersResult dynamicParametersCallback(std::vector< rclcpp::Parameter > parameters)
Callback executed when a parameter change is detected.
bool isCancelRequested(std::unique_ptr< nav2_util::SimpleActionServer< T >> &action_server)
Check if an action server has a cancellation request pending.
nav_msgs::msg::Path getPlan(const geometry_msgs::msg::PoseStamped &start, const geometry_msgs::msg::PoseStamped &goal, const std::string &planner_id)
Method to get plan from the desired plugin.
nav2_util::CallbackReturn on_configure(const rclcpp_lifecycle::State &state) override
Configure member variables and initializes planner.
bool validatePath(std::unique_ptr< nav2_util::SimpleActionServer< T >> &action_server, const geometry_msgs::msg::PoseStamped &curr_goal, const nav_msgs::msg::Path &path, const std::string &planner_id)
Validate that the path contains a meaningful path.
nav2_util::CallbackReturn on_shutdown(const rclcpp_lifecycle::State &state) override
Called when in shutdown state.
nav2_util::CallbackReturn on_activate(const rclcpp_lifecycle::State &state) override
Activate member variables.
nav2_util::CallbackReturn on_deactivate(const rclcpp_lifecycle::State &state) override
Deactivate member variables.
std::shared_ptr< nav2_util::LifecycleNode > shared_from_this()
Get a shared pointer of this.
void createBond()
Create bond connection to lifecycle manager.
void destroyBond()
Destroy bond connection to lifecycle manager.
An action server wrapper to make applications simpler using Actions.