Skip to content

Commit 9140499

Browse files
visualize drivable lanes for shift_path
Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
1 parent ec9144c commit 9140499

File tree

10 files changed

+222
-73
lines changed

10 files changed

+222
-73
lines changed

planning/behavior_path_planner_common/include/behavior_path_planner_common/utils/parking_departure/common_module_data.hpp

-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ struct StartGoalPlannerData
3838
std::vector<PoseWithVelocityStamped> ego_predicted_path;
3939
// collision check debug map
4040
CollisionCheckDebugMap collision_check;
41-
42-
Pose refined_start_pose;
43-
std::vector<Pose> start_pose_candidates;
44-
size_t selected_start_pose_candidate_index;
45-
double margin_for_start_pose_candidate;
4641
};
4742

4843
} // namespace behavior_path_planner

planning/behavior_path_start_planner_module/config/start_planner.param.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
center_line_path_interval: 1.0
1414
# shift pull out
1515
enable_shift_pull_out: true
16-
check_shift_path_lane_departure: false
16+
check_shift_path_lane_departure: true
1717
minimum_shift_pull_out_distance: 0.0
1818
deceleration_interval: 15.0
1919
lateral_jerk: 0.5
+24-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
#ifndef BEHAVIOR_PATH_START_PLANNER_MODULE__START_PLANNER_PARAMETERS_HPP_
17-
#define BEHAVIOR_PATH_START_PLANNER_MODULE__START_PLANNER_PARAMETERS_HPP_
16+
#ifndef BEHAVIOR_PATH_START_PLANNER_MODULE__DATA_STRUCTS_HPP_
17+
#define BEHAVIOR_PATH_START_PLANNER_MODULE__DATA_STRUCTS_HPP_
1818

1919
#include "behavior_path_planner_common/utils/parking_departure/geometric_parallel_parking.hpp"
2020
#include "behavior_path_planner_common/utils/path_safety_checker/path_safety_checker_parameters.hpp"
@@ -29,10 +29,31 @@
2929
namespace behavior_path_planner
3030
{
3131

32+
using autoware_auto_perception_msgs::msg::PredictedObjects;
33+
using behavior_path_planner::utils::path_safety_checker::CollisionCheckDebugMap;
34+
using behavior_path_planner::utils::path_safety_checker::PoseWithVelocityStamped;
35+
using behavior_path_planner::utils::path_safety_checker::TargetObjectsOnLane;
36+
3237
using freespace_planning_algorithms::AstarParam;
3338
using freespace_planning_algorithms::PlannerCommonParam;
3439
using freespace_planning_algorithms::RRTStarParam;
3540

41+
struct StartPlannerDebugData
42+
{
43+
// filtered objects
44+
PredictedObjects filtered_objects;
45+
TargetObjectsOnLane target_objects_on_lane;
46+
std::vector<PoseWithVelocityStamped> ego_predicted_path;
47+
// collision check debug map
48+
CollisionCheckDebugMap collision_check;
49+
lanelet::ConstLanelets drivable_lanes;
50+
51+
Pose refined_start_pose;
52+
std::vector<Pose> start_pose_candidates;
53+
size_t selected_start_pose_candidate_index;
54+
double margin_for_start_pose_candidate;
55+
};
56+
3657
struct StartPlannerParameters
3758
{
3859
double th_arrived_distance{0.0};
@@ -105,4 +126,4 @@ struct StartPlannerParameters
105126

106127
} // namespace behavior_path_planner
107128

108-
#endif // BEHAVIOR_PATH_START_PLANNER_MODULE__START_PLANNER_PARAMETERS_HPP_
129+
#endif // BEHAVIOR_PATH_START_PLANNER_MODULE__DATA_STRUCTS_HPP_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2023 TIER IV, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef BEHAVIOR_PATH_START_PLANNER_MODULE__DEBUG_HPP_
16+
#define BEHAVIOR_PATH_START_PLANNER_MODULE__DEBUG_HPP_
17+
18+
#include "behavior_path_start_planner_module/data_structs.hpp"
19+
20+
#include <string>
21+
#include <vector>
22+
23+
namespace behavior_path_planner
24+
{
25+
using behavior_path_planner::StartPlannerDebugData;
26+
27+
void updateSafetyCheckDebugData(
28+
StartPlannerDebugData & data, const PredictedObjects & filtered_objects,
29+
const TargetObjectsOnLane & target_objects_on_lane,
30+
const std::vector<PoseWithVelocityStamped> & ego_predicted_path)
31+
{
32+
data.filtered_objects = filtered_objects;
33+
data.target_objects_on_lane = target_objects_on_lane;
34+
data.ego_predicted_path = ego_predicted_path;
35+
}
36+
37+
} // namespace behavior_path_planner
38+
39+
#endif // BEHAVIOR_PATH_START_PLANNER_MODULE__DEBUG_HPP_

planning/behavior_path_start_planner_module/include/behavior_path_start_planner_module/pull_out_planner_base.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#define BEHAVIOR_PATH_START_PLANNER_MODULE__PULL_OUT_PLANNER_BASE_HPP_
1717

1818
#include "behavior_path_planner_common/data_manager.hpp"
19+
#include "behavior_path_start_planner_module/data_structs.hpp"
1920
#include "behavior_path_start_planner_module/pull_out_path.hpp"
20-
#include "behavior_path_start_planner_module/start_planner_parameters.hpp"
2121

2222
#include <autoware_auto_planning_msgs/msg/path_with_lane_id.hpp>
2323
#include <geometry_msgs/msg/pose_stamped.hpp>

planning/behavior_path_start_planner_module/include/behavior_path_start_planner_module/shift_pull_out.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ class ShiftPullOut : public PullOutPlannerBase
5050
ShiftedPath & shifted_path, const Pose & start_pose, const Pose & end_pose,
5151
const double longitudinal_acc, const double lateral_acc);
5252

