@@ -54,14 +54,14 @@ WalkwayModule::WalkwayModule(
54
54
}
55
55
}
56
56
57
- std::optional<std:: pair<double , geometry_msgs::msg::Point > > WalkwayModule::getStopLine (
57
+ std::pair<double , geometry_msgs::msg::Point > WalkwayModule::getStopLine (
58
58
const PathWithLaneId & ego_path, bool & exist_stopline_in_map,
59
- const std::vector< geometry_msgs::msg::Point > & path_intersects ) const
59
+ const geometry_msgs::msg::Point & first_path_point_on_walkway ) const
60
60
{
61
61
const auto & ego_pos = planner_data_->current_odometry ->pose .position ;
62
62
for (const auto & stop_line : stop_lines_) {
63
- const auto p_stop_lines = getLinestringIntersects (
64
- ego_path, lanelet::utils::to2D (stop_line).basicLineString (), ego_pos, 2 );
63
+ const auto p_stop_lines =
64
+ getLinestringIntersects ( ego_path, lanelet::utils::to2D (stop_line).basicLineString (), ego_pos);
65
65
if (p_stop_lines.empty ()) {
66
66
continue ;
67
67
}
@@ -73,18 +73,12 @@ std::optional<std::pair<double, geometry_msgs::msg::Point>> WalkwayModule::getSt
73
73
return std::make_pair (dist_ego_to_stop, p_stop_lines.front ());
74
74
}
75
75
76
- {
77
- exist_stopline_in_map = false ;
76
+ exist_stopline_in_map = false ;
78
77
79
- if (!path_intersects.empty ()) {
80
- const auto p_stop_line = path_intersects.front ();
81
- const auto dist_ego_to_stop = calcSignedArcLength (ego_path.points , ego_pos, p_stop_line) -
82
- planner_param_.stop_distance_from_crosswalk ;
83
- return std::make_pair (dist_ego_to_stop, p_stop_line);
84
- }
85
- }
86
-
87
- return {};
78
+ const auto p_stop_line = first_path_point_on_walkway;
79
+ const auto dist_ego_to_stop = calcSignedArcLength (ego_path.points , ego_pos, p_stop_line) -
80
+ planner_param_.stop_distance_from_crosswalk ;
81
+ return std::make_pair (dist_ego_to_stop, p_stop_line);
88
82
}
89
83
90
84
bool WalkwayModule::modifyPathVelocity (PathWithLaneId * path, StopReason * stop_reason)
@@ -97,21 +91,19 @@ bool WalkwayModule::modifyPathVelocity(PathWithLaneId * path, StopReason * stop_
97
91
const auto input = *path;
98
92
99
93
const auto & ego_pos = planner_data_->current_odometry ->pose .position ;
100
- const auto path_intersects =
101
- getPolygonIntersects (input, walkway_.polygon2d ().basicPolygon (), ego_pos, 2 );
102
-
103
- if (path_intersects.empty ()) {
94
+ const auto path_end_points_on_walkway =
95
+ getPathEndPointsOnCrosswalk (input, walkway_.polygon2d ().basicPolygon (), ego_pos);
96
+ if (!path_end_points_on_walkway) {
104
97
return false ;
105
98
}
106
99
100
+ const auto & first_path_point_on_walkway = path_end_points_on_walkway->first ;
101
+
107
102
if (state_ == State::APPROACH) {
108
103
bool exist_stopline_in_map;
109
- const auto p_stop_line = getStopLine (input, exist_stopline_in_map, path_intersects);
110
- if (!p_stop_line) {
111
- return false ;
112
- }
104
+ const auto p_stop_line = getStopLine (input, exist_stopline_in_map, first_path_point_on_walkway);
113
105
114
- const auto & p_stop = p_stop_line-> second ;
106
+ const auto & p_stop = p_stop_line. second ;
115
107
const auto stop_distance_from_crosswalk =
116
108
exist_stopline_in_map ? 0.0 : planner_param_.stop_distance_from_crosswalk ;
117
109
const auto margin = stop_distance_from_crosswalk + base_link2front;
@@ -129,7 +121,7 @@ bool WalkwayModule::modifyPathVelocity(PathWithLaneId * path, StopReason * stop_
129
121
/* get stop point and stop factor */
130
122
StopFactor stop_factor;
131
123
stop_factor.stop_pose = stop_pose.value ();
132
- stop_factor.stop_factor_points .push_back (path_intersects. front () );
124
+ stop_factor.stop_factor_points .push_back (path_end_points_on_walkway-> first );
133
125
planning_utils::appendStopReason (stop_factor, stop_reason);
134
126
velocity_factor_.set (
135
127
path->points , planner_data_->current_odometry ->pose , stop_pose.value (),
0 commit comments