@@ -139,7 +139,7 @@ RouteHandler::RouteHandler(const HADMapBin & map_msg)
139
139
route_ptr_ = nullptr ;
140
140
}
141
141
142
- void RouteHandler::setMap (const HADMapBin & map_msg)
142
+ void RouteHandler::setMap (const HADMapBin & map_msg, const bool & is_enable_differantial_lanelet )
143
143
{
144
144
lanelet_map_ptr_ = std::make_shared<lanelet::LaneletMap>();
145
145
lanelet::utils::conversion::fromBinMsg (
@@ -163,7 +163,7 @@ void RouteHandler::setMap(const HADMapBin & map_msg)
163
163
is_map_msg_ready_ = true ;
164
164
is_handler_ready_ = false ;
165
165
166
- setLaneletsFromRouteMsg ();
166
+ setLaneletsFromRouteMsg (is_enable_differantial_lanelet );
167
167
}
168
168
169
169
bool RouteHandler::isRouteLooped (const RouteSections & route_sections)
@@ -180,7 +180,8 @@ bool RouteHandler::isRouteLooped(const RouteSections & route_sections)
180
180
return false ;
181
181
}
182
182
183
- void RouteHandler::setRoute (const LaneletRoute & route_msg)
183
+ void RouteHandler::setRoute (
184
+ const LaneletRoute & route_msg, const bool & is_enable_differantial_lanelet)
184
185
{
185
186
if (!isRouteLooped (route_msg.segments )) {
186
187
// if get not modified route but new route, reset original start pose
@@ -190,7 +191,7 @@ void RouteHandler::setRoute(const LaneletRoute & route_msg)
190
191
}
191
192
route_ptr_ = std::make_shared<LaneletRoute>(route_msg);
192
193
is_handler_ready_ = false ;
193
- setLaneletsFromRouteMsg ();
194
+ setLaneletsFromRouteMsg (is_enable_differantial_lanelet );
194
195
} else {
195
196
RCLCPP_ERROR (
196
197
logger_,
@@ -313,17 +314,19 @@ void RouteHandler::clearRoute()
313
314
is_handler_ready_ = false ;
314
315
}
315
316
316
- void RouteHandler::setLaneletsFromRouteMsg ()
317
+ void RouteHandler::setLaneletsFromRouteMsg (const bool & is_enable_differantial_lanelet )
317
318
{
318
319
if (!route_ptr_ || !is_map_msg_ready_) {
319
320
return ;
320
321
}
321
322
route_lanelets_.clear ();
322
323
preferred_lanelets_.clear ();
323
- // const bool is_route_valid = lanelet::utils::route::isRouteValid(*route_ptr_,
324
- // lanelet_map_ptr_); if (!is_route_valid) {
325
- // return;
326
- // }
324
+ if (!is_enable_differantial_lanelet) {
325
+ const bool is_route_valid = lanelet::utils::route::isRouteValid (*route_ptr_, lanelet_map_ptr_);
326
+ if (!is_route_valid) {
327
+ return ;
328
+ }
329
+ }
327
330
328
331
size_t primitive_size{0 };
329
332
for (const auto & route_section : route_ptr_->segments ) {
@@ -341,11 +344,18 @@ void RouteHandler::setLaneletsFromRouteMsg()
341
344
preferred_lanelets_.push_back (llt);
342
345
}
343
346
} catch (const std::exception & e) {
344
- std::cerr
345
- << e.what ()
346
- << " . Maybe the loaded route was created on a different Map from the current one. "
347
- " Try to load the other Route again."
348
- << std::endl;
347
+ if (!is_enable_differantial_lanelet) {
348
+ std::cerr
349
+ << e.what ()
350
+ << " . Maybe the loaded route was created on a different Map from the current one. "
351
+ " Try to load the other Route again."
352
+ << std::endl;
353
+ return ;
354
+ } else {
355
+ RCLCPP_DEBUG (
356
+ logger_, " Failed to get lanelet differential map with id: %ld. %s" , primitive.id ,
357
+ e.what ());
358
+ }
349
359
}
350
360
}
351
361
}
@@ -359,11 +369,18 @@ void RouteHandler::setLaneletsFromRouteMsg()
359
369
const auto & llt = lanelet_map_ptr_->laneletLayer .get (id);
360
370
goal_lanelets_.push_back (llt);
361
371
} catch (const std::exception & e) {
362
- std::cerr
363
- << e.what ()
364
- << " . Maybe the loaded route was created on a different Map from the current one. "
365
- " Try to load the other Route again."
366
- << std::endl;
372
+ if (!is_enable_differantial_lanelet) {
373
+ std::cerr
374
+ << e.what ()
375
+ << " . Maybe the loaded route was created on a different Map from the current one. "
376
+ " Try to load the other Route again."
377
+ << std::endl;
378
+ return ;
379
+ } else {
380
+ RCLCPP_DEBUG (
381
+ logger_, " Failed to get lanelet differential map with id: %ld. %s" , primitive.id ,
382
+ e.what ());
383
+ }
367
384
}
368
385
}
369
386
start_lanelets_.reserve (route_ptr_->segments .front ().primitives .size ());
@@ -373,11 +390,18 @@ void RouteHandler::setLaneletsFromRouteMsg()
373
390
const auto & llt = lanelet_map_ptr_->laneletLayer .get (id);
374
391
start_lanelets_.push_back (llt);
375
392
} catch (const std::exception & e) {
376
- std::cerr
377
- << e.what ()
378
- << " . Maybe the loaded route was created on a different Map from the current one. "
379
- " Try to load the other Route again."
380
- << std::endl;
393
+ if (!is_enable_differantial_lanelet) {
394
+ std::cerr
395
+ << e.what ()
396
+ << " . Maybe the loaded route was created on a different Map from the current one. "
397
+ " Try to load the other Route again."
398
+ << std::endl;
399
+ return ;
400
+ } else {
401
+ RCLCPP_DEBUG (
402
+ logger_, " Failed to get lanelet differential map with id: %ld. %s" , primitive.id ,
403
+ e.what ());
404
+ }
381
405
}
382
406
}
383
407
}
0 commit comments