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(autonomous_emergency_braking): fix debug marker visual bug #8611

Merged
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 @@ -156,10 +156,7 @@ class CollisionDataKeeper
* @brief Get the closest object data
* @return Object data of the closest object
*/
[[nodiscard]] ObjectData get() const
{
return (closest_object_.has_value()) ? closest_object_.value() : ObjectData();
}
[[nodiscard]] std::optional<ObjectData> get() const { return closest_object_; }

/**
* @brief Get the previous closest object data
Expand Down
25 changes: 15 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.68 to 5.74, 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 @@ -393,12 +393,15 @@
const auto diag_level = DiagnosticStatus::ERROR;
stat.summary(diag_level, error_msg);
const auto & data = collision_data_keeper_.get();
stat.addf("RSS", "%.2f", data.rss);
stat.addf("Distance", "%.2f", data.distance_to_object);
stat.addf("Object Speed", "%.2f", data.velocity);
if (publish_debug_markers_) {
addCollisionMarker(data, debug_markers);
if (data.has_value()) {
stat.addf("RSS", "%.2f", data.value().rss);
stat.addf("Distance", "%.2f", data.value().distance_to_object);
stat.addf("Object Speed", "%.2f", data.value().velocity);
if (publish_debug_markers_) {
addCollisionMarker(data.value(), debug_markers);
}
}

addVirtualStopWallMarker(info_markers);
} else {
const std::string error_msg = "[AEB]: No Collision";
Expand Down Expand Up @@ -476,17 +479,19 @@
return std::make_optional<ObjectData>(*closest_object_point_itr);
});

const bool has_collision = (closest_object_point.has_value())
? hasCollision(current_v, closest_object_point.value())
: false;

// Add debug markers
if (publish_debug_markers_) {
const auto [color_r, color_g, color_b, color_a] = debug_colors;
addMarker(
this->get_clock()->now(), path, ego_polys, objects, closest_object_point, color_r, color_g,
color_b, color_a, debug_ns, debug_markers);
this->get_clock()->now(), path, ego_polys, objects, collision_data_keeper_.get(), color_r,
color_g, color_b, color_a, debug_ns, debug_markers);
}
// check collision using rss distance
return (closest_object_point.has_value())
? hasCollision(current_v, closest_object_point.value())
: false;
return has_collision;

Check notice 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 already has high cyclomatic complexity, and now it increases in Lines of Code from 92 to 93. 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.
};

// step3. make function to check collision with ego path created with sensor data
Expand Down
Loading