Skip to content

Commit f2755f6

Browse files
committed
Make NavigateThroughPoses navigator report waypoint statuses information
Signed-off-by: zz990099 <771647586@qq.com>
1 parent 1db63c0 commit f2755f6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

nav2_bt_navigator/behavior_trees/navigate_through_poses_w_replanning_and_recovery.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<RateController hz="0.333">
1515
<RecoveryNode number_of_retries="1" name="ComputePathThroughPoses">
1616
<ReactiveSequence>
17-
<RemovePassedGoals input_goals="{goals}" output_goals="{goals}" radius="0.7"/>
17+
<RemovePassedGoals input_goals="{goals}" output_goals="{goals}" radius="0.7" input_waypoint_statuses="{waypoint_statuses}" output_waypoint_statuses="{waypoint_statuses}" />
1818
<ComputePathThroughPoses goals="{goals}" path="{path}" planner_id="{selected_planner}" error_code_id="{compute_path_error_code}" error_msg="{compute_path_error_msg}"/>
1919
</ReactiveSequence>
2020
<Sequence>

nav2_bt_navigator/include/nav2_bt_navigator/navigators/navigate_through_poses.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "geometry_msgs/msg/pose_stamped_array.hpp"
2525
#include "nav2_core/behavior_tree_navigator.hpp"
2626
#include "nav2_msgs/action/navigate_through_poses.hpp"
27+
#include "nav2_msgs/msg/waypoint_status.hpp"
2728
#include "nav_msgs/msg/path.hpp"
2829
#include "nav2_util/robot_utils.hpp"
2930
#include "nav2_util/geometry_utils.hpp"
@@ -110,6 +111,7 @@ class NavigateThroughPosesNavigator
110111
rclcpp::Time start_time_;
111112
std::string goals_blackboard_id_;
112113
std::string path_blackboard_id_;
114+
std::string waypoint_statuses_blackboard_id_;
113115

114116
// Odometry smoother object
115117
std::shared_ptr<nav2_util::OdomSmoother> odom_smoother_;

nav2_bt_navigator/src/navigators/navigate_through_poses.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ NavigateThroughPosesNavigator::configure(
4242

4343
path_blackboard_id_ = node->get_parameter("path_blackboard_id").as_string();
4444

45+
if (!node->has_parameter("waypoint_statuses_blackboard_id")) {
46+
node->declare_parameter("waypoint_statuses_blackboard_id", std::string("waypoint_statuses"));
47+
}
48+
49+
waypoint_statuses_blackboard_id_ =
50+
node->get_parameter("waypoint_statuses_blackboard_id").as_string();
51+
4552
// Odometry smoother object for getting current speed
4653
odom_smoother_ = odom_smoother;
4754

@@ -116,6 +123,9 @@ NavigateThroughPosesNavigator::onLoop()
116123
nav_msgs::msg::Goals goal_poses;
117124
[[maybe_unused]] auto res = blackboard->get(goals_blackboard_id_, goal_poses);
118125

126+
feedback_msg->waypoint_statuses =
127+
blackboard->get<std::vector<nav2_msgs::msg::WaypointStatus>>(waypoint_statuses_blackboard_id_);
128+
119129
if (goal_poses.goals.size() == 0) {
120130
bt_action_server_->publishFeedback(feedback_msg);
121131
return;
@@ -262,6 +272,11 @@ NavigateThroughPosesNavigator::initializeGoalPoses(ActionT::Goal::ConstSharedPtr
262272
blackboard->set<nav_msgs::msg::Goals>(goals_blackboard_id_,
263273
std::move(goals_array));
264274

275+
// Reset the waypoint states vector in the blackboard
276+
auto waypoint_statuses = std::vector<nav2_msgs::msg::WaypointStatus>(goals_array.goals.size());
277+
blackboard->set<decltype(waypoint_statuses)>(waypoint_statuses_blackboard_id_,
278+
std::move(waypoint_statuses));
279+
265280
return true;
266281
}
267282

0 commit comments

Comments
 (0)