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 no backward imu path and wrong back distance usage #9141

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
13 changes: 8 additions & 5 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.96 to 6.00, 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 All @@ -15,6 +15,7 @@
#include <autoware/autonomous_emergency_braking/node.hpp>
#include <autoware/autonomous_emergency_braking/utils.hpp>
#include <autoware/motion_utils/marker/marker_helper.hpp>
#include <autoware/motion_utils/trajectory/trajectory.hpp>
#include <autoware/universe_utils/geometry/boost_geometry.hpp>
#include <autoware/universe_utils/geometry/boost_polygon_utils.hpp>
#include <autoware/universe_utils/geometry/geometry.hpp>
Expand Down Expand Up @@ -642,7 +643,7 @@
ini_pose.orientation = autoware::universe_utils::createQuaternionFromYaw(curr_yaw);
path.push_back(ini_pose);
const double & dt = imu_prediction_time_interval_;
const double distance_between_points = curr_v * dt;
const double distance_between_points = std::abs(curr_v) * dt;
constexpr double minimum_distance_between_points{1e-2};
// if current velocity is too small, assume it stops at the same point
// if distance between points is too small, arc length calculation is unreliable, so we skip
Expand Down Expand Up @@ -887,40 +888,42 @@
if (ego_path.size() < 2 || points_belonging_to_cluster_hulls->empty()) {
return;
}

const auto ego_is_driving_forward_opt = autoware::motion_utils::isDrivingForward(ego_path);
if (!ego_is_driving_forward_opt.has_value()) {
return;
}
const bool ego_is_driving_forward = ego_is_driving_forward_opt.value();
// select points inside the ego footprint path
const auto current_p = [&]() {
const auto & first_point_of_path = ego_path.front();
const auto & p = first_point_of_path.position;
return autoware::universe_utils::createPoint(p.x, p.y, p.z);
}();

for (const auto & p : *points_belonging_to_cluster_hulls) {
const auto obj_position = autoware::universe_utils::createPoint(p.x, p.y, p.z);
const double obj_arc_length =
autoware::motion_utils::calcSignedArcLength(ego_path, current_p, obj_position);
if (std::isnan(obj_arc_length)) continue;

// calculate the lateral offset between the ego vehicle and the object
const double lateral_offset =
std::abs(autoware::motion_utils::calcLateralOffset(ego_path, obj_position));

if (std::isnan(lateral_offset)) continue;

// object is outside region of interest
if (
lateral_offset >
vehicle_info_.vehicle_width_m / 2.0 + expand_width_ + speed_calculation_expansion_margin_) {
continue;
}

// If the object is behind the ego, we need to use the backward long offset. The distance should
// be a positive number in any case
const bool is_object_in_front_of_ego = obj_arc_length > 0.0;
const double dist_ego_to_object = (is_object_in_front_of_ego)
const double dist_ego_to_object = (ego_is_driving_forward)
? obj_arc_length - vehicle_info_.max_longitudinal_offset_m
: obj_arc_length + vehicle_info_.min_longitudinal_offset_m;

Check warning on line 926 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::getClosestObjectsOnPath increases in cyclomatic complexity from 11 to 12, 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.

ObjectData obj;
obj.stamp = stamp;
obj.position = obj_position;
Expand Down
Loading