Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
time_expired_condition.hpp
1 // Copyright (c) 2020 Sarthak Mittal
2 // Copyright (c) 2019 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__TIME_EXPIRED_CONDITION_HPP_
17 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__TIME_EXPIRED_CONDITION_HPP_
18 
19 #include <string>
20 
21 #include "nav2_ros_common/lifecycle_node.hpp"
22 #include "behaviortree_cpp/condition_node.h"
23 
24 namespace nav2_behavior_tree
25 {
26 
33 class TimeExpiredCondition : public BT::ConditionNode
34 {
35 public:
42  const std::string & condition_name,
43  const BT::NodeConfiguration & conf);
44 
45  TimeExpiredCondition() = delete;
46 
51  BT::NodeStatus tick() override;
52 
56  void initialize();
57 
62  static BT::PortsList providedPorts()
63  {
64  return {
65  BT::InputPort<double>("seconds", 1.0, "Seconds")
66  };
67  }
68 
69 private:
70  nav2::LifecycleNode::SharedPtr node_;
71  rclcpp::Time start_;
72  double period_;
73 };
74 
75 } // namespace nav2_behavior_tree
76 
77 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__TIME_EXPIRED_CONDITION_HPP_
A BT::ConditionNode that returns SUCCESS every time a specified time period passes and FAILURE otherw...
BT::NodeStatus tick() override
The main override required by a BT action.
void initialize()
Function to read parameters and initialize class variables.
static BT::PortsList providedPorts()
Creates list of BT ports.