Skip to content

Commit e167aaf

Browse files
authored
Merge pull request #5 from angsa-robotics/AR-2212_Move_intermediate_goal_sampling_to_route_planner
AR-2212 Move intermediate goal sampling to route planner
2 parents 432f289 + aa671b1 commit e167aaf

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/remove_in_collision_goals_action.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,17 @@ class RemoveInCollisionGoals : public BtServiceNode<nav2_msgs::srv::GetCosts>
6666
BT::InputPort<int>(
6767
"nb_goals_to_consider", 5,
6868
"Number of goals to consider for collision checking"),
69+
BT::InputPort<bool>(
70+
"update_status", true,
71+
"Whether to update the status of the goals"),
6972
BT::OutputPort<Goals>("output_goals", "Goals with in-collision goals removed"),
7073
});
7174
}
7275

7376
private:
7477
bool use_footprint_;
7578
bool consider_unknown_as_obstacle_;
79+
bool update_status_;
7680
double cost_threshold_;
7781
Goals input_goals_;
7882
int nb_goals_to_consider_;

nav2_behavior_tree/plugins/action/remove_in_collision_goals_action.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void RemoveInCollisionGoals::on_tick()
3939
getInput("input_goals", input_goals_);
4040
getInput("consider_unknown_as_obstacle", consider_unknown_as_obstacle_);
4141
getInput("nb_goals_to_consider", nb_goals_to_consider_);
42+
getInput("update_status", update_status_);
4243

4344
if (input_goals_.empty()) {
4445
setOutput("output_goals", input_goals_);
@@ -63,7 +64,9 @@ BT::NodeStatus RemoveInCollisionGoals::on_completion(
6364
[[maybe_unused]] auto res = config().blackboard->get("goals_feedback", goals_feedback);
6465
for (int i = static_cast<int>(response->costs.size()) - 1; i >= 0; --i) {
6566
if ((response->costs[i] != 255 || consider_unknown_as_obstacle_) && response->costs[i] >= cost_threshold_) {
66-
goals_feedback[input_goals_[i].index].status = nav2_msgs::msg::Waypoint::SKIPPED;
67+
if (update_status_) {
68+
goals_feedback[input_goals_[i].index].status = nav2_msgs::msg::Waypoint::SKIPPED;
69+
}
6770
// if it's not valid then we erase it from input_goals_ and set the status to SKIPPED
6871
input_goals_.erase(input_goals_.begin() + i);
6972
}

nav2_planner/src/planner_server.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,14 @@ void PlannerServer::computePlanThroughPoses()
433433
curr_start, curr_goal, goal->planner_id,
434434
cancel_checker);
435435
} catch (nav2_core::GoalOutsideMapBounds & ex) {
436-
RCLCPP_WARN(
437-
get_logger(), "Goal %d coordinates of (%.2f, %.2f) was outside bounds",
438-
i, curr_goal.pose.position.x, curr_goal.pose.position.y);
439-
continue;
436+
if (i == 0) {
437+
throw ex;
438+
} else {
439+
RCLCPP_WARN(
440+
get_logger(), "Goal %d coordinates of (%.2f, %.2f) was outside bounds but there are still goals inside. Ignoring the rest",
441+
i, curr_goal.pose.position.x, curr_goal.pose.position.y);
442+
break;
443+
}
440444
} catch (nav2_core::StartOccupied & ex) {
441445
RCLCPP_WARN(
442446
get_logger(), "Error START_OCCUPIED but probably 2 goals are just too close to each other.");

0 commit comments

Comments
 (0)