19 #include "nav2_behavior_tree/plugins/action/check_pose_occupancy_action.hpp"
21 namespace nav2_behavior_tree
25 const std::string & service_node_name,
26 const BT::NodeConfiguration & conf)
27 :
BtServiceNode<nav2_msgs::srv::GetCosts>(service_node_name, conf,
28 "/global_costmap/get_cost_global_costmap")
35 getInput<double>(
"cost_threshold", cost_threshold_);
36 getInput<bool>(
"use_footprint", use_footprint_);
37 getInput<bool>(
"consider_unknown_as_obstacle", consider_unknown_as_obstacle_);
38 geometry_msgs::msg::PoseStamped pose;
39 getInput(
"pose", pose);
41 request_ = std::make_shared<nav2_msgs::srv::GetCosts::Request>();
42 request_->use_footprint = use_footprint_;
43 request_->poses.push_back(pose);
47 std::shared_ptr<nav2_msgs::srv::GetCosts::Response> response)
49 if (!response->success) {
52 "GetCosts service call failed");
53 return BT::NodeStatus::FAILURE;
56 if ((response->costs[0] == 255 && !consider_unknown_as_obstacle_) ||
57 response->costs[0] < cost_threshold_)
59 return BT::NodeStatus::FAILURE;
61 return BT::NodeStatus::SUCCESS;
67 #include "behaviortree_cpp/bt_factory.h"
68 BT_REGISTER_NODES(factory)
Abstract class representing a service based BT node.
A nav2_behavior_tree::BtServiceNode class that checks if a pose is occupied by calling the GetCosts s...
BT::NodeStatus on_completion(std::shared_ptr< nav2_msgs::srv::GetCosts::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.
CheckPoseOccupancy(const std::string &service_node_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::CheckPoseOccupancy.