20 #include "nav_msgs/msg/path.hpp"
21 #include "geometry_msgs/msg/pose_stamped.hpp"
22 #include "nav2_util/geometry_utils.hpp"
23 #include "behaviortree_cpp/decorator_node.h"
25 #include "nav2_behavior_tree/plugins/action/get_current_pose_action.hpp"
27 namespace nav2_behavior_tree
31 const std::string & name,
32 const BT::NodeConfiguration & conf)
33 : BT::ActionNodeBase(name, conf)
35 auto node = config().blackboard->get<nav2::LifecycleNode::SharedPtr>(
"node");
36 tf_ = config().blackboard->get<std::shared_ptr<tf2_ros::Buffer>>(
"tf_buffer");
37 node->get_parameter(
"transform_tolerance", transform_tolerance_);
38 global_frame_ = BT::deconflictPortAndParamFrame<std::string>(
39 node,
"global_frame",
this);
40 robot_base_frame_ = BT::deconflictPortAndParamFrame<std::string>(
41 node,
"robot_base_frame",
this);
44 inline BT::NodeStatus GetCurrentPoseAction::tick()
46 setStatus(BT::NodeStatus::RUNNING);
47 geometry_msgs::msg::PoseStamped current_pose;
49 if (!nav2_util::getCurrentPose(
50 current_pose, *tf_, global_frame_, robot_base_frame_, transform_tolerance_))
53 config().blackboard->get<nav2::LifecycleNode::SharedPtr>(
"node")->get_logger(),
54 "Current robot pose is not available.");
55 return BT::NodeStatus::FAILURE;
58 setOutput(
"current_pose", current_pose);
59 return BT::NodeStatus::SUCCESS;
64 #include "behaviortree_cpp/bt_factory.h"
65 BT_REGISTER_NODES(factory)
A BT::ActionNodeBase to shorten path by some distance.
GetCurrentPoseAction(const std::string &xml_tag_name, const BT::NodeConfiguration &conf)
A nav2_behavior_tree::GetCurrentPoseAction constructor.