1515#include " static_centerline_generator_node.hpp"
1616
1717#include " autoware/map_loader/lanelet2_map_loader_node.hpp"
18- #include " autoware/map_projection_loader/load_info_from_lanelet2_map.hpp"
1918#include " autoware/map_projection_loader/map_projection_loader.hpp"
2019#include " autoware/motion_utils/resample/resample.hpp"
2120#include " autoware/motion_utils/trajectory/conversion.hpp"
@@ -332,13 +331,13 @@ void StaticCenterlineGeneratorNode::visualize_selected_centerline()
332331void StaticCenterlineGeneratorNode::generate_centerline ()
333332{
334333 // declare planning setting parameters
335- const auto lanelet2_input_file_path = declare_parameter<std::string>(" lanelet2_input_file_path " );
336- if (lanelet2_input_file_path == " " ) {
337- throw std::invalid_argument (" The `lanelet2_input_file_path ` is empty." );
334+ const auto lanelet2_input_dir_path = declare_parameter<std::string>(" lanelet2_input_dir_path " );
335+ if (lanelet2_input_dir_path == " " ) {
336+ throw std::invalid_argument (" The `lanelet2_input_dir_path ` is empty. Please set a directory path. (Not a file path) " );
338337 }
339338
340339 // process
341- load_map (lanelet2_input_file_path );
340+ load_map (lanelet2_input_dir_path );
342341 const auto whole_centerline_with_route = generate_whole_centerline_with_route ();
343342 centerline_handler_ = CenterlineHandler (whole_centerline_with_route);
344343
@@ -471,38 +470,44 @@ CenterlineWithRoute StaticCenterlineGeneratorNode::generate_whole_centerline_wit
471470 return centerline_with_route;
472471}
473472
474- void StaticCenterlineGeneratorNode::load_map (const std::string & lanelet2_input_file_path )
473+ void StaticCenterlineGeneratorNode::load_map (const std::string & lanelet2_input_dir_path )
475474{
475+ // construct file paths from directory path
476+ const std::string lanelet2_map_file_path = lanelet2_input_dir_path + " /lanelet2_map.osm" ;
477+ const std::string map_projector_info_file_path =
478+ lanelet2_input_dir_path + " /map_projector_info.yaml" ;
479+
476480 // copy the input LL2 map to the temporary file for debugging
477481 const std::string debug_input_file_dir{" /tmp/autoware_static_centerline_generator/input/" };
478482 std::filesystem::create_directories (debug_input_file_dir);
479483 std::filesystem::copy (
480- lanelet2_input_file_path , debug_input_file_dir + " lanelet2_map.osm" ,
484+ lanelet2_map_file_path , debug_input_file_dir + " lanelet2_map.osm" ,
481485 std::filesystem::copy_options::overwrite_existing);
482486
483487 // load map by the map_loader package
484488 map_bin_ptr_ = [&]() -> LaneletMapBin::ConstSharedPtr {
485- // load map
489+ // load map projector info
486490 map_projector_info_ = std::make_unique<MapProjectorInfo>(
487- autoware::map_projection_loader::load_info_from_lanelet2_map (lanelet2_input_file_path));
491+ autoware::map_projection_loader::load_map_projector_info (
492+ map_projector_info_file_path, lanelet2_map_file_path));
488493 const auto map_ptr = autoware::map_loader::Lanelet2MapLoaderNode::load_map (
489- lanelet2_input_file_path , *map_projector_info_);
494+ lanelet2_map_file_path , *map_projector_info_);
490495 if (!map_ptr) {
491496 return nullptr ;
492497 }
493498
494499 // NOTE: The original map is stored here since the centerline will be added to all the
495500 // lanelet when lanelet::utils::overwriteLaneletCenterline is called.
496501 original_map_ptr_ = autoware::map_loader::Lanelet2MapLoaderNode::load_map (
497- lanelet2_input_file_path , *map_projector_info_);
502+ lanelet2_map_file_path , *map_projector_info_);
498503
499504 // overwrite more dense centerline
500505 // NOTE: overwriteLaneletsCenterlineWithWaypoints is used only in real time calculation.
501506 lanelet::utils::overwriteLaneletsCenterline (map_ptr, 5.0 , false );
502507
503508 // create map bin msg
504509 const auto map_bin_msg = autoware::map_loader::Lanelet2MapLoaderNode::create_map_bin_msg (
505- map_ptr, lanelet2_input_file_path , now ());
510+ map_ptr, lanelet2_map_file_path , now ());
506511
507512 return std::make_shared<LaneletMapBin>(map_bin_msg);
508513 }();
@@ -526,16 +531,20 @@ void StaticCenterlineGeneratorNode::load_map(const std::string & lanelet2_input_
526531void StaticCenterlineGeneratorNode::on_load_map (
527532 const LoadMap::Request::SharedPtr request, const LoadMap::Response::SharedPtr response)
528533{
529- const std::string tmp_lanelet2_input_file_path = " /tmp/input_lanelet2_map.osm" ;
534+ const std::string tmp_lanelet2_input_dir_path = " /tmp/input_lanelet2_map" ;
535+ const std::string tmp_lanelet2_input_file_path = tmp_lanelet2_input_dir_path + " /lanelet2_map.osm" ;
536+
537+ // create temporary directory
538+ std::filesystem::create_directories (tmp_lanelet2_input_dir_path);
530539
531- // save map file temporarily since load map's input must be a file
540+ // save map file temporarily since load map's input must be a directory
532541 std::ofstream map_writer;
533542 map_writer.open (tmp_lanelet2_input_file_path, std::ios::out);
534543 map_writer << request->map ;
535544 map_writer.close ();
536545
537- // load map from the saved map file
538- load_map (tmp_lanelet2_input_file_path );
546+ // load map from the saved map directory
547+ load_map (tmp_lanelet2_input_dir_path );
539548
540549 if (map_bin_ptr_) {
541550 return ;
0 commit comments