@@ -74,10 +74,19 @@ std::set<int64_t> getCrosswalkIdSetOnPath(
74
74
75
75
return crosswalk_id_set;
76
76
}
77
+
78
+ bool checkRegulatoryElementExistence (const lanelet::LaneletMapPtr & lanelet_map_ptr)
79
+ {
80
+ const auto all_lanelets = lanelet::utils::query::laneletLayer (lanelet_map_ptr);
81
+ return !lanelet::utils::query::crosswalks (all_lanelets).empty ();
82
+ }
77
83
} // namespace
78
84
79
85
namespace behavior_velocity_planner
80
86
{
87
+
88
+ using lanelet::autoware::Crosswalk;
89
+
81
90
CrosswalkModuleManager::CrosswalkModuleManager (rclcpp::Node & node)
82
91
: SceneModuleManagerInterfaceWithRTC(node, getModuleName())
83
92
{
@@ -128,17 +137,43 @@ CrosswalkModuleManager::CrosswalkModuleManager(rclcpp::Node & node)
128
137
void CrosswalkModuleManager::launchNewModules (const PathWithLaneId & path)
129
138
{
130
139
const auto rh = planner_data_->route_handler_ ;
131
- for (const auto & crosswalk : getCrosswalksOnPath (
132
- planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (),
133
- rh->getOverallGraphPtr ())) {
134
- const auto module_id = crosswalk.id ();
135
- if (!isModuleRegistered (module_id)) {
136
- registerModule (std::make_shared<CrosswalkModule>(
137
- module_id, crosswalk, crosswalk_planner_param_, logger_.get_child (" crosswalk_module" ),
138
- clock_));
139
- generateUUID (module_id);
140
- updateRTCStatus (
141
- getUUID (module_id), true , std::numeric_limits<double >::lowest (), path.header .stamp );
140
+ if (!opt_use_regulatory_element_) {
141
+ opt_use_regulatory_element_ = checkRegulatoryElementExistence (rh->getLaneletMapPtr ());
142
+ std::ostringstream string_stream;
143
+ string_stream << " use crosswalk regulatory element: " ;
144
+ string_stream << std::boolalpha << opt_use_regulatory_element_.get ();
145
+ RCLCPP_INFO_STREAM (logger_, string_stream.str ());
146
+ }
147
+
148
+ const auto launch = [this , &path](const auto id) {
149
+ if (isModuleRegistered (id)) {
150
+ return ;
151
+ }
152
+
153
+ const auto & p = crosswalk_planner_param_;
154
+ const auto logger = logger_.get_child (" crosswalk_module" );
155
+ const auto lanelet_map_ptr = planner_data_->route_handler_ ->getLaneletMapPtr ();
156
+
157
+ registerModule (std::make_shared<CrosswalkModule>(
158
+ id, lanelet_map_ptr, p, opt_use_regulatory_element_.get (), logger, clock_));
159
+ generateUUID (id);
160
+ updateRTCStatus (getUUID (id), true , std::numeric_limits<double >::lowest (), path.header .stamp );
161
+ };
162
+
163
+ if (opt_use_regulatory_element_.get ()) {
164
+ const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
165
+ path, rh->getLaneletMapPtr (), planner_data_->current_odometry ->pose );
166
+
167
+ for (const auto & crosswalk : crosswalk_leg_elem_map) {
168
+ launch (crosswalk.first ->id ());
169
+ }
170
+ } else {
171
+ const auto crosswalk_lanelets = getCrosswalksOnPath (
172
+ planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (),
173
+ rh->getOverallGraphPtr ());
174
+
175
+ for (const auto & crosswalk : crosswalk_lanelets) {
176
+ launch (crosswalk.id ());
142
177
}
143
178
}
144
179
}
@@ -147,8 +182,21 @@ std::function<bool(const std::shared_ptr<SceneModuleInterface> &)>
147
182
CrosswalkModuleManager::getModuleExpiredFunction (const PathWithLaneId & path)
148
183
{
149
184
const auto rh = planner_data_->route_handler_ ;
150
- const auto crosswalk_id_set = getCrosswalkIdSetOnPath (
151
- planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (), rh->getOverallGraphPtr ());
185
+
186
+ std::set<int64_t > crosswalk_id_set;
187
+
188
+ if (opt_use_regulatory_element_.get ()) {
189
+ const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
190
+ path, rh->getLaneletMapPtr (), planner_data_->current_odometry ->pose );
191
+
192
+ for (const auto & crosswalk : crosswalk_leg_elem_map) {
193
+ crosswalk_id_set.insert (crosswalk.first ->id ());
194
+ }
195
+ } else {
196
+ crosswalk_id_set = getCrosswalkIdSetOnPath (
197
+ planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (),
198
+ rh->getOverallGraphPtr ());
199
+ }
152
200
153
201
return [crosswalk_id_set](const std::shared_ptr<SceneModuleInterface> & scene_module) {
154
202
return crosswalk_id_set.count (scene_module->getModuleId ()) == 0 ;
@@ -166,31 +214,69 @@ WalkwayModuleManager::WalkwayModuleManager(rclcpp::Node & node)
166
214
wp.stop_duration_sec = node.declare_parameter <double >(ns + " .stop_duration_sec" );
167
215
}
168
216
169
- void WalkwayModuleManager::launchNewModules (
170
- const autoware_auto_planning_msgs::msg::PathWithLaneId & path)
217
+ void WalkwayModuleManager::launchNewModules (const PathWithLaneId & path)
171
218
{
172
219
const auto rh = planner_data_->route_handler_ ;
173
- for (const auto & crosswalk : getCrosswalksOnPath (
174
- planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (),
175
- rh->getOverallGraphPtr ())) {
176
- const auto module_id = crosswalk.id ();
177
- if (
178
- !isModuleRegistered (module_id) &&
179
- crosswalk.attributeOr (lanelet::AttributeNamesString::Subtype, std::string (" " )) ==
180
- lanelet::AttributeValueString::Walkway) {
181
- registerModule (std::make_shared<WalkwayModule>(
182
- module_id, crosswalk, walkway_planner_param_, logger_.get_child (" walkway_module" ), clock_));
220
+ if (!opt_use_regulatory_element_) {
221
+ opt_use_regulatory_element_ = checkRegulatoryElementExistence (rh->getLaneletMapPtr ());
222
+ }
223
+
224
+ const auto launch = [this , &path](const auto & lanelet) {
225
+ const auto attribute =
226
+ lanelet.attributeOr (lanelet::AttributeNamesString::Subtype, std::string (" " ));
227
+ if (attribute != lanelet::AttributeValueString::Walkway) {
228
+ return ;
229
+ }
230
+
231
+ if (isModuleRegistered (lanelet.id ())) {
232
+ return ;
233
+ }
234
+
235
+ const auto & p = walkway_planner_param_;
236
+ const auto logger = logger_.get_child (" walkway_module" );
237
+ const auto lanelet_map_ptr = planner_data_->route_handler_ ->getLaneletMapPtr ();
238
+
239
+ registerModule (std::make_shared<WalkwayModule>(
240
+ lanelet.id (), lanelet_map_ptr, p, opt_use_regulatory_element_.get (), logger, clock_));
241
+ };
242
+
243
+ if (opt_use_regulatory_element_.get ()) {
244
+ const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
245
+ path, rh->getLaneletMapPtr (), planner_data_->current_odometry ->pose );
246
+
247
+ for (const auto & crosswalk : crosswalk_leg_elem_map) {
248
+ launch (crosswalk.first ->crosswalkLanelet ());
249
+ }
250
+ } else {
251
+ const auto crosswalk_lanelets = getCrosswalksOnPath (
252
+ planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (),
253
+ rh->getOverallGraphPtr ());
254
+
255
+ for (const auto & crosswalk : crosswalk_lanelets) {
256
+ launch (crosswalk);
183
257
}
184
258
}
185
259
}
186
260
187
261
std::function<bool (const std::shared_ptr<SceneModuleInterface> &)>
188
- WalkwayModuleManager::getModuleExpiredFunction (
189
- const autoware_auto_planning_msgs::msg::PathWithLaneId & path)
262
+ WalkwayModuleManager::getModuleExpiredFunction (const PathWithLaneId & path)
190
263
{
191
264
const auto rh = planner_data_->route_handler_ ;
192
- const auto walkway_id_set = getCrosswalkIdSetOnPath (
193
- planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (), rh->getOverallGraphPtr ());
265
+
266
+ std::set<int64_t > walkway_id_set;
267
+
268
+ if (opt_use_regulatory_element_.get ()) {
269
+ const auto crosswalk_leg_elem_map = planning_utils::getRegElemMapOnPath<Crosswalk>(
270
+ path, rh->getLaneletMapPtr (), planner_data_->current_odometry ->pose );
271
+
272
+ for (const auto & crosswalk : crosswalk_leg_elem_map) {
273
+ walkway_id_set.insert (crosswalk.first ->id ());
274
+ }
275
+ } else {
276
+ walkway_id_set = getCrosswalkIdSetOnPath (
277
+ planner_data_->current_odometry ->pose , path, rh->getLaneletMapPtr (),
278
+ rh->getOverallGraphPtr ());
279
+ }
194
280
195
281
return [walkway_id_set](const std::shared_ptr<SceneModuleInterface> & scene_module) {
196
282
return walkway_id_set.count (scene_module->getModuleId ()) == 0 ;
0 commit comments