Skip to content

Commit 5e65cc1

Browse files
committed
load projecter info from yaml file
1 parent 710cfee commit 5e65cc1

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

planning/autoware_static_centerline_generator/launch/static_centerline_generator.launch.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<arg name="centerline_source" default="optimization_trajectory_base" description="select from optimization_trajectory_base and bag_ego_trajectory_base"/>
99

1010
<!-- mandatory arguments when mode is AUTO -->
11-
<arg name="lanelet2_input_file_path" default=""/>
11+
<arg name="lanelet2_input_dir_path" default="/opt/autoware/maps"/>
1212
<arg name="lanelet2_output_file_path" default="/tmp/autoware_static_centerline_generator/lanelet2_map.osm"/>
1313
<arg name="start_lanelet_id" default="0"/>
1414
<arg name="start_pose" default="[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]"/>
@@ -69,7 +69,7 @@
6969
<remap from="input_centerline" to="~/input_centerline"/>
7070

7171
<param name="mode" value="$(var mode)"/>
72-
<param name="lanelet2_input_file_path" value="$(var lanelet2_input_file_path)"/>
72+
<param name="lanelet2_input_dir_path" value="$(var lanelet2_input_dir_path)"/>
7373
<param name="lanelet2_output_file_path" value="$(var lanelet2_output_file_path)"/>
7474
<param name="start_lanelet_id" value="$(var start_lanelet_id)"/>
7575
<param name="start_pose" value="$(var start_pose)"/>

planning/autoware_static_centerline_generator/src/static_centerline_generator_node.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
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()
332331
void 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_
526531
void 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;

planning/autoware_static_centerline_generator/src/static_centerline_generator_node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class StaticCenterlineGeneratorNode : public rclcpp::Node
125125

126126
private:
127127
// load map
128-
void load_map(const std::string & lanelet2_input_file_path);
128+
void load_map(const std::string & lanelet2_input_dir_path);
129129
void on_load_map(
130130
const LoadMap::Request::SharedPtr request, const LoadMap::Response::SharedPtr response);
131131

planning/autoware_static_centerline_generator/test/utils/test_static_centerline_generator_launch_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def generate_test_description_impl(
5151
launch_description.append(DeclareLaunchArgument("mode", default_value=mode))
5252
if map_path:
5353
launch_description.append(
54-
DeclareLaunchArgument("lanelet2_input_file_path", default_value=map_path)
54+
DeclareLaunchArgument("lanelet2_input_dir_path", default_value=map_path)
5555
)
5656
if centerline_source:
5757
launch_description.append(

0 commit comments

Comments
 (0)