Skip to content

Commit 1e1011e

Browse files
committed
add function to add path lanelets that may be missing during lane change
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent b7fdccc commit 1e1011e

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

planning/behavior_velocity_out_of_lane_module/src/lanelets_selection.cpp

+35-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,43 @@
2424

2525
namespace behavior_velocity_planner::out_of_lane
2626
{
27+
28+
lanelet::ConstLanelets consecutive_lanelets(
29+
const route_handler::RouteHandler & route_handler, const lanelet::ConstLanelet & lanelet)
30+
{
31+
lanelet::ConstLanelets consecutives = route_handler.getRoutingGraphPtr()->following(lanelet);
32+
const auto previous = route_handler.getRoutingGraphPtr()->previous(lanelet);
33+
consecutives.insert(consecutives.end(), previous.begin(), previous.end());
34+
return consecutives;
35+
}
36+
37+
lanelet::ConstLanelets get_missing_lane_change_lanelets(
38+
lanelet::ConstLanelets & path_lanelets, const route_handler::RouteHandler & route_handler)
39+
{
40+
lanelet::ConstLanelets missing_lane_change_lanelets;
41+
const auto & routing_graph = *route_handler.getRoutingGraphPtr();
42+
lanelet::ConstLanelets adjacents;
43+
lanelet::ConstLanelets consecutives;
44+
for (const auto & ll : path_lanelets) {
45+
for (const auto & consecutive : consecutive_lanelets(route_handler, ll))
46+
if (!contains_lanelet(consecutives, consecutive.id())) consecutives.push_back(consecutive);
47+
for (const auto & adjacent : routing_graph.besides(ll))
48+
if (!contains_lanelet(adjacents, adjacent.id())) adjacents.push_back(adjacent);
49+
}
50+
for (const auto & ll : adjacents) {
51+
if (
52+
!contains_lanelet(missing_lane_change_lanelets, ll.id()) &&
53+
!contains_lanelet(path_lanelets, ll.id()) && contains_lanelet(consecutives, ll.id()))
54+
missing_lane_change_lanelets.push_back(ll);
55+
}
56+
return missing_lane_change_lanelets;
57+
}
58+
2759
lanelet::ConstLanelets calculate_path_lanelets(
2860
const EgoData & ego_data, const route_handler::RouteHandler & route_handler)
2961
{
3062
const auto lanelet_map_ptr = route_handler.getLaneletMapPtr();
31-
lanelet::ConstLanelets path_lanelets =
32-
planning_utils::getLaneletsOnPath(ego_data.path, lanelet_map_ptr, ego_data.pose);
63+
lanelet::ConstLanelets path_lanelets;
3364
lanelet::BasicLineString2d path_ls;
3465
for (const auto & p : ego_data.path.points)
3566
path_ls.emplace_back(p.point.pose.position.x, p.point.pose.position.y);
@@ -38,6 +69,8 @@ lanelet::ConstLanelets calculate_path_lanelets(
3869
if (!contains_lanelet(path_lanelets, dist_lanelet.second.id()))
3970
path_lanelets.push_back(dist_lanelet.second);
4071
}
72+
const auto missing_lanelets = get_missing_lane_change_lanelets(path_lanelets, route_handler);
73+
path_lanelets.insert(path_lanelets.end(), missing_lanelets.begin(), missing_lanelets.end());
4174
return path_lanelets;
4275
}
4376

planning/behavior_velocity_out_of_lane_module/src/lanelets_selection.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ inline bool contains_lanelet(const lanelet::ConstLanelets & lanelets, const lane
4141
/// @return lanelets crossed by the ego vehicle
4242
lanelet::ConstLanelets calculate_path_lanelets(
4343
const EgoData & ego_data, const route_handler::RouteHandler & route_handler);
44+
/// @brief calculate lanelets that may not be crossed by the path but may be overlapped during a
45+
/// lane change
46+
/// @param [in] path_lanelets lanelets driven by the ego vehicle
47+
/// @param [in] route_handler route handler
48+
/// @return lanelets that may be overlapped by a lane change (and are not already in path_lanelets)
49+
lanelet::ConstLanelets get_missing_lane_change_lanelets(
50+
lanelet::ConstLanelets & path_lanelets, const route_handler::RouteHandler & route_handler);
4451
/// @brief calculate lanelets that should be ignored
4552
/// @param [in] ego_data data about the ego vehicle
4653
/// @param [in] path_lanelets lanelets driven by the ego vehicle

0 commit comments

Comments
 (0)