53+
void setDrivableLanes(const lanelet::ConstLanelets & drivable_lanes)
54+
{
55+
drivable_lanes_ = drivable_lanes;
56+
}
57+
5358
std::shared_ptr<LaneDepartureChecker> lane_departure_checker_;
5459

5560
private:
@@ -58,6 +63,8 @@ class ShiftPullOut : public PullOutPlannerBase
5863
double calcPullOutLongitudinalDistance(
5964
const double lon_acc, const double shift_time, const double shift_length,
6065
const double max_curvature, const double min_distance) const;
66+
67+
lanelet::ConstLanelets drivable_lanes_;
6168
};
6269
} // namespace behavior_path_planner
6370

planning/behavior_path_start_planner_module/include/behavior_path_start_planner_module/start_planner_module.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
#include "behavior_path_planner_common/utils/path_safety_checker/path_safety_checker_parameters.hpp"
2222
#include "behavior_path_planner_common/utils/path_shifter/path_shifter.hpp"
2323
#include "behavior_path_planner_common/utils/utils.hpp"
24+
#include "behavior_path_start_planner_module/data_structs.hpp"
2425
#include "behavior_path_start_planner_module/freespace_pull_out.hpp"
2526
#include "behavior_path_start_planner_module/geometric_pull_out.hpp"
2627
#include "behavior_path_start_planner_module/pull_out_path.hpp"
2728
#include "behavior_path_start_planner_module/shift_pull_out.hpp"
28-
#include "behavior_path_start_planner_module/start_planner_parameters.hpp"
2929

3030
#include <lane_departure_checker/lane_departure_checker.hpp>
3131
#include <vehicle_info_util/vehicle_info.hpp>
@@ -191,7 +191,7 @@ class StartPlannerModule : public SceneModuleInterface
191191

192192
std::vector<std::shared_ptr<PullOutPlannerBase>> start_planners_;
193193
PullOutStatus status_;
194-
mutable StartGoalPlannerData start_planner_data_;
194+
mutable StartPlannerDebugData debug_data_;
195195

196196
std::deque<nav_msgs::msg::Odometry::ConstSharedPtr> odometry_buffer_;
197197

@@ -242,6 +242,8 @@ class StartPlannerModule : public SceneModuleInterface
242242
const std::vector<PoseWithVelocityStamped> & ego_predicted_path) const;
243243
bool isSafePath() const;
244244
void setDrivableAreaInfo(BehaviorModuleOutput & output) const;
245+
void updateDrivableLanes();
246+
lanelet::ConstLanelets createDrivableLanes() const;
245247

246248
// check if the goal is located behind the ego in the same route segment.
247249
bool isGoalBehindOfEgoInSameRouteSegment() const;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2023 TIER IV, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "behavior_path_start_planner_module/debug.hpp"
16+
17+
namespace behavior_path_planner
18+
{
19+
20+
void updateSafetyCheckDebugData(
21+
StartPlannerDebugData & data, const PredictedObjects & filtered_objects,
22+
const TargetObjectsOnLane & target_objects_on_lane,
23+
const std::vector<PoseWithVelocityStamped> & ego_predicted_path)
24+
{
25+
data.filtered_objects = filtered_objects;
26+
data.target_objects_on_lane = target_objects_on_lane;
27+
data.ego_predicted_path = ego_predicted_path;
28+
}
29+
30+
} // namespace behavior_path_planner

