Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(side_shift): fix unupdated prev path that caused heavy interpolation #6967

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class SideShiftModule : public SceneModuleInterface
// member
PathWithLaneId refined_path_{};
PathWithLaneId reference_path_{};
PathWithLaneId prev_reference_{};
lanelet::ConstLanelets current_lanelets_;
std::shared_ptr<SideShiftParameters> parameters_;

Expand Down
14 changes: 6 additions & 8 deletions planning/behavior_path_side_shift_module/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@

const auto reference_pose = prev_output_.shift_length.empty()
? planner_data_->self_odometry->pose.pose
: utils::getUnshiftedEgoPose(getEgoPose(), prev_output_);

Check notice on line 204 in planning/behavior_path_side_shift_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

SideShiftModule::updateData decreases in cyclomatic complexity from 11 to 10, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
if (prev_reference_.points.empty()) {
prev_reference_ = getPreviousModuleOutput().path;
}
if (getPreviousModuleOutput().reference_path.points.empty()) {
return;
}
Expand Down Expand Up @@ -433,13 +430,14 @@
const auto backward_length = std::max(
planner_data_->parameters.backward_path_length, longest_dist_to_shift_point + extra_margin);

const auto & prev_reference = getPreviousModuleOutput().path;
const size_t orig_ego_idx = findNearestIndex(original_path.points, getEgoPose().position);
const size_t prev_ego_idx = findNearestSegmentIndex(
prev_reference_.points, getPoint(original_path.points.at(orig_ego_idx)));
const size_t prev_ego_idx =
findNearestSegmentIndex(prev_reference.points, getPoint(original_path.points.at(orig_ego_idx)));

size_t clip_idx = 0;
for (size_t i = 0; i < prev_ego_idx; ++i) {
if (backward_length > calcSignedArcLength(prev_reference_.points, clip_idx, prev_ego_idx)) {
if (backward_length > calcSignedArcLength(prev_reference.points, clip_idx, prev_ego_idx)) {
break;
}
clip_idx = i;
Expand All @@ -448,8 +446,8 @@
PathWithLaneId extended_path{};
{
extended_path.points.insert(
extended_path.points.end(), prev_reference_.points.begin() + clip_idx,
prev_reference_.points.begin() + prev_ego_idx);
extended_path.points.end(), prev_reference.points.begin() + clip_idx,
prev_reference.points.begin() + prev_ego_idx);
}

{
Expand Down
Loading