@@ -130,11 +130,11 @@ std::optional<bool> isDrivingForwardWithTwist(const T & points_with_twist)
130
130
if (points_with_twist.size () == 1 ) {
131
131
if (0.0 < tier4_autoware_utils::getLongitudinalVelocity (points_with_twist.front ())) {
132
132
return true ;
133
- } else if (0.0 > tier4_autoware_utils::getLongitudinalVelocity (points_with_twist.front ())) {
133
+ }
134
+ if (0.0 > tier4_autoware_utils::getLongitudinalVelocity (points_with_twist.front ())) {
134
135
return false ;
135
- } else {
136
- return std::nullopt;
137
136
}
137
+ return std::nullopt;
138
138
}
139
139
140
140
return isDrivingForward (points_with_twist);
@@ -401,12 +401,12 @@ double calcLongitudinalOffsetToSegment(
401
401
const bool throw_exception = false )
402
402
{
403
403
if (seg_idx >= points.size () - 1 ) {
404
- const std::out_of_range e ( " Segment index is invalid." ) ;
404
+ const auto error_message{ " Segment index is invalid." } ;
405
405
tier4_autoware_utils::print_backtrace ();
406
406
if (throw_exception) {
407
- throw e ;
407
+ throw std::out_of_range (error_message) ;
408
408
}
409
- std::cerr << e. what () << std::endl;
409
+ std::cerr << error_message << std::endl;
410
410
return std::nan (" " );
411
411
}
412
412
@@ -424,12 +424,12 @@ double calcLongitudinalOffsetToSegment(
424
424
}
425
425
426
426
if (seg_idx >= overlap_removed_points.size () - 1 ) {
427
- const std::runtime_error e ( " Same points are given." ) ;
427
+ const auto error_message{ " Same points are given." } ;
428
428
tier4_autoware_utils::print_backtrace ();
429
429
if (throw_exception) {
430
- throw e ;
430
+ throw std::runtime_error (error_message) ;
431
431
}
432
- std::cerr << e. what () << std::endl;
432
+ std::cerr << error_message << std::endl;
433
433
return std::nan (" " );
434
434
}
435
435
@@ -581,12 +581,12 @@ double calcLateralOffset(
581
581
}
582
582
583
583
if (overlap_removed_points.size () == 1 ) {
584
- const std::runtime_error e ( " Same points are given." ) ;
584
+ const auto error_message{ " Same points are given." } ;
585
585
tier4_autoware_utils::print_backtrace ();
586
586
if (throw_exception) {
587
- throw e ;
587
+ throw std::runtime_error (error_message) ;
588
588
}
589
- std::cerr << e. what () << std::endl;
589
+ std::cerr << error_message << std::endl;
590
590
return std::nan (" " );
591
591
}
592
592
@@ -643,12 +643,12 @@ double calcLateralOffset(
643
643
}
644
644
645
645
if (overlap_removed_points.size () == 1 ) {
646
- const std::runtime_error e ( " Same points are given." ) ;
646
+ const auto error_message{ " Same points are given." } ;
647
647
tier4_autoware_utils::print_backtrace ();
648
648
if (throw_exception) {
649
- throw e ;
649
+ throw std::runtime_error (error_message) ;
650
650
}
651
- std::cerr << e. what () << std::endl;
651
+ std::cerr << error_message << std::endl;
652
652
return std::nan (" " );
653
653
}
654
654
@@ -968,17 +968,17 @@ std::vector<std::pair<double, double>> calcCurvatureAndArcLength(const T & point
968
968
{
969
969
// Note that arclength is for the segment, not the sum.
970
970
std::vector<std::pair<double , double >> curvature_arc_length_vec;
971
- curvature_arc_length_vec.push_back ( std::pair ( 0.0 , 0.0 ) );
971
+ curvature_arc_length_vec.emplace_back ( 0.0 , 0.0 );
972
972
for (size_t i = 1 ; i < points.size () - 1 ; ++i) {
973
973
const auto p1 = tier4_autoware_utils::getPoint (points.at (i - 1 ));
974
974
const auto p2 = tier4_autoware_utils::getPoint (points.at (i));
975
975
const auto p3 = tier4_autoware_utils::getPoint (points.at (i + 1 ));
976
976
const double curvature = tier4_autoware_utils::calcCurvature (p1, p2, p3);
977
977
const double arc_length = tier4_autoware_utils::calcDistance2d (points.at (i - 1 ), points.at (i)) +
978
978
tier4_autoware_utils::calcDistance2d (points.at (i), points.at (i + 1 ));
979
- curvature_arc_length_vec.push_back ( std::pair ( curvature, arc_length) );
979
+ curvature_arc_length_vec.emplace_back ( curvature, arc_length);
980
980
}
981
- curvature_arc_length_vec.push_back ( std::pair ( 0.0 , 0.0 ) );
981
+ curvature_arc_length_vec.emplace_back ( 0.0 , 0.0 );
982
982
983
983
return curvature_arc_length_vec;
984
984
}
@@ -1046,12 +1046,12 @@ std::optional<geometry_msgs::msg::Point> calcLongitudinalOffsetPoint(
1046
1046
}
1047
1047
1048
1048
if (points.size () - 1 < src_idx) {
1049
- const auto e = std::out_of_range ( " Invalid source index" ) ;
1049
+ const auto error_message{ " Invalid source index" } ;
1050
1050
tier4_autoware_utils::print_backtrace ();
1051
1051
if (throw_exception) {
1052
- throw e ;
1052
+ throw std::out_of_range (error_message) ;
1053
1053
}
1054
- std::cerr << e. what () << std::endl;
1054
+ std::cerr << error_message << std::endl;
1055
1055
return {};
1056
1056
}
1057
1057
@@ -1171,12 +1171,12 @@ std::optional<geometry_msgs::msg::Pose> calcLongitudinalOffsetPose(
1171
1171
}
1172
1172
1173
1173
if (points.size () - 1 < src_idx) {
1174
- const auto e = std::out_of_range ( " Invalid source index" ) ;
1174
+ const auto error_message{ " Invalid source index" } ;
1175
1175
tier4_autoware_utils::print_backtrace ();
1176
1176
if (throw_exception) {
1177
- throw e ;
1177
+ throw std::out_of_range (error_message) ;
1178
1178
}
1179
- std::cerr << e. what () << std::endl;
1179
+ std::cerr << error_message << std::endl;
1180
1180
return {};
1181
1181
}
1182
1182
@@ -2041,9 +2041,8 @@ size_t findFirstNearestIndexWithSoftConstraints(
2041
2041
if (squared_dist_threshold < squared_dist || yaw_threshold < std::abs (yaw)) {
2042
2042
if (is_within_constraints) {
2043
2043
break ;
2044
- } else {
2045
- continue ;
2046
2044
}
2045
+ continue ;
2047
2046
}
2048
2047
2049
2048
if (min_squared_dist <= squared_dist) {
@@ -2073,9 +2072,8 @@ size_t findFirstNearestIndexWithSoftConstraints(
2073
2072
if (squared_dist_threshold < squared_dist) {
2074
2073
if (is_within_constraints) {
2075
2074
break ;
2076
- } else {
2077
- continue ;
2078
2075
}
2076
+ continue ;
2079
2077
}
2080
2078
2081
2079
if (min_squared_dist <= squared_dist) {
@@ -2386,12 +2384,12 @@ double calcYawDeviation(
2386
2384
}
2387
2385
2388
2386
if (overlap_removed_points.size () <= 1 ) {
2389
- const std::runtime_error e ( " points size is less than 2" ) ;
2387
+ const auto error_message{ " points size is less than 2" } ;
2390
2388
tier4_autoware_utils::print_backtrace ();
2391
2389
if (throw_exception) {
2392
- throw e ;
2390
+ throw std::runtime_error (error_message) ;
2393
2391
}
2394
- std::cerr << e. what () << std::endl;
2392
+ std::cerr << error_message << std::endl;
2395
2393
return 0.0 ;
2396
2394
}
2397
2395
0 commit comments