19 #include "nav_msgs/msg/path.hpp"
20 #include "nav2_util/geometry_utils.hpp"
22 #include "nav2_behavior_tree/plugins/action/get_pose_from_path_action.hpp"
24 namespace nav2_behavior_tree
27 GetPoseFromPath::GetPoseFromPath(
28 const std::string & name,
29 const BT::NodeConfiguration & conf)
30 : BT::ActionNodeBase(name, conf)
34 inline BT::NodeStatus GetPoseFromPath::tick()
36 setStatus(BT::NodeStatus::RUNNING);
38 nav_msgs::msg::Path input_path;
39 getInput(
"path", input_path);
42 getInput(
"index", pose_index);
44 if (input_path.poses.empty()) {
45 return BT::NodeStatus::FAILURE;
50 pose_index = input_path.poses.size() + pose_index;
54 if (pose_index < 0 ||
static_cast<unsigned>(pose_index) >= input_path.poses.size()) {
55 return BT::NodeStatus::FAILURE;
59 geometry_msgs::msg::PoseStamped output_pose;
60 output_pose = input_path.poses[pose_index];
63 if (output_pose.header.frame_id.empty()) {
64 output_pose.header.frame_id = input_path.header.frame_id;
68 setOutput(
"pose", output_pose);
70 return BT::NodeStatus::SUCCESS;
75 #include "behaviortree_cpp/bt_factory.h"
76 BT_REGISTER_NODES(factory)