@@ -38,11 +38,6 @@ Lanelet2DifferentialLoaderModule::Lanelet2DifferentialLoaderModule(
38
38
std::bind (
39
39
&Lanelet2DifferentialLoaderModule::onServiceGetDifferentialLanelet2Map, this ,
40
40
std::placeholders::_1, std::placeholders::_2));
41
-
42
- pub_map_bin_ = node->create_publisher <HADMapBin>(
43
- " /map/differential_lanelet2_map_bin" , rclcpp::QoS{1 }.transient_local ());
44
- pub_map_bin_debug_ =
45
- node->create_publisher <HADMapBin>(" /map/vector_map" , rclcpp::QoS{1 }.transient_local ());
46
41
}
47
42
48
43
bool Lanelet2DifferentialLoaderModule::onServiceGetDifferentialLanelet2Map (
@@ -53,7 +48,6 @@ bool Lanelet2DifferentialLoaderModule::onServiceGetDifferentialLanelet2Map(
53
48
RCLCPP_ERROR (logger_, " Failed to load differential lanelet2 map" );
54
49
return false ;
55
50
}
56
- res->header .stamp = clock_->now ();
57
51
res->header .frame_id = " map" ;
58
52
59
53
return true ;
@@ -63,101 +57,58 @@ bool Lanelet2DifferentialLoaderModule::differentialLanelet2Load(
63
57
GetDifferentialLanelet2Map::Request::SharedPtr & request,
64
58
GetDifferentialLanelet2Map::Response::SharedPtr & response)
65
59
{
66
- {
67
- std::vector<std::string> lanelet2_paths;
68
- for (const auto & path : lanelet2_file_metadata_dict_) {
69
- if (!std::filesystem::exists (path.first )) {
70
- continue ;
71
- }
72
- lanelet2_paths.push_back (path.first );
60
+ // check osm ids
61
+ std::vector<std::string> lanelet2_paths;
62
+ for (const auto & id : request->osm_file_ids ) {
63
+ auto it = std::find_if (
64
+ lanelet2_file_metadata_dict_.begin (), lanelet2_file_metadata_dict_.end (),
65
+ [&id](const auto & file) { return file.second .id == id; });
66
+ if (it == lanelet2_file_metadata_dict_.end ()) {
67
+ continue ;
73
68
}
74
- if (lanelet2_paths. empty ( )) {
75
- return false ;
69
+ if (! std::filesystem::exists (it-> first )) {
70
+ continue ;
76
71
}
72
+ lanelet2_paths.push_back (it->first );
73
+ }
74
+ if (lanelet2_paths.empty ()) {
75
+ return false ;
76
+ }
77
+
78
+ // create parser and load map
79
+ lanelet::ErrorMessages errors{};
80
+ lanelet::projection::MGRSProjector projector{};
81
+ lanelet::io_handlers::MultiOsmParser parser (projector);
82
+ lanelet::LaneletMapPtr map = parser.parse (lanelet2_paths, errors);
77
83
78
- lanelet::ErrorMessages errors{};
79
- lanelet::projection::MGRSProjector projector{};
80
- lanelet::io_handlers::MultiOsmParser parser (projector, {});
81
- lanelet::LaneletMapPtr map = parser.parse (lanelet2_paths, errors);
82
-
83
- for (lanelet::Point3d point : map->pointLayer ) {
84
- if (point.hasAttribute (" local_x" )) {
85
- point.x () = point.attribute (" local_x" ).asDouble ().value ();
86
- }
87
- if (point.hasAttribute (" local_y" )) {
88
- point.y () = point.attribute (" local_y" ).asDouble ().value ();
89
- }
84
+ for (lanelet::Point3d point : map->pointLayer ) {
85
+ if (point.hasAttribute (" local_x" )) {
86
+ point.x () = point.attribute (" local_x" ).asDouble ().value ();
90
87
}
91
- // realign lanelet borders using updated points
92
- for (lanelet::Lanelet lanelet : map->laneletLayer ) {
93
- auto left = lanelet.leftBound ();
94
- auto right = lanelet.rightBound ();
95
- std::tie (left, right) = lanelet::geometry::align (left, right);
96
- lanelet.setLeftBound (left);
97
- lanelet.setRightBound (right);
88
+ if (point.hasAttribute (" local_y" )) {
89
+ point.y () = point.attribute (" local_y" ).asDouble ().value ();
98
90
}
99
- // overwrite centerline
100
- lanelet::utils::overwriteLaneletsCenterline (map, 5.0 , false );
101
- // convert map to binary message
102
- {
103
- const auto map_bin_msg =
104
- Lanelet2MapLoaderNode::create_map_bin_msg (map, lanelet2_paths[0 ], rclcpp::Clock ().now ());
105
-
106
- pub_map_bin_debug_->publish (map_bin_msg);
107
- } // convert map to binary message end
108
91
}
109
92
93
+ // realign lanelet borders using updated points
94
+ for (lanelet::Lanelet lanelet : map->laneletLayer ) {
95
+ auto left = lanelet.leftBound ();
96
+ auto right = lanelet.rightBound ();
97
+ std::tie (left, right) = lanelet::geometry::align (left, right);
98
+ lanelet.setLeftBound (left);
99
+ lanelet.setRightBound (right);
100
+ }
101
+
102
+ // overwrite centerline
103
+ lanelet::utils::overwriteLaneletsCenterline (map, 5.0 , false );
104
+ // convert map to binary message
110
105
{
111
- std::vector<std::string> lanelet2_paths;
112
- for (const auto & id : request->osm_file_ids ) {
113
- auto it = std::find_if (
114
- lanelet2_file_metadata_dict_.begin (), lanelet2_file_metadata_dict_.end (),
115
- [&id](const auto & file) { return file.second .id == id; });
116
- if (it == lanelet2_file_metadata_dict_.end ()) {
117
- continue ;
118
- }
119
- if (!std::filesystem::exists (it->first )) {
120
- continue ;
121
- }
122
- lanelet2_paths.push_back (it->first );
123
- }
124
- if (lanelet2_paths.empty ()) {
125
- return false ;
126
- }
106
+ const auto map_bin_msg =
107
+ Lanelet2MapLoaderNode::create_map_bin_msg (map, lanelet2_paths[0 ], rclcpp::Clock ().now ());
127
108
128
- lanelet::ErrorMessages errors{};
129
- lanelet::projection::MGRSProjector projector{};
130
- lanelet::io_handlers::MultiOsmParser parser (projector);
131
- lanelet::LaneletMapPtr map = parser.parse (lanelet2_paths, errors);
132
-
133
- for (lanelet::Point3d point : map->pointLayer ) {
134
- if (point.hasAttribute (" local_x" )) {
135
- point.x () = point.attribute (" local_x" ).asDouble ().value ();
136
- }
137
- if (point.hasAttribute (" local_y" )) {
138
- point.y () = point.attribute (" local_y" ).asDouble ().value ();
139
- }
140
- }
141
- // realign lanelet borders using updated points
142
- for (lanelet::Lanelet lanelet : map->laneletLayer ) {
143
- auto left = lanelet.leftBound ();
144
- auto right = lanelet.rightBound ();
145
- std::tie (left, right) = lanelet::geometry::align (left, right);
146
- lanelet.setLeftBound (left);
147
- lanelet.setRightBound (right);
148
- }
149
- // overwrite centerline
150
- lanelet::utils::overwriteLaneletsCenterline (map, 5.0 , false );
151
- // convert map to binary message
152
- {
153
- const auto map_bin_msg =
154
- Lanelet2MapLoaderNode::create_map_bin_msg (map, lanelet2_paths[0 ], rclcpp::Clock ().now ());
155
-
156
- pub_map_bin_->publish (map_bin_msg);
157
- response->differential_map = map_bin_msg;
158
- }
109
+ pub_map_bin_->publish (map_bin_msg);
110
+ response->differential_map = map_bin_msg;
159
111
}
160
-
161
112
return true ;
162
113
}
163
114
@@ -166,10 +117,6 @@ Lanelet2DifferentialLoaderModule::getLaneletMapMetaDataMsg() const
166
117
{
167
118
autoware_map_msgs::msg::LaneletMapMetaData metadata;
168
119
for (const auto & file : lanelet2_file_metadata_dict_) {
169
- std::cout << " ----------------" << std::endl;
170
- std::cout << file.first << std::endl;
171
- std::cout << file.second .id << std::endl;
172
-
173
120
autoware_map_msgs::msg::LaneletMapTileMetaData tile_msg;
174
121
tile_msg.mgrs_code = file.second .mgrs_code ;
175
122
tile_msg.origin_lat = file.second .origin_lat ;
0 commit comments