Skip to content

Commit 434615f

Browse files
committed
feat(avoidance): return original lane as soon as possible if traffic is congested
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 35d39e7 commit 434615f

File tree

7 files changed

+49
-9
lines changed

7 files changed

+49
-9
lines changed

planning/behavior_path_avoidance_module/config/avoidance.param.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@
228228
traffic_light:
229229
enable: true # [-]
230230
buffer: 3.0 # [m]
231+
traffic_jam:
232+
enable: true # [-]
233+
buffer: 8.0 # [m]
231234

232235
# For cancel maneuver
233236
cancel:

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/data_structs.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ struct AvoidanceParameters
134134
// consider avoidance return dead line
135135
bool enable_dead_line_for_goal{false};
136136
bool enable_dead_line_for_traffic_light{false};
137+
bool enable_dead_line_for_traffic_jam{false};
137138

138139
// module try to return original path to keep this distance from edge point of the path.
139140
double dead_line_buffer_for_goal{0.0};
140141
double dead_line_buffer_for_traffic_light{0.0};
142+
double dead_line_buffer_for_traffic_jam{0.0};
141143

142144
// max deceleration for
143145
double max_deceleration{0.0};

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/parameter_helper.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,13 @@ AvoidanceParameters getParameter(rclcpp::Node * node)
283283
p.enable_dead_line_for_goal = getOrDeclareParameter<bool>(*node, ns + "goal.enable");
284284
p.enable_dead_line_for_traffic_light =
285285
getOrDeclareParameter<bool>(*node, ns + "traffic_light.enable");
286+
p.enable_dead_line_for_traffic_jam =
287+
getOrDeclareParameter<bool>(*node, ns + "traffic_jam.enable");
286288
p.dead_line_buffer_for_goal = getOrDeclareParameter<double>(*node, ns + "goal.buffer");
287289
p.dead_line_buffer_for_traffic_light =
288290
getOrDeclareParameter<double>(*node, ns + "traffic_light.buffer");
291+
p.dead_line_buffer_for_traffic_jam =
292+
getOrDeclareParameter<double>(*node, ns + "traffic_jam.buffer");
289293
}
290294

291295
// cancel

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/utils.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ DrivableLanes generateExpandedDrivableLanes(
166166

167167
double calcDistanceToReturnDeadLine(
168168
const lanelet::ConstLanelets & lanelets, const PathWithLaneId & path,
169-
const std::shared_ptr<const PlannerData> & planner_data,
169+
ObjectDataArray & other_objects, const std::shared_ptr<const PlannerData> & planner_data,
170170
const std::shared_ptr<AvoidanceParameters> & parameters);
171171

172172
double calcDistanceToAvoidStartLine(

planning/behavior_path_avoidance_module/schema/avoidance.schema.json

+18-1
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,26 @@
11831183
},
11841184
"required": ["enable", "buffer"],
11851185
"additionalProperties": false
1186+
},
1187+
"traffic_jam": {
1188+
"type": "object",
1189+
"properties": {
1190+
"enable": {
1191+
"type": "boolean",
1192+
"description": "Insert stop point in order to return original lane before reaching vehicles in traffic jam.",
1193+
"default": "true"
1194+
},
1195+
"buffer": {
1196+
"type": "number",
1197+
"description": "Buffer distance to return original lane before reaching vehicles in traffic jam.",
1198+
"default": 8.0
1199+
}
1200+
},
1201+
"required": ["enable", "buffer"],
1202+
"additionalProperties": false
11861203
}
11871204
},
1188-
"required": ["goal", "traffic_light"],
1205+
"required": ["goal", "traffic_light", "traffic_jam"],
11891206
"additionalProperties": false
11901207
}
11911208
},

planning/behavior_path_avoidance_module/src/scene.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,6 @@ void AvoidanceModule::fillFundamentalData(AvoidancePlanningData & data, DebugDat
267267
data.reference_path, 0, data.reference_path.points.size(),
268268
motion_utils::calcSignedArcLength(data.reference_path.points, getEgoPosition(), 0));
269269

270-
data.to_return_point = utils::avoidance::calcDistanceToReturnDeadLine(
271-
data.current_lanelets, data.reference_path_rough, planner_data_, parameters_);
272-
273-
data.to_start_point = utils::avoidance::calcDistanceToAvoidStartLine(
274-
data.current_lanelets, data.reference_path_rough, planner_data_, parameters_);
275-
276270
// target objects for avoidance
277271
fillAvoidanceTargetObjects(data, debug);
278272

@@ -286,6 +280,17 @@ void AvoidanceModule::fillFundamentalData(AvoidancePlanningData & data, DebugDat
286280
return a.longitudinal < b.longitudinal;
287281
});
288282

283+
std::sort(data.other_objects.begin(), data.other_objects.end(), [](auto a, auto b) {
284+
return a.longitudinal < b.longitudinal;
285+
});
286+
287+
data.to_return_point = utils::avoidance::calcDistanceToReturnDeadLine(
288+
data.current_lanelets, data.reference_path_rough, data.other_objects, planner_data_,
289+
parameters_);
290+
291+
data.to_start_point = utils::avoidance::calcDistanceToAvoidStartLine(
292+
data.current_lanelets, data.reference_path_rough, planner_data_, parameters_);
293+
289294
// set base path
290295
path_shifter_.setPath(data.reference_path);
291296
}

planning/behavior_path_avoidance_module/src/utils.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ double calcDistanceToAvoidStartLine(
22632263

22642264
double calcDistanceToReturnDeadLine(
22652265
const lanelet::ConstLanelets & lanelets, const PathWithLaneId & path,
2266-
const std::shared_ptr<const PlannerData> & planner_data,
2266+
ObjectDataArray & other_objects, const std::shared_ptr<const PlannerData> & planner_data,
22672267
const std::shared_ptr<AvoidanceParameters> & parameters)
22682268
{
22692269
if (lanelets.empty()) {
@@ -2282,6 +2282,15 @@ double calcDistanceToReturnDeadLine(
22822282
}
22832283
}
22842284

2285+
// dead line stop factor(traffic jam)
2286+
if (parameters->enable_dead_line_for_traffic_jam && !other_objects.empty()) {
2287+
if (filtering_utils::isOnEgoLane(other_objects.front())) {
2288+
distance_to_return_dead_line = std::min(
2289+
distance_to_return_dead_line,
2290+
other_objects.front().longitudinal - parameters->dead_line_buffer_for_traffic_jam);
2291+
}
2292+
}
2293+
22852294
// dead line for goal
22862295
if (
22872296
!utils::isAllowedGoalModification(planner_data->route_handler) &&

0 commit comments

Comments
 (0)