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 "behaviortree_cpp/action_node.h"
24 #include "behaviortree_cpp/json_export.h"
25 #include "nav_msgs/msg/path.hpp"
26 #include "nav2_behavior_tree/bt_utils.hpp"
27 #include "nav2_behavior_tree/json_utils.hpp"
28 #include "nav2_ros_common/tf2_factories.hpp"
29 #include "nav2_ros_common/lifecycle_node.hpp"
32 namespace nav2_behavior_tree
53 const std::string & xml_tag_name,
54 const BT::NodeConfiguration & conf);
63 BT::RegisterJsonDefinition<nav_msgs::msg::Path>();
64 BT::RegisterJsonDefinition<geometry_msgs::msg::PoseStamped>();
67 BT::InputPort<nav_msgs::msg::Path>(
"input_path",
"Original Path"),
68 BT::OutputPort<nav_msgs::msg::Path>(
69 "output_path",
"Path truncated to a certain distance around robot"),
70 BT::InputPort<double>(
71 "distance_forward", 8.0,
72 "Distance in forward direction"),
73 BT::InputPort<double>(
74 "distance_backward", 4.0,
75 "Distance in backward direction"),
76 BT::InputPort<std::string>(
78 "Robot base frame id"),
79 BT::InputPort<double>(
80 "transform_tolerance", 0.2,
81 "Transform lookup tolerance"),
82 BT::InputPort<geometry_msgs::msg::PoseStamped>(
83 "pose",
"Manually specified pose to be used"
84 "if overriding current robot pose"),
85 BT::InputPort<double>(
86 "angular_distance_weight", 0.0,
87 "Weight of angular distance relative to positional distance when finding which path "
88 "pose is closest to robot. Not applicable on paths without orientations assigned"),
89 BT::InputPort<double>(
90 "max_robot_pose_search_dist", std::numeric_limits<double>::infinity(),
91 "Maximum forward integrated distance along the path (starting from the last detected pose) "
92 "to bound the search for the closest pose to the robot. When set to infinity (default), "
93 "whole path is searched every time"),
101 void halt()
override {}
107 BT::NodeStatus tick()
override;
115 bool getRobotPose(std::string path_frame_id, geometry_msgs::msg::PoseStamped & pose);
125 static double poseDistance(
126 const geometry_msgs::msg::PoseStamped & pose1,
127 const geometry_msgs::msg::PoseStamped & pose2,
128 const double angular_distance_weight);
130 nav2::TransformBuffer::SharedPtr tf_buffer_;
132 nav_msgs::msg::Path path_;
133 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.