Skip to content

Commit 3cfb03e

Browse files
authored
fix(static_centerline_generator): several bug fixes (#9426)
* fix: dependent packages Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * feat: use steer angle, use warn for steer angle failure, calc curvature dicontinuously Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix cppcheck Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> --------- Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 53aaf0f commit 3cfb03e

File tree

5 files changed

+42
-21
lines changed

5 files changed

+42
-21
lines changed

common/autoware_vehicle_info_utils/include/autoware_vehicle_info_utils/vehicle_info.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct VehicleInfo
7171

7272
double calcMaxCurvature() const;
7373
double calcCurvatureFromSteerAngle(const double steer_angle) const;
74+
double calcSteerAngleFromCurvature(const double curvature) const;
7475
};
7576

7677
/// Create vehicle info from base parameters

common/autoware_vehicle_info_utils/src/vehicle_info.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,15 @@ double VehicleInfo::calcCurvatureFromSteerAngle(const double steer_angle) const
129129
const double curvature = 1.0 / radius;
130130
return curvature;
131131
}
132+
133+
double VehicleInfo::calcSteerAngleFromCurvature(const double curvature) const
134+
{
135+
if (std::abs(curvature) < 1e-6) {
136+
return 0.0;
137+
}
138+
139+
const double radius = 1.0 / curvature;
140+
const double steer_angle = std::atan2(wheel_base_m, radius);
141+
return steer_angle;
142+
}
132143
} // namespace autoware::vehicle_info_utils

planning/autoware_static_centerline_generator/launch/static_centerline_generator.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</node>
4949

5050
<!-- visualize map -->
51-
<node pkg="map_loader" exec="lanelet2_map_visualization" name="lanelet2_map_visualization">
51+
<node pkg="autoware_lanelet2_map_visualizer" exec="lanelet2_map_visualization" name="lanelet2_map_visualization">
5252
<remap from="input/lanelet2_map" to="$(var lanelet2_map_topic)"/>
5353
<remap from="output/lanelet2_map_marker" to="$(var lanelet2_map_marker_topic)"/>
5454
</node>

planning/autoware_static_centerline_generator/package.xml

+2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
<depend>autoware_global_parameter_loader</depend>
2121
<depend>autoware_interpolation</depend>
2222
<depend>autoware_lanelet2_extension</depend>
23+
<depend>autoware_lanelet2_map_visualizer</depend>
2324
<depend>autoware_map_loader</depend>
2425
<depend>autoware_map_msgs</depend>
2526
<depend>autoware_map_projection_loader</depend>
27+
<depend>autoware_map_tf_generator</depend>
2628
<depend>autoware_mission_planner</depend>
2729
<depend>autoware_motion_utils</depend>
2830
<depend>autoware_osqp_interface</depend>

planning/autoware_static_centerline_generator/src/static_centerline_generator_node.cpp

+27-20
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414

1515
#include "static_centerline_generator_node.hpp"
1616

17-
#include "autoware/interpolation/spline_interpolation_points_2d.hpp"
1817
#include "autoware/map_loader/lanelet2_map_loader_node.hpp"
1918
#include "autoware/map_projection_loader/load_info_from_lanelet2_map.hpp"
2019
#include "autoware/map_projection_loader/map_projection_loader.hpp"
2120
#include "autoware/motion_utils/resample/resample.hpp"
2221
#include "autoware/motion_utils/trajectory/conversion.hpp"
22+
#include "autoware/motion_utils/trajectory/trajectory.hpp"
2323
#include "autoware/universe_utils/geometry/geometry.hpp"
24+
#include "autoware/universe_utils/math/unit_conversion.hpp"
2425
#include "autoware/universe_utils/ros/parameter.hpp"
2526
#include "autoware_lanelet2_extension/utility/message_conversion.hpp"
2627
#include "autoware_lanelet2_extension/utility/query.hpp"
@@ -59,6 +60,7 @@
5960

6061
#define RESET_TEXT "\x1B[0m"
6162
#define RED_TEXT "\x1B[31m"
63+
#define YELLOW_TEXT "\x1b[33m"
6264
#define BOLD_TEXT "\x1B[1m"
6365

6466
namespace autoware::static_centerline_generator
@@ -626,10 +628,8 @@ void StaticCenterlineGeneratorNode::validate()
626628
}
627629

