Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
transform_available_condition.hpp
1 // Copyright (c) 2020 Samsung Research America
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__TRANSFORM_AVAILABLE_CONDITION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__TRANSFORM_AVAILABLE_CONDITION_HPP_
17 
18 #include <string>
19 #include <atomic>
20 #include <memory>
21 
22 #include "rclcpp/rclcpp.hpp"
23 #include "behaviortree_cpp/condition_node.h"
24 #include "tf2_ros/buffer.h"
25 
26 namespace nav2_behavior_tree
27 {
28 
35 class TransformAvailableCondition : public BT::ConditionNode
36 {
37 public:
44  const std::string & condition_name,
45  const BT::NodeConfiguration & conf);
46 
47  TransformAvailableCondition() = delete;
48 
53 
58  BT::NodeStatus tick() override;
59 
63  void initialize();
64 
69  static BT::PortsList providedPorts()
70  {
71  return {
72  BT::InputPort<std::string>("child", std::string(), "Child frame for transform"),
73  BT::InputPort<std::string>("parent", std::string(), "parent frame for transform")
74  };
75  }
76 
77 private:
78  rclcpp::Node::SharedPtr node_;
79  std::shared_ptr<tf2_ros::Buffer> tf_;
80 
81  std::atomic<bool> was_found_;
82 
83  std::string child_frame_;
84  std::string parent_frame_;
85 };
86 
87 } // namespace nav2_behavior_tree
88 
89 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__TRANSFORM_AVAILABLE_CONDITION_HPP_
A BT::ConditionNode that returns SUCCESS if there is a valid transform between two specified frames a...
~TransformAvailableCondition()
A destructor for nav2_behavior_tree::TransformAvailableCondition.
void initialize()
Function to read parameters and initialize class variables.
static BT::PortsList providedPorts()
Creates list of BT ports.
BT::NodeStatus tick() override
The main override required by a BT action.