15 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__VALIDATE_PATH_ACTION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__VALIDATE_PATH_ACTION_HPP_
22 #include "nav2_ros_common/lifecycle_node.hpp"
23 #include "behaviortree_cpp/action_node.h"
24 #include "behaviortree_cpp/json_export.h"
25 #include "geometry_msgs/msg/pose_stamped.hpp"
26 #include "nav2_msgs/srv/is_path_valid.hpp"
27 #include "nav2_ros_common/service_client.hpp"
28 #include "nav2_behavior_tree/bt_utils.hpp"
29 #include "nav2_behavior_tree/json_utils.hpp"
30 #include "nav2_behavior_tree/bt_service_node.hpp"
32 namespace nav2_behavior_tree
79 const std::string & service_node_name,
80 const BT::NodeConfiguration & conf);
93 BT::NodeStatus
on_completion(std::shared_ptr<nav2_msgs::srv::IsPathValid::Response> response)
103 BT::RegisterJsonDefinition<nav_msgs::msg::Path>();
104 BT::RegisterJsonDefinition<std::chrono::milliseconds>();
105 BT::RegisterJsonDefinition<std::vector<geometry_msgs::msg::PoseStamped>>();
109 BT::InputPort<nav_msgs::msg::Path>(
"path",
"Path to Check"),
110 BT::InputPort<unsigned int>(
"max_cost", 254,
"Maximum cost of the path"),
112 "consider_unknown_as_obstacle",
false,
113 "Whether to consider unknown cost as obstacle"),
114 BT::InputPort<std::string>(
116 "Name of the costmap layer to check against (empty = full costmap)"),
117 BT::InputPort<std::string>(
119 "Custom footprint specification as bracketed array of arrays, e.g., "
120 "[[x1,y1],[x2,y2],...] (empty = use robot footprint)"),
122 "stop_at_first_collision",
true,
123 "Whether to stop validation at first collision (true) or check all poses (false)"),
124 BT::InputPort<double>(
125 "max_lookahead_distance", -1.0,
126 "Maximum distance ahead of the robot to validate (-1 = full path)"),
127 BT::OutputPort<std::vector<geometry_msgs::msg::PoseStamped>>(
129 "Poses in the path that are in collision")
134 unsigned int max_cost_;
135 bool consider_unknown_as_obstacle_;
136 std::string layer_name_;
137 std::string footprint_;
138 bool stop_at_first_collision_;
139 double max_lookahead_distance_;
140 nav_msgs::msg::Path path_;
Abstract class representing a service based BT node.
static BT::PortsList providedBasicPorts(BT::PortsList addition)
Any subclass of BtServiceNode that accepts parameters must provide a providedPorts method and call pr...
A nav2_behavior_tree::BtServiceNode class that validates a path by calling the IsPathValid service on...
static BT::PortsList providedPorts()
Creates list of BT ports.
BT::NodeStatus on_completion(std::shared_ptr< nav2_msgs::srv::IsPathValid::Response > response) override
Function to perform some user-defined operation after receiving a result from the service.
void on_tick() override
The main override required by a BT service.
ValidatePath(const std::string &service_node_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::ValidatePath.