Skip to content

Commit

Permalink
feat(route_handler): use start pose yaw and not lanelet length to sel…
Browse files Browse the repository at this point in the history
…ect start lanelet (autowarefoundation#6550)

use start pose yaw  and not lanelet length to select start lanelet

Signed-off-by: Daniel Sanchez <[email protected]>
  • Loading branch information
danielsanchezaran authored and karishma1911 committed Jun 3, 2024
1 parent 02b08c5 commit c2b59da
Showing 1 changed file with 21 additions and 34 deletions.
55 changes: 21 additions & 34 deletions planning/route_handler/src/route_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2133,24 +2133,17 @@ bool RouteHandler::planPathLaneletsBetweenCheckpoints(
lanelet::routing::LaneletPath shortest_path;
bool is_route_found = false;

lanelet::routing::LaneletPath drivable_lane_path;
bool drivable_lane_path_found = false;
double shortest_path_length2d = std::numeric_limits<double>::max();
double smallest_angle_diff = std::numeric_limits<double>::max();
constexpr double yaw_threshold = M_PI / 2.0;

for (const auto & st_llt : start_lanelets) {
// check if the angle difference between start_checkpoint and start lanelet center line
// orientation is in yaw_threshold range
double yaw_threshold = M_PI / 2.0;
bool is_proper_angle = false;
{
double lanelet_angle = lanelet::utils::getLaneletAngle(st_llt, start_checkpoint.position);
double pose_yaw = tf2::getYaw(start_checkpoint.orientation);
double angle_diff = std::abs(autoware_utils::normalize_radian(lanelet_angle - pose_yaw));

if (angle_diff <= std::abs(yaw_threshold)) {
is_proper_angle = true;
}
}
double lanelet_angle = lanelet::utils::getLaneletAngle(st_llt, start_checkpoint.position);
double pose_yaw = tf2::getYaw(start_checkpoint.orientation);
double angle_diff = std::abs(autoware_utils::normalize_radian(lanelet_angle - pose_yaw));

bool is_proper_angle = angle_diff <= std::abs(yaw_threshold);

optional_route = routing_graph_ptr_->getRoute(st_llt, goal_lanelet, 0);
if (!optional_route || !is_proper_angle) {
Expand All @@ -2161,34 +2154,28 @@ bool RouteHandler::planPathLaneletsBetweenCheckpoints(
<< " - goal checkpoint: " << toString(goal_checkpoint) << std::endl
<< " - start lane id: " << st_llt.id() << std::endl
<< " - goal lane id: " << goal_lanelet.id() << std::endl);
} else {
is_route_found = true;

if (optional_route->length2d() < shortest_path_length2d) {
shortest_path_length2d = optional_route->length2d();
shortest_path = optional_route->shortestPath();
start_lanelet = st_llt;
}
continue;
}
is_route_found = true;
if (angle_diff < smallest_angle_diff) {
smallest_angle_diff = angle_diff;
shortest_path = optional_route->shortestPath();
start_lanelet = st_llt;
}
}

if (is_route_found) {
lanelet::routing::LaneletPath path;
if (consider_no_drivable_lanes) {
bool shortest_path_has_no_drivable_lane = hasNoDrivableLaneInPath(shortest_path);
if (shortest_path_has_no_drivable_lane) {
path = [&]() -> lanelet::routing::LaneletPath {
if (!consider_no_drivable_lanes) return shortest_path;
lanelet::routing::LaneletPath drivable_lane_path;
bool drivable_lane_path_found = false;
if (hasNoDrivableLaneInPath(shortest_path)) {
drivable_lane_path_found =
findDrivableLanePath(start_lanelet, goal_lanelet, drivable_lane_path);
}

if (drivable_lane_path_found) {
path = drivable_lane_path;
} else {
path = shortest_path;
}
} else {
path = shortest_path;
}
return (drivable_lane_path_found) ? drivable_lane_path : shortest_path;
}();

path_lanelets->reserve(path.size());
for (const auto & llt : path) {
Expand Down

0 comments on commit c2b59da

Please sign in to comment.