Skip to content

Commit 036b8f4

Browse files
author
Takumi Ito
committed
Append detection wethear the goal position is out of range during A-star planning.
Signed-off-by: Takumi Ito <takumi.ito@tier4.jp>
1 parent 9735dfa commit 036b8f4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

planning/freespace_planning_algorithms/src/astar_search.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,27 @@ bool AstarSearch::search()
259259
continue;
260260
}
261261

262+
geometry_msgs::msg::Pose relative_goal_pose;
263+
relative_goal_pose.position.x = goal_pose_.position.x - (next_pose.position.x - start_pose_.position.x);
264+
relative_goal_pose.position.y = goal_pose_.position.y - (next_pose.position.y - start_pose_.position.y);
265+
relative_goal_pose.orientation = goal_pose_.orientation;
266+
const auto relative_goal_index = pose2index(costmap_, relative_goal_pose, planner_common_param_.theta_size);
267+
268+
const auto & vertex_indexes_2d = vertex_indexes_table_[relative_goal_index.theta];
269+
bool relative_goal_is_out_of_range = false;
270+
for (const auto & vertex_index_2d : vertex_indexes_2d) {
271+
IndexXYT vertex_index{vertex_index_2d.x, vertex_index_2d.y, 0};
272+
// must slide to current base position
273+
vertex_index.x += relative_goal_index.x;
274+
vertex_index.y += relative_goal_index.y;
275+
if (isOutOfRange(vertex_index)) {
276+
relative_goal_is_out_of_range = true;
277+
}
278+
}
279+
if (relative_goal_is_out_of_range) {
280+
continue;
281+
}
282+
262283
// Compare cost
263284
AstarNode * next_node = getNodeRef(next_index);
264285
if (next_node->status == NodeStatus::None) {

0 commit comments

Comments
 (0)