15 #include "nav2_behavior_tree/plugins/action/get_current_pose_action.hpp"
17 namespace nav2_behavior_tree
21 const std::string & xml_tag_name,
22 const BT::NodeConfiguration & conf)
23 : BT::ActionNodeBase(xml_tag_name, conf)
25 auto node = config().blackboard->get<rclcpp::Node::SharedPtr>(
"node");
26 tf_ = config().blackboard->get<std::shared_ptr<tf2_ros::Buffer>>(
"tf_buffer");
27 node->get_parameter(
"transform_tolerance", transform_tolerance_);
28 global_frame_ = BT::deconflictPortAndParamFrame<std::string>(
29 node,
"global_frame",
this);
30 robot_base_frame_ = BT::deconflictPortAndParamFrame<std::string>(
31 node,
"robot_base_frame",
this);
34 BT::NodeStatus GetCurrentPoseAction::tick()
36 setStatus(BT::NodeStatus::RUNNING);
37 geometry_msgs::msg::PoseStamped current_pose;
39 if (!nav2_util::getCurrentPose(
40 current_pose, *tf_, global_frame_, robot_base_frame_, transform_tolerance_))
43 config().blackboard->get<rclcpp::Node::SharedPtr>(
"node")->get_logger(),
44 "Current robot pose is not available.");
45 return BT::NodeStatus::FAILURE;
48 setOutput(
"current_pose", current_pose);
49 return BT::NodeStatus::SUCCESS;
54 #include "behaviortree_cpp/bt_factory.h"
55 BT_REGISTER_NODES(factory)
Action Node to get the current robot pose from TF.
GetCurrentPoseAction(const std::string &xml_tag_name, const BT::NodeConfiguration &conf)
Constructor.