Nav2 Navigation Stack - jazzy  jazzy
ROS 2 Navigation Stack
goal_updated_controller.hpp
1 // Copyright (c) 2018 Intel Corporation
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__DECORATOR__GOAL_UPDATED_CONTROLLER_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__DECORATOR__GOAL_UPDATED_CONTROLLER_HPP_
17 
18 #include <chrono>
19 #include <string>
20 #include <vector>
21 
22 #include "behaviortree_cpp/decorator_node.h"
23 #include "behaviortree_cpp/json_export.h"
24 
25 #include "rclcpp/rclcpp.hpp"
26 #include "geometry_msgs/msg/pose_stamped.hpp"
27 #include "nav2_behavior_tree/bt_utils.hpp"
28 #include "nav2_behavior_tree/json_utils.hpp"
29 
30 namespace nav2_behavior_tree
31 {
32 
43 class GoalUpdatedController : public BT::DecoratorNode
44 {
45 public:
52  const std::string & name,
53  const BT::NodeConfiguration & conf);
54 
59  static BT::PortsList providedPorts()
60  {
61  // Register JSON definitions for the types used in the ports
62  BT::RegisterJsonDefinition<geometry_msgs::msg::PoseStamped>();
63  BT::RegisterJsonDefinition<std::vector<geometry_msgs::msg::PoseStamped>>();
64 
65  return {
66  BT::InputPort<std::vector<geometry_msgs::msg::PoseStamped>>(
67  "goals", "Vector of navigation goals"),
68  BT::InputPort<geometry_msgs::msg::PoseStamped>(
69  "goal", "Navigation goal"),
70  };
71  }
72 
73 private:
78  BT::NodeStatus tick() override;
79 
80  bool goal_was_updated_;
81  geometry_msgs::msg::PoseStamped goal_;
82  std::vector<geometry_msgs::msg::PoseStamped> goals_;
83 };
84 
85 } // namespace nav2_behavior_tree
86 
87 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__DECORATOR__GOAL_UPDATED_CONTROLLER_HPP_
A BT::DecoratorNode that ticks its child if the goal was updated.
GoalUpdatedController(const std::string &name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::GoalUpdatedController.
static BT::PortsList providedPorts()
Creates list of BT ports.