Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
get_pose_from_path_action.hpp
1 // Copyright (c) 2024 Marc Morcos
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__GET_POSE_FROM_PATH_ACTION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__GET_POSE_FROM_PATH_ACTION_HPP_
17 
18 #include <vector>
19 #include <memory>
20 #include <string>
21 
22 #include "behaviortree_cpp/action_node.h"
23 #include "behaviortree_cpp/json_export.h"
24 #include "geometry_msgs/msg/pose_stamped.hpp"
25 #include "nav_msgs/msg/path.hpp"
26 #include "nav2_behavior_tree/bt_utils.hpp"
27 #include "nav2_behavior_tree/json_utils.hpp"
28 #include "nav2_util/geometry_utils.hpp"
29 #include "nav2_util/robot_utils.hpp"
30 #include "nav2_ros_common/lifecycle_node.hpp"
31 
32 namespace nav2_behavior_tree
33 {
34 
41 class GetPoseFromPath : public BT::ActionNodeBase
42 {
43 public:
45  const std::string & xml_tag_name,
46  const BT::NodeConfiguration & conf);
47 
48 
49  static BT::PortsList providedPorts()
50  {
51  // Register JSON definitions for the types used in the ports
52  BT::RegisterJsonDefinition<geometry_msgs::msg::PoseStamped>();
53  BT::RegisterJsonDefinition<nav_msgs::msg::Path>();
54 
55  return {
56  BT::InputPort<nav_msgs::msg::Path>("path", "Path to extract pose from"),
57  BT::OutputPort<geometry_msgs::msg::PoseStamped>("pose", "Stamped Extracted Pose"),
58  BT::InputPort<int>("index", 0, "Index of pose to extract from. -1 is end of list"),
59  };
60  }
61 
62 private:
63  void halt() override {}
64  BT::NodeStatus tick() override;
65 };
66 
67 } // namespace nav2_behavior_tree
68 
69 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__GET_POSE_FROM_PATH_ACTION_HPP_