Nav2 Navigation Stack - jazzy  jazzy
ROS 2 Navigation Stack
are_poses_near_condition.hpp
1 // Copyright (c) 2025 Open Navigation LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__ARE_POSES_NEAR_CONDITION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__ARE_POSES_NEAR_CONDITION_HPP_
17 
18 #include <string>
19 #include <memory>
20 
21 #include "rclcpp/rclcpp.hpp"
22 #include "geometry_msgs/msg/pose_stamped.hpp"
23 #include "tf2_ros/buffer.h"
24 #include "behaviortree_cpp/condition_node.h"
25 #include "nav2_util/robot_utils.hpp"
26 #include "nav2_util/node_utils.hpp"
27 #include "nav2_behavior_tree/bt_utils.hpp"
28 
29 namespace nav2_behavior_tree
30 {
31 
41 class ArePosesNearCondition : public BT::ConditionNode
42 {
43 public:
50  const std::string & condition_name,
51  const BT::NodeConfiguration & conf);
52 
53  ArePosesNearCondition() = delete;
54 
58  ~ArePosesNearCondition() override = default;
59 
64  BT::NodeStatus tick() override;
65 
69  void initialize();
70 
75  bool arePosesNearby();
76 
81  static BT::PortsList providedPorts()
82  {
83  return {
84  BT::InputPort<geometry_msgs::msg::PoseStamped>("ref_pose", "Destination"),
85  BT::InputPort<geometry_msgs::msg::PoseStamped>("target_pose", "Destination"),
86  BT::InputPort<std::string>("global_frame", "Global frame"),
87  BT::InputPort<double>("tolerance", 0.5, "Tolerance")
88  };
89  }
90 
91 protected:
92  rclcpp::Node::SharedPtr node_;
93  std::shared_ptr<tf2_ros::Buffer> tf_;
94  double transform_tolerance_;
95  std::string global_frame_;
96 };
97 
98 } // namespace nav2_behavior_tree
99 
100 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__ARE_POSES_NEAR_CONDITION_HPP_
A BT::ConditionNode that returns SUCCESS when a specified goal is reached and FAILURE otherwise.
BT::NodeStatus tick() override
The main override required by a BT action.
bool arePosesNearby()
Checks if the current robot pose lies within a given distance from the goal.
static BT::PortsList providedPorts()
Creates list of BT ports.
void initialize()
Function to read parameters and initialize class variables.
~ArePosesNearCondition() override=default
A destructor for nav2_behavior_tree::ArePosesNearCondition.