Nav2 Navigation Stack - lyrical  lyrical
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 "nav2_ros_common/lifecycle_node.hpp"
22 #include "behaviortree_cpp/condition_node.h"
23 #include "nav2_ros_common/tf2_factories.hpp"
24 #include "nav2_behavior_tree/bt_utils.hpp"
25 
26 namespace nav2_behavior_tree
27 {
28 
38 class ArePosesNearCondition : public BT::ConditionNode
39 {
40 public:
47  const std::string & condition_name,
48  const BT::NodeConfiguration & conf);
49 
53  ~ArePosesNearCondition() override = default;
54 
59  BT::NodeStatus tick() override;
60 
64  void initialize();
65 
70  bool arePosesNearby();
71 
76  static BT::PortsList providedPorts()
77  {
78  return {
79  BT::InputPort<geometry_msgs::msg::PoseStamped>("ref_pose", "Destination"),
80  BT::InputPort<geometry_msgs::msg::PoseStamped>("target_pose", "Destination"),
81  BT::InputPort<std::string>("global_frame", "Global frame"),
82  BT::InputPort<double>("tolerance", 0.5, "Tolerance")
83  };
84  }
85 
86 private:
87  nav2::LifecycleNode::SharedPtr node_;
88  nav2::TransformBuffer::SharedPtr tf_;
89  double transform_tolerance_;
90  std::string global_frame_;
91 };
92 
93 } // namespace nav2_behavior_tree
94 
95 #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.
ArePosesNearCondition(const std::string &condition_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::ArePosesNearCondition.
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.