Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
globally_updated_goal_condition.hpp
1 // Copyright (c) 2021 Joshua Wallace
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__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_
17 
18 #include <string>
19 #include <vector>
20 
21 #include "nav2_ros_common/lifecycle_node.hpp"
22 #include "behaviortree_cpp/condition_node.h"
23 #include "behaviortree_cpp/json_export.h"
24 #include "nav_msgs/msg/goals.hpp"
25 #include "nav2_behavior_tree/bt_utils.hpp"
26 #include "nav2_behavior_tree/json_utils.hpp"
27 
28 
29 namespace nav2_behavior_tree
30 {
40 class GloballyUpdatedGoalCondition : public BT::ConditionNode
41 {
42 public:
49  const std::string & condition_name,
50  const BT::NodeConfiguration & conf);
51 
53 
58  BT::NodeStatus tick() override;
59 
60 
65  static BT::PortsList providedPorts()
66  {
67  // Register JSON definitions for the types used in the ports
68  BT::RegisterJsonDefinition<geometry_msgs::msg::PoseStamped>();
69  BT::RegisterJsonDefinition<nav_msgs::msg::Goals>();
70 
71  return {
72  BT::InputPort<nav_msgs::msg::Goals>(
73  "goals", "Vector of navigation goals"),
74  BT::InputPort<geometry_msgs::msg::PoseStamped>(
75  "goal", "Navigation goal"),
76  };
77  }
78 
79 private:
80  bool first_time;
81  nav2::LifecycleNode::SharedPtr node_;
82  geometry_msgs::msg::PoseStamped goal_;
83  nav_msgs::msg::Goals goals_;
84 };
85 
86 } // namespace nav2_behavior_tree
87 
88 
89 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_
A BT::ConditionNode that returns SUCCESS when goal is updated on the blackboard and FAILURE otherwise...
static BT::PortsList providedPorts()
Creates list of BT ports.
BT::NodeStatus tick() override
The main override required by a BT action.