Skip to content

Commit f97cdc0

Browse files
authored
fix(static_centerline_optimizer): fix latlon values of generated LL2 map (autowarefoundation#6727)
* fix(static_centerline_optimizer): fix lat/lon value of generated LL2 map Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> --------- Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 5617f74 commit f97cdc0

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

planning/static_centerline_optimizer/include/static_centerline_optimizer/static_centerline_optimizer_node.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "static_centerline_optimizer/type_alias.hpp"
2323
#include "vehicle_info_util/vehicle_info_util.hpp"
2424

25+
#include <geography_utils/lanelet2_projector.hpp>
26+
2527
#include "std_msgs/msg/bool.hpp"
2628
#include "std_msgs/msg/int32.hpp"
2729

@@ -69,6 +71,7 @@ class StaticCenterlineOptimizerNode : public rclcpp::Node
6971
lanelet::LaneletMapPtr original_map_ptr_{nullptr};
7072
HADMapBin::ConstSharedPtr map_bin_ptr_{nullptr};
7173
std::shared_ptr<RouteHandler> route_handler_ptr_{nullptr};
74+
std::unique_ptr<lanelet::Projector> map_projector_{nullptr};
7275

7376
int traj_start_index_{0};
7477
int traj_end_index_{0};

planning/static_centerline_optimizer/package.xml

+2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
<depend>autoware_auto_perception_msgs</depend>
2020
<depend>autoware_auto_planning_msgs</depend>
2121
<depend>behavior_path_planner_common</depend>
22+
<depend>geography_utils</depend>
2223
<depend>geometry_msgs</depend>
2324
<depend>global_parameter_loader</depend>
2425
<depend>interpolation</depend>
2526
<depend>lanelet2_extension</depend>
2627
<depend>map_loader</depend>
28+
<depend>map_projection_loader</depend>
2729
<depend>mission_planner</depend>
2830
<depend>motion_utils</depend>
2931
<depend>obstacle_avoidance_planner</depend>

planning/static_centerline_optimizer/src/static_centerline_optimizer_node.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "lanelet2_extension/utility/query.hpp"
1919
#include "lanelet2_extension/utility/utilities.hpp"
2020
#include "map_loader/lanelet2_map_loader_node.hpp"
21+
#include "map_projection_loader/load_info_from_lanelet2_map.hpp"
2122
#include "motion_utils/resample/resample.hpp"
2223
#include "motion_utils/trajectory/conversion.hpp"
2324
#include "obstacle_avoidance_planner/node.hpp"
@@ -28,6 +29,7 @@
2829
#include "tier4_autoware_utils/geometry/geometry.hpp"
2930
#include "tier4_autoware_utils/ros/parameter.hpp"
3031

32+
#include <geography_utils/lanelet2_projector.hpp>
3133
#include <mission_planner/mission_planner_plugin.hpp>
3234
#include <pluginlib/class_loader.hpp>
3335
#include <tier4_autoware_utils/ros/marker_helper.hpp>
@@ -331,14 +333,17 @@ void StaticCenterlineOptimizerNode::load_map(const std::string & lanelet2_input_
331333
// load map by the map_loader package
332334
map_bin_ptr_ = [&]() -> HADMapBin::ConstSharedPtr {
333335
// load map
334-
tier4_map_msgs::msg::MapProjectorInfo map_projector_info;
335-
map_projector_info.projector_type = tier4_map_msgs::msg::MapProjectorInfo::MGRS;
336+
const auto map_projector_info = load_info_from_lanelet2_map(lanelet2_input_file_path);
336337
const auto map_ptr =
337338
Lanelet2MapLoaderNode::load_map(lanelet2_input_file_path, map_projector_info);
338339
if (!map_ptr) {
339340
return nullptr;
340341
}
341342

343+
// NOTE: generate map projector for lanelet::write().
344+
// Without this, lat/lon of the generated LL2 map will be wrong.
345+
map_projector_ = geography_utils::get_lanelet2_projector(map_projector_info);
346+
342347
// NOTE: The original map is stored here since the various ids in the lanelet map will change
343348
// after lanelet::utils::overwriteLaneletCenterline, and saving map will fail.
344349
original_map_ptr_ =
@@ -750,7 +755,7 @@ void StaticCenterlineOptimizerNode::save_map(
750755
RCLCPP_INFO(get_logger(), "Updated centerline in map.");
751756

752757
// save map with modified center line
753-
lanelet::write(lanelet2_output_file_path, *original_map_ptr_);
758+
lanelet::write(lanelet2_output_file_path, *original_map_ptr_, *map_projector_);
754759
RCLCPP_INFO(get_logger(), "Saved map.");
755760
}
756761
} // namespace static_centerline_optimizer

0 commit comments

Comments
 (0)