16 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__TRUNCATE_PATH_LOCAL_ACTION_HPP_
17 #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__TRUNCATE_PATH_LOCAL_ACTION_HPP_
23 #include "nav_msgs/msg/path.hpp"
25 #include "behaviortree_cpp/action_node.h"
26 #include "behaviortree_cpp/json_export.h"
27 #include "nav2_behavior_tree/json_utils.hpp"
28 #include "tf2_ros/buffer.h"
30 namespace nav2_behavior_tree
51 const std::string & xml_tag_name,
52 const BT::NodeConfiguration & conf);
61 BT::RegisterJsonDefinition<nav_msgs::msg::Path>();
62 BT::RegisterJsonDefinition<geometry_msgs::msg::PoseStamped>();
65 BT::InputPort<nav_msgs::msg::Path>(
"input_path",
"Original Path"),
66 BT::OutputPort<nav_msgs::msg::Path>(
67 "output_path",
"Path truncated to a certain distance around robot"),
68 BT::InputPort<double>(
69 "distance_forward", 8.0,
70 "Distance in forward direction"),
71 BT::InputPort<double>(
72 "distance_backward", 4.0,
73 "Distance in backward direction"),
74 BT::InputPort<std::string>(
75 "robot_frame",
"base_link",
76 "Robot base frame id"),
77 BT::InputPort<double>(
78 "transform_tolerance", 0.2,
79 "Transform lookup tolerance"),
80 BT::InputPort<geometry_msgs::msg::PoseStamped>(
81 "pose",
"Manually specified pose to be used"
82 "if overriding current robot pose"),
83 BT::InputPort<double>(
84 "angular_distance_weight", 0.0,
85 "Weight of angular distance relative to positional distance when finding which path "
86 "pose is closest to robot. Not applicable on paths without orientations assigned"),
87 BT::InputPort<double>(
88 "max_robot_pose_search_dist", std::numeric_limits<double>::infinity(),
89 "Maximum forward integrated distance along the path (starting from the last detected pose) "
90 "to bound the search for the closest pose to the robot. When set to infinity (default), "
91 "whole path is searched every time"),
99 void halt()
override {}
105 BT::NodeStatus tick()
override;
113 bool getRobotPose(std::string path_frame_id, geometry_msgs::msg::PoseStamped & pose);
123 static double poseDistance(
124 const geometry_msgs::msg::PoseStamped & pose1,
125 const geometry_msgs::msg::PoseStamped & pose2,
126 const double angular_distance_weight);
128 std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
130 nav_msgs::msg::Path path_;
131 nav_msgs::msg::Path::_poses_type::iterator closest_pose_detection_begin_;
A BT::ActionNodeBase to shorten path to some distance around robot.
static BT::PortsList providedPorts()
Creates list of BT ports.
TruncatePathLocal(const std::string &xml_tag_name, const BT::NodeConfiguration &conf)
A nav2_behavior_tree::TruncatePathLocal constructor.