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

feat(autonomous_emergency_braking): enable aeb with only one req path #8569

Merged
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
29 changes: 19 additions & 10 deletions control/autoware_autonomous_emergency_braking/src/node.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 TIER IV, Inc.

Check notice on line 1 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 5.58 to 5.68, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// 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 @@ -348,21 +348,30 @@
return missing("object detection method (pointcloud or predicted objects)");
}

const auto imu_ptr = sub_imu_.takeData();
if (use_imu_path_) {
const bool has_imu_path = std::invoke([&]() {
if (!use_imu_path_) return false;
const auto imu_ptr = sub_imu_.takeData();
if (!imu_ptr) {
return missing("imu message");
}
// imu_ptr is valid
onImu(imu_ptr);
}
if (use_imu_path_ && !angular_velocity_ptr_) {
return missing("imu");
}
return (!angular_velocity_ptr_) ? missing("imu") : true;
});

predicted_traj_ptr_ = sub_predicted_traj_.takeData();
if (use_predicted_trajectory_ && !predicted_traj_ptr_) {
return missing("control predicted trajectory");
const bool has_predicted_path = std::invoke([&]() {
if (!use_predicted_trajectory_) {
return false;
}
predicted_traj_ptr_ = sub_predicted_traj_.takeData();
return (!predicted_traj_ptr_) ? missing("control predicted trajectory") : true;
});

if (!has_imu_path && !has_predicted_path) {
RCLCPP_INFO_SKIPFIRST_THROTTLE(
get_logger(), *get_clock(), 5000,
"[AEB] At least one path (IMU or predicted trajectory) is required for operation");
return false;

Check warning on line 374 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

AEB::fetchLatestData increases in cyclomatic complexity from 17 to 18, 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.

Check notice on line 374 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Bumpy Road Ahead

AEB::fetchLatestData decreases from 3 to 2 logical blocks with deeply nested code, threshold is one single block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
}

autoware_state_ = sub_autoware_state_.takeData();
Expand Down Expand Up @@ -482,7 +491,7 @@

// step3. make function to check collision with ego path created with sensor data
const auto has_collision_ego = [&](pcl::PointCloud<pcl::PointXYZ>::Ptr filtered_objects) -> bool {
if (!use_imu_path_) return false;
if (!use_imu_path_ || !angular_velocity_ptr_) return false;

Check warning on line 494 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

AEB::checkCollision increases in cyclomatic complexity from 19 to 20, 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.
const double current_w = angular_velocity_ptr_->z;
constexpr colorTuple debug_color = {0.0 / 256.0, 148.0 / 256.0, 205.0 / 256.0, 0.999};
const std::string ns = "ego";
Expand Down
Loading