Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
goal_updated_condition.hpp
1 // Copyright (c) 2020 Aitor Miguel Blanco
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__CONDITION__GOAL_UPDATED_CONDITION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GOAL_UPDATED_CONDITION_HPP_
17 
18 #include <string>
19 #include <vector>
20 
21 #include "behaviortree_cpp/condition_node.h"
22 #include "behaviortree_cpp/json_export.h"
23 #include "nav_msgs/msg/goals.hpp"
24 #include "nav2_behavior_tree/bt_utils.hpp"
25 #include "nav2_behavior_tree/json_utils.hpp"
26 
27 
28 namespace nav2_behavior_tree
29 {
30 
37 class GoalUpdatedCondition : public BT::ConditionNode
38 {
39 public:
46  const std::string & condition_name,
47  const BT::NodeConfiguration & conf);
48 
49  GoalUpdatedCondition() = delete;
50 
55  BT::NodeStatus tick() override;
56 
61  static BT::PortsList providedPorts()
62  {
63  // Register JSON definitions for the types used in the ports
64  BT::RegisterJsonDefinition<geometry_msgs::msg::PoseStamped>();
65  BT::RegisterJsonDefinition<nav_msgs::msg::Goals>();
66 
67  return {
68  BT::InputPort<nav_msgs::msg::Goals>(
69  "goals", "Vector of navigation goals"),
70  BT::InputPort<geometry_msgs::msg::PoseStamped>(
71  "goal", "Navigation goal"),
72  };
73  }
74 
75 private:
76  geometry_msgs::msg::PoseStamped goal_;
77  nav_msgs::msg::Goals goals_;
78 };
79 
80 } // namespace nav2_behavior_tree
81 
82 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GOAL_UPDATED_CONDITION_HPP_
A BT::ConditionNode that returns SUCCESS when goal is updated on the blackboard and FAILURE otherwise...
BT::NodeStatus tick() override
The main override required by a BT action.
static BT::PortsList providedPorts()
Creates list of BT ports.