File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
include/nav2_behavior_tree/plugins/action Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -78,15 +78,18 @@ class FollowPathAction : public BtActionNode<nav2_msgs::action::FollowPath>
7878 */
7979 static BT::PortsList providedPorts ()
8080 {
81- return providedBasicPorts (
82- {
81+ return providedBasicPorts ({
8382 BT::InputPort<nav_msgs::msg::Path>(" path" , " Path to follow" ),
8483 BT::InputPort<std::string>(" controller_id" , " " ),
8584 BT::InputPort<std::string>(" goal_checker_id" , " " ),
8685 BT::InputPort<std::string>(" progress_checker_id" , " " ),
87- BT::OutputPort<ActionResult::_error_code_type>(
88- " error_code_id" , " The follow path error code" ),
89- });
86+ BT::OutputPort<double >(" distance_to_goal" , " Current distance_to_goal from feedback" ),
87+ BT::OutputPort<uint64_t >(
88+ " closest_path_pose_idx" ,
89+ " Current index of the pose on global path closest to current robot pose from feedback" ),
90+ BT::OutputPort<double >(" distance_to_path" , " Current distance_to_path from feedback" ),
91+ BT::OutputPort<ActionResult::_error_code_type>(" error_code_id" , " The follow path error code" ),
92+ });
9093 }
9194};
9295
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ BT::NodeStatus FollowPathAction::on_cancelled()
5656}
5757
5858void FollowPathAction::on_wait_for_result (
59- std::shared_ptr<const Action::Feedback>/* feedback*/ )
59+ std::shared_ptr<const Action::Feedback> feedback)
6060{
6161 // Grab the new path
6262 nav_msgs::msg::Path new_path;
@@ -92,6 +92,16 @@ void FollowPathAction::on_wait_for_result(
9292 goal_.progress_checker_id = new_progress_checker_id;
9393 goal_updated_ = true ;
9494 }
95+
96+ if (!goal_updated_ && feedback) // feedback may be nullptr if no new feedback was received
97+ {
98+ setOutput (" distance_to_goal" , static_cast <double >(feedback->distance_to_goal ));
99+ setOutput (" closest_path_pose_idx" , feedback->closest_path_pose_idx );
100+ setOutput (" distance_to_path" , static_cast <double >(feedback->distance_to_path ));
101+ // std::cout << "feedback:" << "distance_to_goal: " << feedback->distance_to_goal
102+ // << "closest_path_pose_idx: " << feedback->closest_path_pose_idx
103+ // << "distance_to_path: " << feedback->distance_to_path << std::endl;
104+ }
95105}
96106
97107} // namespace nav2_behavior_tree
You can’t perform that action at this time.
0 commit comments