planning/behavior_path_start_planner_module/src/shift_pull_out.cpp

+8-37
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ std::optional<PullOutPath> ShiftPullOut::plan(const Pose & start_pose, const Pos
4949

5050
const double backward_path_length =
5151
planner_data_->parameters.backward_path_length + parameters_.max_back_distance;
52-
const auto pull_out_lanes = getPullOutLanes(planner_data_, backward_path_length);
53-
if (pull_out_lanes.empty()) {
54-
return std::nullopt;
55-
}
56-
5752
const auto road_lanes = utils::getExtendedCurrentLanes(
5853
planner_data_, backward_path_length, std::numeric_limits<double>::max(),
5954
/*forward_only_in_route*/ true);
@@ -69,41 +64,17 @@ std::optional<PullOutPath> ShiftPullOut::plan(const Pose & start_pose, const Pos
6964
pull_out_path.partial_paths.front(); // shift path is not separate but only one.
7065

7166
// check lane_departure with path between pull_out_start to pull_out_end
72-
PathWithLaneId path_start_to_end{};
67+
PathWithLaneId path_shift_start_to_end{};
7368
{
7469
const size_t pull_out_start_idx = findNearestIndex(shift_path.points, start_pose.position);
70+
const size_t pull_out_end_idx =
71+
findNearestIndex(shift_path.points, pull_out_path.end_pose.position);
7572

76-
// calculate collision check end idx
77-
const size_t collision_check_end_idx = std::invoke([&]() {
78-
const auto collision_check_end_pose = motion_utils::calcLongitudinalOffsetPose(
79-
shift_path.points, pull_out_path.end_pose.position,
80-
parameters_.collision_check_distance_from_end);
81-
82-
if (collision_check_end_pose) {
83-
return findNearestIndex(shift_path.points, collision_check_end_pose->position);
84-
} else {
85-
return shift_path.points.size() - 1;
86-
}
87-
});
88-
path_start_to_end.points.insert(
89-
path_start_to_end.points.begin(), shift_path.points.begin() + pull_out_start_idx,
90-
shift_path.points.begin() + collision_check_end_idx + 1);
73+
path_shift_start_to_end.points.insert(
74+
path_shift_start_to_end.points.begin(), shift_path.points.begin() + pull_out_start_idx,
75+
shift_path.points.begin() + pull_out_end_idx + 1);
9176
}
9277

93-
// extract shoulder lanes from pull out lanes
94-
lanelet::ConstLanelets shoulder_lanes;
95-
std::copy_if(
96-
pull_out_lanes.begin(), pull_out_lanes.end(), std::back_inserter(shoulder_lanes),
97-
[&route_handler](const auto & pull_out_lane) {
98-
return route_handler->isShoulderLanelet(pull_out_lane);
99-
});
100-
const auto drivable_lanes =
101-
utils::generateDrivableLanesWithShoulderLanes(road_lanes, shoulder_lanes);
102-
const auto & dp = planner_data_->drivable_area_expansion_parameters;
103-
const auto expanded_lanes = utils::transformToLanelets(utils::expandLanelets(
104-
drivable_lanes, dp.drivable_area_left_bound_offset, dp.drivable_area_right_bound_offset,
105-
dp.drivable_area_types_to_skip));
106-
10778
// crop backward path
10879
// removes points which are out of lanes up to the start pose.
10980
// this ensures that the backward_path stays within the drivable area when starting from a
@@ -117,7 +88,7 @@ std::optional<PullOutPath> ShiftPullOut::plan(const Pose & start_pose, const Pos
11788
const auto transformed_vehicle_footprint =
11889
transformVector(vehicle_footprint_, tier4_autoware_utils::pose2transform(pose));
11990
const bool is_out_of_lane =
120-
LaneDepartureChecker::isOutOfLane(expanded_lanes, transformed_vehicle_footprint);
91+
LaneDepartureChecker::isOutOfLane(drivable_lanes_, transformed_vehicle_footprint);
12192
if (i <= start_segment_idx) {
12293
if (!is_out_of_lane) {
12394
cropped_path.points.push_back(shift_path.points.at(i));
@@ -131,7 +102,7 @@ std::optional<PullOutPath> ShiftPullOut::plan(const Pose & start_pose, const Pos
131102
// check lane departure
132103
if (
133104
parameters_.check_shift_path_lane_departure &&
134-
lane_departure_checker_->checkPathWillLeaveLane(expanded_lanes, path_start_to_end)) {
105+
lane_departure_checker_->checkPathWillLeaveLane(drivable_lanes_, path_shift_start_to_end)) {
135106
continue;
136107
}
137108

0 commit comments

Comments
 (0)