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(autoware_multi_object_tracker): fix bugprone-errors #9651

Merged
merged 1 commit into from
Dec 16, 2024
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 @@ -208,11 +208,8 @@
constexpr double size_min = 0.1; // [m]
if (
object.shape.dimensions.x > size_max || object.shape.dimensions.y > size_max ||
object.shape.dimensions.z > size_max) {
return false;
} else if (
object.shape.dimensions.x < size_min || object.shape.dimensions.y < size_min ||
object.shape.dimensions.z < size_min) {
object.shape.dimensions.z > size_max || object.shape.dimensions.x < size_min ||
object.shape.dimensions.y < size_min || object.shape.dimensions.z < size_min) {

Check notice on line 212 in perception/autoware_multi_object_tracker/lib/tracker/model/bicycle_tracker.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Conditional

BicycleTracker::measureWithShape decreases from 2 complex conditionals with 4 branches to 1 complex conditionals with 5 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check warning on line 212 in perception/autoware_multi_object_tracker/lib/tracker/model/bicycle_tracker.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_multi_object_tracker/lib/tracker/model/bicycle_tracker.cpp#L211-L212

Added lines #L211 - L212 were not covered by tests
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
double w = vel * sin_slip / lr_;
const double sin_2yaw = std::sin(2.0f * X_t(IDX::YAW));
const double w_dtdt = w * dt * dt;
const double vv_dtdt__lr = vel * vel * dt * dt / lr_;
const double vv_dtdt_lr = vel * vel * dt * dt / lr_;

Check warning on line 318 in perception/autoware_multi_object_tracker/lib/tracker/motion_model/bicycle_motion_model.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_multi_object_tracker/lib/tracker/motion_model/bicycle_motion_model.cpp#L318

Added line #L318 was not covered by tests

// Predict state vector X t+1
Eigen::MatrixXd X_next_t(DIM, 1); // predicted state
Expand All @@ -332,11 +332,11 @@
A(IDX::X, IDX::YAW) = -vel * sin_yaw * dt - 0.5 * vel * cos_yaw * w_dtdt;
A(IDX::X, IDX::VEL) = cos_yaw * dt - sin_yaw * w_dtdt;
A(IDX::X, IDX::SLIP) =
-vel * sin_yaw * dt - 0.5 * (cos_slip * sin_yaw + sin_slip * cos_yaw) * vv_dtdt__lr;
-vel * sin_yaw * dt - 0.5 * (cos_slip * sin_yaw + sin_slip * cos_yaw) * vv_dtdt_lr;

Check warning on line 335 in perception/autoware_multi_object_tracker/lib/tracker/motion_model/bicycle_motion_model.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_multi_object_tracker/lib/tracker/motion_model/bicycle_motion_model.cpp#L335

Added line #L335 was not covered by tests
A(IDX::Y, IDX::YAW) = vel * cos_yaw * dt - 0.5 * vel * sin_yaw * w_dtdt;
A(IDX::Y, IDX::VEL) = sin_yaw * dt + cos_yaw * w_dtdt;
A(IDX::Y, IDX::SLIP) =
vel * cos_yaw * dt + 0.5 * (cos_slip * cos_yaw - sin_slip * sin_yaw) * vv_dtdt__lr;
vel * cos_yaw * dt + 0.5 * (cos_slip * cos_yaw - sin_slip * sin_yaw) * vv_dtdt_lr;

Check warning on line 339 in perception/autoware_multi_object_tracker/lib/tracker/motion_model/bicycle_motion_model.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_multi_object_tracker/lib/tracker/motion_model/bicycle_motion_model.cpp#L339

Added line #L339 was not covered by tests
A(IDX::YAW, IDX::VEL) = 1.0 / lr_ * sin_slip * dt;
A(IDX::YAW, IDX::SLIP) = vel / lr_ * cos_slip * dt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@
// The default object_earliest_time is to have a 1-second time interval
const rclcpp::Time object_earliest_time_default =
object_latest_time - rclcpp::Duration::from_seconds(1.0);
if (latest_exported_object_time_ < object_earliest_time_default) {
// if the latest exported object time is too old, set to the default
object_earliest_time = object_earliest_time_default;
} else if (latest_exported_object_time_ > object_latest_time) {
// if the latest exported object time is newer than the object_latest_time, set to the default
if (
latest_exported_object_time_ < object_earliest_time_default ||
latest_exported_object_time_ > object_latest_time) {

Check warning on line 268 in perception/autoware_multi_object_tracker/src/processor/input_manager.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_multi_object_tracker/src/processor/input_manager.cpp#L267-L268

Added lines #L267 - L268 were not covered by tests
// if the latest exported object time is too old or newer than the object_latest_time,
// set to the default
object_earliest_time = object_earliest_time_default;
} else {
// The object_earliest_time is the latest exported object time
Expand Down
Loading