628630
// calculate curvature
629-
autoware::interpolation::SplineInterpolationPoints2d centerline_spline(centerline);
630-
const auto curvature_vec = centerline_spline.getSplineInterpolatedCurvatures();
631-
const double curvature_threshold = vehicle_info_.calcCurvatureFromSteerAngle(
632-
vehicle_info_.max_steer_angle_rad - max_steer_angle_margin);
631+
const auto curvature_vec = autoware::motion_utils::calcCurvature(centerline);
632+
const double steer_angle_threshold = vehicle_info_.max_steer_angle_rad - max_steer_angle_margin;
633633

634634
// calculate the distance between footprint and right/left bounds
635635
MarkerArray marker_array;
@@ -676,6 +676,7 @@ void StaticCenterlineGeneratorNode::validate()
676676
max_curvature = std::abs(curvature);
677677
}
678678
}
679+
const double max_steer_angle = vehicle_info_.calcSteerAngleFromCurvature(max_curvature);
679680

680681
// publish road boundaries
681682
const auto left_bound = convertToGeometryPoints(lanelet_left_bound);
@@ -693,30 +694,36 @@ void StaticCenterlineGeneratorNode::validate()
693694
std::cerr << "1. Footprints inside Lanelets:" << std::endl;
694695
if (dist_thresh_to_road_border < min_dist) {
695696
std::cerr << " The generated centerline is inside the lanelet. (threshold:"
696-
<< dist_thresh_to_road_border << " < actual:" << min_dist << ")" << std::endl
697+
<< dist_thresh_to_road_border << "[m] < actual:" << min_dist << "[m])" << std::endl
697698
<< " Passed." << std::endl;
698699
return true;
699700
}
700701
std::cerr << RED_TEXT
701702
<< " The generated centerline is outside the lanelet. (actual:" << min_dist
702-
<< " <= threshold:" << dist_thresh_to_road_border << ")" << std::endl
703+
<< "[m] <= threshold:" << dist_thresh_to_road_border << "[m])" << std::endl
703704
<< " Failed." << RESET_TEXT << std::endl;
704705
return false;
705706
}();
706707
// 2. centerline's curvature
707-
const bool is_curvature_low = [&]() {
708-
std::cerr << "2. Curvature:" << std::endl;
709-
if (max_curvature < curvature_threshold) {
710-
std::cerr << " The generated centerline has no high curvature. (actual:" << max_curvature
711-
<< " < threshold:" << curvature_threshold << ")"
712-
<< " Passed." << std::endl;
713-
return true;
714-
}
715-
std::cerr << RED_TEXT << " The generated centerline has a too high curvature. (threshold:"
716-
<< curvature_threshold << " <= actual:" << max_curvature << ")"
717-
<< " Failed." << RESET_TEXT << std::endl;
718-
return false;
719-
}();
708+
std::cerr << "2. Curvature:" << std::endl;
709+
const bool is_curvature_low =
710+
true; // always tre for now since the curvature is just estimated and not enough precise.
711+
if (max_steer_angle < steer_angle_threshold) {
712+
std::cerr << " The generated centerline has no high steer angle. (estimated:"
713+
<< autoware::universe_utils::rad2deg(max_steer_angle)
714+
<< "[deg] < threshold:" << autoware::universe_utils::rad2deg(steer_angle_threshold)
715+
<< "[deg])" << std::endl
716+
<< " Passed." << std::endl;
717+
} else {
718+
std::cerr << YELLOW_TEXT << " The generated centerline has a too high steer angle. (threshold:"
719+
<< autoware::universe_utils::rad2deg(steer_angle_threshold)
720+
<< "[deg] <= estimated:" << autoware::universe_utils::rad2deg(max_steer_angle)
721+
<< "[deg])" << std::endl
722+
<< " However, the estimated steer angle is not enough precise, so the result is "
723+
"conditional pass."
724+
<< std::endl
725+
<< " Conditionally Passed." << RESET_TEXT << std::endl;
726+
}
720727
// 3. result
721728
std::cerr << std::endl << BOLD_TEXT << "Result:" << RESET_TEXT << std::endl;
722729
if (are_footprints_inside_lanelets && is_curvature_low) {

0 commit comments

Comments
 (0)