Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
progress_checker_selector_node.hpp
1 // Copyright (c) 2024 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__ACTION__PROGRESS_CHECKER_SELECTOR_NODE_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__PROGRESS_CHECKER_SELECTOR_NODE_HPP_
17 
18 #include <memory>
19 #include <string>
20 
21 #include "std_msgs/msg/string.hpp"
22 
23 #include "behaviortree_cpp/action_node.h"
24 
25 #include "rclcpp/rclcpp.hpp"
26 
27 namespace nav2_behavior_tree
28 {
29 
38 class ProgressCheckerSelector : public BT::SyncActionNode
39 {
40 public:
48  const std::string & xml_tag_name,
49  const BT::NodeConfiguration & conf);
50 
55  static BT::PortsList providedPorts()
56  {
57  return {
58  BT::InputPort<std::string>(
59  "default_progress_checker",
60  "the default progress_checker to use if there is not any external topic message received."),
61 
62  BT::InputPort<std::string>(
63  "topic_name",
64  "progress_checker_selector",
65  "the input topic name to select the progress_checker"),
66 
67  BT::OutputPort<std::string>(
68  "selected_progress_checker",
69  "Selected progress_checker by subscription")
70  };
71  }
72 
73 private:
77  void initialize();
81  void createROSInterfaces();
82 
86  BT::NodeStatus tick() override;
87 
93  void callbackProgressCheckerSelect(const std_msgs::msg::String::SharedPtr msg);
94 
95  rclcpp::Subscription<std_msgs::msg::String>::SharedPtr progress_checker_selector_sub_;
96 
97  std::string last_selected_progress_checker_;
98 
99  rclcpp::Node::SharedPtr node_;
100 
101  std::string topic_name_;
102 };
103 
104 } // namespace nav2_behavior_tree
105 
106 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__PROGRESS_CHECKER_SELECTOR_NODE_HPP_
The ProgressCheckerSelector behavior is used to switch the progress checker of the controller server....
static BT::PortsList providedPorts()
Creates list of BT ports.
ProgressCheckerSelector(const std::string &xml_tag_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::ProgressCheckerSelector.