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

fix(obstacle_avoidance_planner): suppress the osqp error about upper/lower bounds #5895

Closed
Closed
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
9 changes: 7 additions & 2 deletions planning/obstacle_avoidance_planner/src/mpt_optimizer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check notice on line 1 in planning/obstacle_avoidance_planner/src/mpt_optimizer.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1267 to 1270, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1423,8 +1423,13 @@
for (const size_t i : fixed_points_indices) {
A.block(A_rows_end, D_x * i, D_x, D_x) = Eigen::MatrixXd::Identity(D_x, D_x);

lb.segment(A_rows_end, D_x) = ref_points.at(i).fixed_kinematic_state->toEigenVector();
ub.segment(A_rows_end, D_x) = ref_points.at(i).fixed_kinematic_state->toEigenVector();
// NOTE: Without this, "ERROR in osqp_update_lower_bound: upper bound must be greater than
// or equal to lower bound" is shown somehow especially when reaching the goal.
const Eigen::VectorXd epsilon_vec = Eigen::VectorXd::Constant(D_x, 1e-9);
lb.segment(A_rows_end, D_x) =
ref_points.at(i).fixed_kinematic_state->toEigenVector() - epsilon_vec;
ub.segment(A_rows_end, D_x) =
ref_points.at(i).fixed_kinematic_state->toEigenVector() + epsilon_vec;

Check warning on line 1432 in planning/obstacle_avoidance_planner/src/mpt_optimizer.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

MPTOptimizer::calcConstraintMatrix already has high cyclomatic complexity, and now it increases in Lines of Code from 102 to 105. 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.

A_rows_end += D_x;
}
Expand Down
Loading