Skip to content

Commit a7cb680

Browse files
committed
fix
Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 01a9101 commit a7cb680

File tree

3 files changed

+40
-42
lines changed

3 files changed

+40
-42
lines changed

planning/behavior_velocity_planner/autoware_behavior_velocity_crosswalk_module/README.md

+21-15
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@ skinparam monochrome true
1717
title modifyPathVelocity
1818
start
1919
:getPathEndPointsOnCrosswalk;
20-
:applySlowDownByLanleet2Map;
21-
:applySlowDownByOcclusion;
22-
:getStaticStopPose;
23-
:resamplePath;
24-
:checkStopForCrosswalkUsers;
25-
:checkStopForStuckVehicles;
26-
:getNearestStopFactor;
27-
:setSafe;
28-
:setDistanceToStop;
29-
30-
if (isActivated() is True?) then (yes)
31-
:planGo;
32-
else (yes)
33-
:planStop;
34-
endif
20+
group apply slow down
21+
:applySlowDownByLanleet2Map;
22+
:applySlowDownByOcclusion;
23+
end group
24+
group calculate stop pose
25+
:getStaticStopPose;
26+
:resamplePath;
27+
:checkStopForCrosswalkUsers;
28+
:checkStopForStuckVehicles;
29+
end group
30+
group apply stop
31+
:getNearestStopFactor;
32+
:setSafe;
33+
:setDistanceToStop;
34+
35+
if (isActivated() is True?) then (yes)
36+
:planGo;
37+
else (no)
38+
:planStop;
39+
endif
40+
end group
3541
3642
stop
3743
@enduml

planning/behavior_velocity_planner/autoware_behavior_velocity_walkway_module/src/scene_walkway.cpp

+17-25
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ WalkwayModule::WalkwayModule(
5454
}
5555
}
5656

57-
std::optional<std::pair<double, geometry_msgs::msg::Point>> WalkwayModule::getStopLine(
57+
std::pair<double, geometry_msgs::msg::Point> WalkwayModule::getStopLine(
5858
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
6060
{
6161
const auto & ego_pos = planner_data_->current_odometry->pose.position;
6262
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);
6565
if (p_stop_lines.empty()) {
6666
continue;
6767
}
@@ -73,18 +73,12 @@ std::optional<std::pair<double, geometry_msgs::msg::Point>> WalkwayModule::getSt
7373
return std::make_pair(dist_ego_to_stop, p_stop_lines.front());
7474
}
7575

76-
{
77-
exist_stopline_in_map = false;
76+
exist_stopline_in_map = false;
7877

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);
8882
}
8983

9084
bool WalkwayModule::modifyPathVelocity(PathWithLaneId * path, StopReason * stop_reason)
@@ -97,21 +91,19 @@ bool WalkwayModule::modifyPathVelocity(PathWithLaneId * path, StopReason * stop_
9791
const auto input = *path;
9892

9993
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) {
10497
return false;
10598
}
10699

100+
const auto & first_path_point_on_walkway = path_end_points_on_walkway->first;
101+
107102
if (state_ == State::APPROACH) {
108103
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);
113105

114-
const auto & p_stop = p_stop_line->second;
106+
const auto & p_stop = p_stop_line.second;
115107
const auto stop_distance_from_crosswalk =
116108
exist_stopline_in_map ? 0.0 : planner_param_.stop_distance_from_crosswalk;
117109
const auto margin = stop_distance_from_crosswalk + base_link2front;
@@ -129,7 +121,7 @@ bool WalkwayModule::modifyPathVelocity(PathWithLaneId * path, StopReason * stop_
129121
/* get stop point and stop factor */
130122
StopFactor stop_factor;
131123
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);
133125
planning_utils::appendStopReason(stop_factor, stop_reason);
134126
velocity_factor_.set(
135127
path->points, planner_data_->current_odometry->pose, stop_pose.value(),

planning/behavior_velocity_planner/autoware_behavior_velocity_walkway_module/src/scene_walkway.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class WalkwayModule : public SceneModuleInterface
5454
private:
5555
const int64_t module_id_;
5656

57-
[[nodiscard]] std::optional<std::pair<double, geometry_msgs::msg::Point>> getStopLine(
57+
[[nodiscard]] std::pair<double, geometry_msgs::msg::Point> getStopLine(
5858
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;
6060

6161
enum class State { APPROACH, STOP, SURPASSED };
6262

0 commit comments

Comments
 (0)