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(accel_brake_map_calibrator): fix accel_brake_map_calibrator not to output invalid maps #6992

Merged
merged 1 commit into from
May 13, 2024
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//

Check notice on line 1 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.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 1361 to 1362, 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.

Check notice on line 1 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_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 4.04 to 4.06, 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.
// Copyright 2020 Tier IV, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -703,17 +703,19 @@
{
const double bit = std::pow(1e-01, precision_);
for (std::size_t ped_idx = 0; ped_idx < update_accel_map_value_.size() - 1; ped_idx++) {
for (std::size_t vel_idx = 0; vel_idx < update_accel_map_value_.at(0).size() - 1; vel_idx++) {
for (std::size_t vel_idx = update_accel_map_value_.at(0).size() - 1;; vel_idx--) {
if (vel_idx == 0) break;

const double current_acc = update_accel_map_value_.at(ped_idx).at(vel_idx);
const double next_ped_acc = update_accel_map_value_.at(ped_idx + 1).at(vel_idx);
const double next_vel_acc = update_accel_map_value_.at(ped_idx).at(vel_idx + 1);
const double prev_vel_acc = update_accel_map_value_.at(ped_idx).at(vel_idx - 1);

if (current_acc <= next_vel_acc) {
if (current_acc + bit >= prev_vel_acc) {
// the higher the velocity, the lower the acceleration
update_accel_map_value_.at(ped_idx).at(vel_idx + 1) = current_acc - bit;
update_accel_map_value_.at(ped_idx).at(vel_idx - 1) = current_acc + bit;
}

if (current_acc >= next_ped_acc) {
if (current_acc + bit >= next_ped_acc) {
// the higher the accel pedal, the higher the acceleration
update_accel_map_value_.at(ped_idx + 1).at(vel_idx) = current_acc + bit;
}
Expand Down
Loading