Skip to content

Commit bd81d4c

Browse files
tkimura4h-ohta
authored andcommitted
fix(accel_brake_map_calibrator): fix accel_brake_map_calibrator not to output invalid maps (autowarefoundation#6992)
Signed-off-by: tomoya.kimura <tomoya.kimura@tier4.jp>
1 parent a1762eb commit bd81d4c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

vehicle/accel_brake_map_calibrator/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -703,17 +703,19 @@ void AccelBrakeMapCalibrator::takeConsistencyOfAccelMap()
703703
{
704704
const double bit = std::pow(1e-01, precision_);
705705
for (std::size_t ped_idx = 0; ped_idx < update_accel_map_value_.size() - 1; ped_idx++) {
706-
for (std::size_t vel_idx = 0; vel_idx < update_accel_map_value_.at(0).size() - 1; vel_idx++) {
706+
for (std::size_t vel_idx = update_accel_map_value_.at(0).size() - 1;; vel_idx--) {
707+
if (vel_idx == 0) break;
708+
707709
const double current_acc = update_accel_map_value_.at(ped_idx).at(vel_idx);
708710
const double next_ped_acc = update_accel_map_value_.at(ped_idx + 1).at(vel_idx);
709-
const double next_vel_acc = update_accel_map_value_.at(ped_idx).at(vel_idx + 1);
711+
const double prev_vel_acc = update_accel_map_value_.at(ped_idx).at(vel_idx - 1);
710712

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

716-
if (current_acc >= next_ped_acc) {
718+
if (current_acc + bit >= next_ped_acc) {
717719
// the higher the accel pedal, the higher the acceleration
718720
update_accel_map_value_.at(ped_idx + 1).at(vel_idx) = current_acc + bit;
719721
}

0 commit comments

Comments
 (0)