Skip to content

Commit 84f242b

Browse files
committed
fix new cppcheck warnings
Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
1 parent 4e90378 commit 84f242b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

perception/autoware_map_based_prediction/src/map_based_prediction_node.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ std::vector<PredictedRefPath> MapBasedPredictionNode::getPredictedReferencePath(
17761776
auto get_search_distance_with_decaying_acc = [&]() -> double {
17771777
const double acceleration_distance =
17781778
obj_acc * (1.0 / lambda) * t_h +
1779-
obj_acc * (1.0 / std::pow(lambda, 2)) * (std::exp(-lambda * t_h) - 1);
1779+
obj_acc * (1.0 / std::pow(lambda, 2)) * std::expm1(-lambda * t_h);
17801780
double search_dist = acceleration_distance + obj_vel * t_h;
17811781
return search_dist;
17821782
};
@@ -1794,7 +1794,7 @@ std::vector<PredictedRefPath> MapBasedPredictionNode::getPredictedReferencePath(
17941794
const double search_dist =
17951795
// Distance covered while accelerating
17961796
obj_acc * (1.0 / lambda) * t_f +
1797-
obj_acc * (1.0 / std::pow(lambda, 2)) * (std::exp(-lambda * t_f) - 1) + obj_vel * t_f +
1797+
obj_acc * (1.0 / std::pow(lambda, 2)) * std::expm1(-lambda * t_f) + obj_vel * t_f +
17981798
// Distance covered at constant speed
17991799
final_speed * (t_h - t_f);
18001800
return search_dist;

perception/autoware_map_based_prediction/src/path_generator.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,12 @@ FrenetPoint PathGenerator::getFrenetPoint(
447447
// e^(-lambda t_stop) = 1 - (-Vo* lambda)/acc
448448
// t_stop = (-1/lambda)*ln(1 - (-Vo* lambda)/acc)
449449
// t_stop = (-1/lambda)*ln(1 + (Vo* lambda)/acc)
450-
auto t_stop = (-1.0 / lambda) * std::log(1 + (v * lambda / a));
450+
auto t_stop = (-1.0 / lambda) * std::log1p(v * lambda / a);
451451

452452
// Calculate the distance traveled until stopping
453453
auto distance_to_reach_zero_speed =
454454
v * t_stop + a * t_stop * (1.0 / lambda) +
455-
a * (1.0 / std::pow(lambda, 2)) * (std::exp(-lambda * t_h) - 1);
455+
a * (1.0 / std::pow(lambda, 2)) * std::expm1(-lambda * t_h);
456456
// Output an equivalent constant speed
457457
return distance_to_reach_zero_speed / t_h;
458458
}
@@ -463,7 +463,7 @@ FrenetPoint PathGenerator::getFrenetPoint(
463463
const bool object_has_surpassed_limit_already = v > speed_limit;
464464
if (terminal_velocity < speed_limit || object_has_surpassed_limit_already)
465465
return v + a * (1.0 / lambda) +
466-
(a / (t_h * std::pow(lambda, 2))) * (std::exp(-lambda * t_h) - 1);
466+
(a / (t_h * std::pow(lambda, 2))) * std::expm1(-lambda * t_h);
467467

468468
// It is assumed the vehicle accelerates until final_speed is reached and
469469
// then continues at constant speed for the rest of the time horizon
@@ -473,7 +473,7 @@ FrenetPoint PathGenerator::getFrenetPoint(
473473
const double t_f = (-1.0 / lambda) * std::log(1 - ((speed_limit - v) * lambda) / a);
474474
const double distance_covered =
475475
// Distance covered while accelerating
476-
a * (1.0 / lambda) * t_f + a * (1.0 / std::pow(lambda, 2)) * (std::exp(-lambda * t_f) - 1) +
476+
a * (1.0 / lambda) * t_f + a * (1.0 / std::pow(lambda, 2)) * std::expm1(-lambda * t_f) +
477477
v * t_f +
478478
// Distance covered at constant speed for the rest of the horizon time
479479
speed_limit * (t_h - t_f);

0 commit comments

Comments
 (0)