Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
wait_action.cpp
1 // Copyright (c) 2018 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 #include <string>
16 #include <memory>
17 
18 #include "nav2_behavior_tree/plugins/action/wait_action.hpp"
19 
20 namespace nav2_behavior_tree
21 {
22 
24  const std::string & xml_tag_name,
25  const std::string & action_name,
26  const BT::NodeConfiguration & conf)
27 : BtActionNode<nav2_msgs::action::Wait>(xml_tag_name, action_name, conf)
28 {
29  int duration;
30  getInput("wait_duration", duration);
31  if (duration <= 0) {
32  RCLCPP_WARN(
33  node_->get_logger(), "Wait duration is negative or zero "
34  "(%i). Setting to positive.", duration);
35  duration *= -1;
36  }
37 
38  goal_.time.sec = duration;
39 }
40 
42 {
44 }
45 
46 } // namespace nav2_behavior_tree
47 
48 #include "behaviortree_cpp_v3/bt_factory.h"
49 BT_REGISTER_NODES(factory)
50 {
51  BT::NodeBuilder builder =
52  [](const std::string & name, const BT::NodeConfiguration & config)
53  {
54  return std::make_unique<nav2_behavior_tree::WaitAction>(name, "wait", config);
55  };
56 
57  factory.registerBuilder<nav2_behavior_tree::WaitAction>("Wait", builder);
58 }
Abstract class representing an action based BT node.
void increment_recovery_count()
Function to increment recovery count on blackboard if this node wraps a recovery.
A nav2_behavior_tree::BtActionNode class that wraps nav2_msgs::action::Wait.
Definition: wait_action.hpp:30
WaitAction(const std::string &xml_tag_name, const std::string &action_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::WaitAction.
Definition: wait_action.cpp:23
void on_tick() override
Function to perform some user-defined operation on tick.
Definition: wait_action.cpp:41