Nav2 Navigation Stack - jazzy  jazzy
ROS 2 Navigation Stack
remove_passed_goals_action.hpp
1 // Copyright (c) 2021 Samsung Research America
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__REMOVE_PASSED_GOALS_ACTION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__REMOVE_PASSED_GOALS_ACTION_HPP_
17 
18 #include <vector>
19 #include <memory>
20 #include <string>
21 
22 #include "behaviortree_cpp/json_export.h"
23 #include "geometry_msgs/msg/pose_stamped.hpp"
24 #include "nav2_util/geometry_utils.hpp"
25 #include "nav2_util/robot_utils.hpp"
26 #include "behaviortree_cpp/action_node.h"
27 #include "nav2_behavior_tree/bt_utils.hpp"
28 #include "nav2_behavior_tree/json_utils.hpp"
29 
30 namespace nav2_behavior_tree
31 {
32 
39 class RemovePassedGoals : public BT::ActionNodeBase
40 {
41 public:
42  typedef std::vector<geometry_msgs::msg::PoseStamped> Goals;
43 
45  const std::string & xml_tag_name,
46  const BT::NodeConfiguration & conf);
47 
51  void initialize();
52 
53  static BT::PortsList providedPorts()
54  {
55  return {
56  BT::InputPort<Goals>("input_goals", "Original goals to remove viapoints from"),
57  BT::OutputPort<Goals>("output_goals", "Goals with passed viapoints removed"),
58  BT::InputPort<double>("radius", 0.5, "radius to goal for it to be considered for removal"),
59  BT::InputPort<std::string>("global_frame", "Global frame"),
60  BT::InputPort<std::string>("robot_base_frame", "Robot base frame"),
61  };
62  }
63 
64 private:
65  void halt() override {}
66  BT::NodeStatus tick() override;
67 
68  double viapoint_achieved_radius_;
69  double transform_tolerance_;
70  std::shared_ptr<tf2_ros::Buffer> tf_;
71  std::string robot_base_frame_;
72 };
73 
74 } // namespace nav2_behavior_tree
75 
76 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__REMOVE_PASSED_GOALS_ACTION_HPP_
void initialize()
Function to read parameters and initialize class variables.