@@ -153,6 +153,15 @@ StopFactor createStopFactor(
153
153
stop_factor.stop_pose = stop_pose;
154
154
return stop_factor;
155
155
}
156
+
157
+ std::optional<geometry_msgs::msg::Pose> toStdOptional (
158
+ const boost::optional<geometry_msgs::msg::Pose> & boost_pose)
159
+ {
160
+ if (boost_pose) {
161
+ return *boost_pose;
162
+ }
163
+ return std::nullopt;
164
+ }
156
165
} // namespace
157
166
158
167
CrosswalkModule::CrosswalkModule (
@@ -175,7 +184,7 @@ CrosswalkModule::CrosswalkModule(
175
184
} else {
176
185
const auto stop_line = getStopLineFromMap (module_id_, lanelet_map_ptr, " crosswalk_id" );
177
186
if (stop_line) {
178
- stop_lines_.push_back (stop_line. get () );
187
+ stop_lines_.push_back (* stop_line);
179
188
}
180
189
crosswalk_ = lanelet_map_ptr->laneletLayer .get (module_id);
181
190
}
@@ -217,8 +226,8 @@ bool CrosswalkModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
217
226
// Calculate stop point with margin
218
227
const auto p_stop_line = getStopPointWithMargin (*path, path_intersects);
219
228
// TODO(murooka) add a guard of p_stop_line
220
- const auto default_stop_pose =
221
- calcLongitudinalOffsetPose (path->points , p_stop_line->first , p_stop_line->second );
229
+ const auto default_stop_pose = toStdOptional (
230
+ calcLongitudinalOffsetPose (path->points , p_stop_line->first , p_stop_line->second )) ;
222
231
223
232
// Resample path sparsely for less computation cost
224
233
constexpr double resample_interval = 4.0 ;
@@ -253,8 +262,7 @@ bool CrosswalkModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
253
262
}
254
263
255
264
// NOTE: The stop point will be the returned point with the margin.
256
- boost::optional<std::pair<geometry_msgs::msg::Point , double >>
257
- CrosswalkModule::getStopPointWithMargin (
265
+ std::optional<std::pair<geometry_msgs::msg::Point , double >> CrosswalkModule::getStopPointWithMargin (
258
266
const PathWithLaneId & ego_path,
259
267
const std::vector<geometry_msgs::msg::Point > & path_intersects) const
260
268
{
@@ -279,11 +287,11 @@ CrosswalkModule::getStopPointWithMargin(
279
287
return {};
280
288
}
281
289
282
- boost ::optional<StopFactor> CrosswalkModule::checkStopForCrosswalkUsers (
290
+ std ::optional<StopFactor> CrosswalkModule::checkStopForCrosswalkUsers (
283
291
const PathWithLaneId & ego_path, const PathWithLaneId & sparse_resample_path,
284
- const boost ::optional<std::pair<geometry_msgs::msg::Point , double >> & p_stop_line,
292
+ const std ::optional<std::pair<geometry_msgs::msg::Point , double >> & p_stop_line,
285
293
const std::vector<geometry_msgs::msg::Point > & path_intersects,
286
- const boost ::optional<geometry_msgs::msg::Pose> & default_stop_pose)
294
+ const std ::optional<geometry_msgs::msg::Pose> & default_stop_pose)
287
295
{
288
296
const auto & ego_pos = planner_data_->current_odometry ->pose .position ;
289
297
const auto & objects_ptr = planner_data_->predicted_objects ;
@@ -480,8 +488,8 @@ std::pair<double, double> CrosswalkModule::clampAttentionRangeByNeighborCrosswal
480
488
481
489
sortCrosswalksByDistance (ego_path, ego_pos, crosswalks);
482
490
483
- boost ::optional<lanelet::ConstLanelet> prev_crosswalk{boost::none };
484
- boost ::optional<lanelet::ConstLanelet> next_crosswalk{boost::none };
491
+ std ::optional<lanelet::ConstLanelet> prev_crosswalk{std::nullopt };
492
+ std ::optional<lanelet::ConstLanelet> next_crosswalk{std::nullopt };
485
493
486
494
if (!crosswalks.empty ()) {
487
495
for (size_t i = 0 ; i < crosswalks.size () - 1 ; ++i) {
@@ -506,7 +514,7 @@ std::pair<double, double> CrosswalkModule::clampAttentionRangeByNeighborCrosswal
506
514
std::reverse (reverse_ego_path.points .begin (), reverse_ego_path.points .end ());
507
515
508
516
const auto prev_crosswalk_intersects = getPolygonIntersects (
509
- reverse_ego_path, prev_crosswalk. get (). polygon2d ().basicPolygon (), ego_pos, 2 );
517
+ reverse_ego_path, prev_crosswalk-> polygon2d ().basicPolygon (), ego_pos, 2 );
510
518
if (prev_crosswalk_intersects.empty ()) {
511
519
return near_attention_range;
512
520
}
@@ -521,7 +529,7 @@ std::pair<double, double> CrosswalkModule::clampAttentionRangeByNeighborCrosswal
521
529
return far_attention_range;
522
530
}
523
531
const auto next_crosswalk_intersects =
524
- getPolygonIntersects (ego_path, next_crosswalk. get (). polygon2d ().basicPolygon (), ego_pos, 2 );
532
+ getPolygonIntersects (ego_path, next_crosswalk-> polygon2d ().basicPolygon (), ego_pos, 2 );
525
533
526
534
if (next_crosswalk_intersects.empty ()) {
527
535
return far_attention_range;
@@ -748,10 +756,10 @@ Polygon2d CrosswalkModule::getAttentionArea(
748
756
return attention_area;
749
757
}
750
758
751
- boost ::optional<StopFactor> CrosswalkModule::checkStopForStuckedVehicles (
759
+ std ::optional<StopFactor> CrosswalkModule::checkStopForStuckedVehicles (
752
760
const PathWithLaneId & ego_path, const std::vector<PredictedObject> & objects,
753
761
const std::vector<geometry_msgs::msg::Point > & path_intersects,
754
- const boost ::optional<geometry_msgs::msg::Pose> & stop_pose) const
762
+ const std ::optional<geometry_msgs::msg::Pose> & stop_pose) const
755
763
{
756
764
if (path_intersects.size () < 2 || !stop_pose) {
757
765
return {};
@@ -789,14 +797,14 @@ boost::optional<StopFactor> CrosswalkModule::checkStopForStuckedVehicles(
789
797
return {};
790
798
}
791
799
792
- boost ::optional<StopFactor> CrosswalkModule::getNearestStopFactor (
800
+ std ::optional<StopFactor> CrosswalkModule::getNearestStopFactor (
793
801
const PathWithLaneId & ego_path,
794
- const boost ::optional<StopFactor> & stop_factor_for_crosswalk_users,
795
- const boost ::optional<StopFactor> & stop_factor_for_stucked_vehicles)
802
+ const std ::optional<StopFactor> & stop_factor_for_crosswalk_users,
803
+ const std ::optional<StopFactor> & stop_factor_for_stucked_vehicles)
796
804
{
797
- const auto get_distance_to_stop = [&](const auto stop_factor) -> boost ::optional<double > {
805
+ const auto get_distance_to_stop = [&](const auto stop_factor) -> std ::optional<double > {
798
806
const auto & ego_pos = planner_data_->current_odometry ->pose .position ;
799
- if (!stop_factor) return boost::none ;
807
+ if (!stop_factor) return std::nullopt ;
800
808
return calcSignedArcLength (ego_path.points , ego_pos, stop_factor->stop_pose .position );
801
809
};
802
810
const auto dist_to_stop_for_crosswalk_users =
@@ -967,7 +975,7 @@ geometry_msgs::msg::Polygon CrosswalkModule::createVehiclePolygon(
967
975
}
968
976
969
977
void CrosswalkModule::planGo (
970
- PathWithLaneId & ego_path, const boost ::optional<StopFactor> & stop_factor)
978
+ PathWithLaneId & ego_path, const std ::optional<StopFactor> & stop_factor)
971
979
{
972
980
if (!stop_factor) {
973
981
setDistance (std::numeric_limits<double >::lowest ());
@@ -988,13 +996,13 @@ void CrosswalkModule::planGo(
988
996
}
989
997
990
998
void CrosswalkModule::planStop (
991
- PathWithLaneId & ego_path, const boost ::optional<StopFactor> & nearest_stop_factor,
992
- const boost ::optional<geometry_msgs::msg::Pose> & default_stop_pose, StopReason * stop_reason)
999
+ PathWithLaneId & ego_path, const std ::optional<StopFactor> & nearest_stop_factor,
1000
+ const std ::optional<geometry_msgs::msg::Pose> & default_stop_pose, StopReason * stop_reason)
993
1001
{
994
- const auto stop_factor = [&]() -> boost ::optional<StopFactor> {
1002
+ const auto stop_factor = [&]() -> std ::optional<StopFactor> {
995
1003
if (nearest_stop_factor) return *nearest_stop_factor;
996
1004
if (default_stop_pose) return createStopFactor (*default_stop_pose);
997
- return boost::none ;
1005
+ return std::nullopt ;
998
1006
}();
999
1007
1000
1008
if (!stop_factor) {
0 commit comments