Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
truncate_path_action.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__ACTION__TRUNCATE_PATH_ACTION_HPP_
17 #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__TRUNCATE_PATH_ACTION_HPP_
18 
19 #include <memory>
20 #include <string>
21 
22 #include "nav_msgs/msg/path.hpp"
23 
24 #include "behaviortree_cpp_v3/action_node.h"
25 
26 namespace nav2_behavior_tree
27 {
28 
32 class TruncatePath : public BT::ActionNodeBase
33 {
34 public:
41  const std::string & xml_tag_name,
42  const BT::NodeConfiguration & conf);
43 
48  static BT::PortsList providedPorts()
49  {
50  return {
51  BT::InputPort<nav_msgs::msg::Path>("input_path", "Original Path"),
52  BT::OutputPort<nav_msgs::msg::Path>("output_path", "Path truncated to a certain distance"),
53  BT::InputPort<double>("distance", 1.0, "distance"),
54  };
55  }
56 
57 private:
61  void halt() override {}
62 
67  BT::NodeStatus tick() override;
68 
69  double distance_;
70 };
71 
72 } // namespace nav2_behavior_tree
73 
74 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__TRUNCATE_PATH_ACTION_HPP_
A BT::ActionNodeBase to shorten path by some distance.
TruncatePath(const std::string &xml_tag_name, const BT::NodeConfiguration &conf)
A nav2_behavior_tree::TruncatePath constructor.
static BT::PortsList providedPorts()
Creates list of BT ports.