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"
24 #include "nav2_ros_common/tf2_factories.hpp"
26 #include "nav2_behavior_tree/plugins/action/get_current_pose_action.hpp"
28 namespace nav2_behavior_tree
32 const std::string & name,
33 const BT::NodeConfiguration & conf)
34 : BT::ActionNodeBase(name, conf)
36 auto node = config().blackboard->get<nav2::LifecycleNode::SharedPtr>(
"node");
37 tf_ = config().blackboard->get<nav2::TransformBuffer::SharedPtr>(
"tf_buffer");
38 node->get_parameter(
"transform_tolerance", transform_tolerance_);
39 global_frame_ = BT::deconflictPortAndParamFrame<std::string>(
40 node,
"global_frame",
this);
41 robot_base_frame_ = BT::deconflictPortAndParamFrame<std::string>(
42 node,
"robot_base_frame",
this);
45 inline BT::NodeStatus GetCurrentPoseAction::tick()
47 setStatus(BT::NodeStatus::RUNNING);
48 geometry_msgs::msg::PoseStamped current_pose;
50 if (!nav2_util::getCurrentPose(
51 current_pose, *tf_, global_frame_, robot_base_frame_, transform_tolerance_))
54 config().blackboard->get<nav2::LifecycleNode::SharedPtr>(
"node")->get_logger(),
55 "Current robot pose is not available.");
56 return BT::NodeStatus::FAILURE;
59 setOutput(
"current_pose", current_pose);
60 return BT::NodeStatus::SUCCESS;
65 #include "behaviortree_cpp/bt_factory.h"
66 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.