Skip to content

Commit 247be5b

Browse files
authored
perf(behavior_path_planner): improve getReferencePath to support very long routes (autowarefoundation#6739) (#1278)
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent 9f6cf65 commit 247be5b

File tree

14 files changed

+829
-572
lines changed

14 files changed

+829
-572
lines changed

planning/behavior_path_lane_change_module/include/behavior_path_lane_change_module/interface.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class LaneChangeInterface : public SceneModuleInterface
6767

6868
bool isExecutionReady() const override;
6969

70-
bool isRootLaneletToBeUpdated() const override
70+
bool isCurrentRouteLaneletToBeReset() const override
7171
{
7272
return getCurrentStatus() == ModuleStatus::SUCCESS;
7373
}

planning/behavior_path_lane_change_module/src/scene.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ void NormalLaneChange::insertStopPoint(
404404

405405
PathWithLaneId NormalLaneChange::getReferencePath() const
406406
{
407-
return utils::getCenterLinePathFromRootLanelet(
407+
return utils::getCenterLinePathFromLanelet(
408408
status_.lane_change_path.info.target_lanes.front(), planner_data_);
409409
}
410410

planning/behavior_path_planner/docs/behavior_path_planner_manager_design.md

+10-44
Original file line numberDiff line numberDiff line change
@@ -532,67 +532,33 @@ When the manager removes succeeded modules, the last added module's output is us
532532

533533
## Reference path generation
534534

535-
The root reference path is generated from the centerline of the **lanelet sequence** that obtained from the **root lanelet**, and it is not only used as an input to the first added module of approved modules stack, but also used as the output of `behavior_path_planner` if none of the modules are running.
535+
The reference path is generated from the centerline of the **lanelet sequence** obtained from the **current route lanelet**, and it is not only used as an input to the first added module of approved modules stack, but also used as the output of `behavior_path_planner` if none of the modules are running.
536536

537537
<figure markdown>
538538
![root_generation](../image/manager/root_generation.svg){width=500}
539539
<figcaption>root reference path generation</figcaption>
540540
</figure>
541541

542-
The root lanelet is the closest lanelet within the route, and the update timing is based on Ego's operation mode state.
542+
The **current route lanelet** keeps track of the route lanelet currently followed by the planner.
543+
It is initialized as the closest lanelet within the route.
544+
It is then updated as ego travels along the route such that (1) it follows the previous **current route lanelet** and (2) it is the closest lanelet within the route.
543545

544-
- the state is `OperationModeState::AUTONOMOUS`: Update only when the ego moves to right or left lane by lane change module.
545-
- the state is **NOT** `OperationModeState::AUTONOMOUS`: Update at the beginning of every planning cycle.
546+
The **current route lanelet** can be reset to the closest lanelet within the route, ignoring whether it follows the previous **current route lanelet** .
546547

547-
![root_lanelet](../image/manager/root_lanelet.svg)
548+
![current_route_lanelet](../image/manager/current_route_lanelet.svg)
548549

549550
The manager needs to know the ego behavior and then generate a root reference path from the lanes that Ego should follow.
550551

551-
For example, during autonomous driving, even if Ego moves into the next lane in order to avoid a parked vehicle, the target lanes that Ego should follow will **NOT** change because Ego will return to the original lane after the avoidance maneuver. Therefore, the manager does **NOT** update **root lanelet** even if the avoidance maneuver is finished.
552+
For example, during autonomous driving, even if Ego moves into the next lane in order to avoid a parked vehicle, the target lanes that Ego should follow will **NOT** change because Ego will return to the original lane after the avoidance maneuver. Therefore, the manager does **NOT** reset the **current route lanelet**, even if the avoidance maneuver is finished.
552553

553554
![avoidance](../image/manager/avoidance.svg)
554555

555-
On the other hand, if the lane change is successful, the manager updates **root lanelet** because the lane that Ego should follow changes.
556+
On the other hand, if the lane change is successful, the manager resets the **current route lanelet** because the lane that Ego should follow changes.
556557

557558
![lane_change](../image/manager/lane_change.svg)
558559

559-
In addition, while manual driving, the manager always updates **root lanelet** because the pilot may move to an adjacent lane regardless of the decision of the autonomous driving system.
560-
561-
```c++
562-
/**
563-
* @brief get reference path from root_lanelet_ centerline.
564-
* @param planner data.
565-
* @return reference path.
566-
*/
567-
BehaviorModuleOutput getReferencePath(const std::shared_ptr<PlannerData> & data) const
568-
{
569-
const auto & route_handler = data->route_handler;
570-
const auto & pose = data->self_odometry->pose.pose;
571-
const auto p = data->parameters;
572-
573-
constexpr double extra_margin = 10.0;
574-
const auto backward_length =
575-
std::max(p.backward_path_length, p.backward_path_length + extra_margin);
576-
577-
const auto lanelet_sequence = route_handler->getLaneletSequence(
578-
root_lanelet_.value(), pose, backward_length, std::numeric_limits<double>::max());
579-
580-
lanelet::ConstLanelet closest_lane{};
581-
if (lanelet::utils::query::getClosestLaneletWithConstrains(
582-
lanelet_sequence, pose, &closest_lane, p.ego_nearest_dist_threshold,
583-
p.ego_nearest_yaw_threshold)) {
584-
return utils::getReferencePath(closest_lane, data);
585-
}
586-
587-
if (lanelet::utils::query::getClosestLanelet(lanelet_sequence, pose, &closest_lane)) {
588-
return utils::getReferencePath(closest_lane, data);
589-
}
590-
591-
return {}; // something wrong.
592-
}
593-
```
594-
595-
Code is [here](https://github.com/autowarefoundation/autoware.universe/blob/b1734916e3efd9786507a271e0fe829dd37476c8/planning/behavior_path_planner/include/behavior_path_planner/planner_manager.hpp#L202-L227)
560+
In addition, while manually driving (i.e., either the `OperationModeState` is different from `AUTONOMOUS` or the Autoware control is not engaged), the manager resets the **current route lanelet** at each iteration because the ego vehicle may move to an adjacent lane regardless of the decision of the autonomous driving system.
561+
The only exception is when a module is already approved, allowing testing the module's behavior while manually driving.
596562

597563
## Drivable area generation
598564

0 commit comments

Comments
 (0)