Nav2 Navigation Stack - jazzy  jazzy
ROS 2 Navigation Stack
goal_updater_node.hpp
1 // Copyright (c) 2018 Intel Corporation
2 // Copyright (c) 2020 Francisco Martin Rico
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__DECORATOR__GOAL_UPDATER_NODE_HPP_
17 #define NAV2_BEHAVIOR_TREE__PLUGINS__DECORATOR__GOAL_UPDATER_NODE_HPP_
18 
19 #include <memory>
20 #include <string>
21 
22 #include "geometry_msgs/msg/pose_stamped.hpp"
23 
24 #include "behaviortree_cpp/decorator_node.h"
25 
26 #include "rclcpp/rclcpp.hpp"
27 
28 namespace nav2_behavior_tree
29 {
30 
35 class GoalUpdater : public BT::DecoratorNode
36 {
37 public:
44  const std::string & xml_tag_name,
45  const BT::NodeConfiguration & conf);
46 
51  static BT::PortsList providedPorts()
52  {
53  return {
54  BT::InputPort<geometry_msgs::msg::PoseStamped>("input_goal", "Original Goal"),
55  BT::OutputPort<geometry_msgs::msg::PoseStamped>(
56  "output_goal",
57  "Received Goal by subscription"),
58  };
59  }
60 
61 private:
66  BT::NodeStatus tick() override;
67 
72  void callback_updated_goal(const geometry_msgs::msg::PoseStamped::SharedPtr msg);
73 
74  rclcpp::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr goal_sub_;
75 
76  geometry_msgs::msg::PoseStamped last_goal_received_;
77 
78  rclcpp::Node::SharedPtr node_;
79  rclcpp::CallbackGroup::SharedPtr callback_group_;
80  rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
81 };
82 
83 } // namespace nav2_behavior_tree
84 
85 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__DECORATOR__GOAL_UPDATER_NODE_HPP_
A BT::DecoratorNode that subscribes to a goal topic and updates the current goal on the blackboard.
GoalUpdater(const std::string &xml_tag_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::GoalUpdater.
static BT::PortsList providedPorts()
Creates list of BT ports.