@@ -209,127 +209,6 @@ void clipPathLength(
209
209
clipPathLength (path, target_idx, params.forward_path_length , params.backward_path_length );
210
210
}
211
211
212
- std::pair<TurnIndicatorsCommand, double > getPathTurnSignal (
213
- const lanelet::ConstLanelets & current_lanes, const ShiftedPath & path,
214
- const ShiftLine & shift_line, const Pose & pose, const double & velocity,
215
- const BehaviorPathPlannerParameters & common_parameter)
216
- {
217
- TurnIndicatorsCommand turn_signal;
218
- turn_signal.command = TurnIndicatorsCommand::NO_COMMAND;
219
- const double max_time = std::numeric_limits<double >::max ();
220
- const double max_distance = std::numeric_limits<double >::max ();
221
- if (path.shift_length .size () < shift_line.end_idx + 1 ) {
222
- return std::make_pair (turn_signal, max_distance);
223
- }
224
- const auto base_link2front = common_parameter.base_link2front ;
225
- const auto vehicle_width = common_parameter.vehicle_width ;
226
- const auto shift_to_outside = vehicle_width / 2 ;
227
- const auto turn_signal_shift_length_threshold =
228
- common_parameter.turn_signal_shift_length_threshold ;
229
- const auto turn_signal_minimum_search_distance =
230
- common_parameter.turn_signal_minimum_search_distance ;
231
- const auto turn_signal_search_time = common_parameter.turn_signal_search_time ;
232
- constexpr double epsilon = 1e-6 ;
233
- const auto arc_position_current_pose = lanelet::utils::getArcCoordinates (current_lanes, pose);
234
-
235
- // Start turn signal when 1 or 2 is satisfied
236
- // 1. time to shift start point is less than prev_sec
237
- // 2. distance to shift point is shorter than tl_on_threshold_long
238
-
239
- // Turn signal on when conditions below are satisfied
240
- // 1. lateral offset is larger than tl_on_threshold_lat for left signal
241
- // smaller than tl_on_threshold_lat for right signal
242
- // 2. side point at shift start/end point cross the line
243
- const double distance_to_shift_start =
244
- std::invoke ([¤t_lanes, &shift_line, &arc_position_current_pose]() {
245
- const auto arc_position_shift_start =
246
- lanelet::utils::getArcCoordinates (current_lanes, shift_line.start );
247
- return arc_position_shift_start.length - arc_position_current_pose.length ;
248
- });
249
-
250
- const auto time_to_shift_start =
251
- (std::abs (velocity) < epsilon) ? max_time : distance_to_shift_start / velocity;
252
-
253
- const double diff =
254
- path.shift_length .at (shift_line.end_idx ) - path.shift_length .at (shift_line.start_idx );
255
-
256
- Pose shift_start_point = path.path .points .at (shift_line.start_idx ).point .pose ;
257
- Pose shift_end_point = path.path .points .at (shift_line.end_idx ).point .pose ;
258
- Pose left_start_point = shift_start_point;
259
- Pose right_start_point = shift_start_point;
260
- Pose left_end_point = shift_end_point;
261
- Pose right_end_point = shift_end_point;
262
- {
263
- const double start_yaw = tf2::getYaw (shift_line.start .orientation );
264
- const double end_yaw = tf2::getYaw (shift_line.end .orientation );
265
- left_start_point.position .x -= std::sin (start_yaw) * (shift_to_outside);
266
- left_start_point.position .y += std::cos (start_yaw) * (shift_to_outside);
267
- right_start_point.position .x -= std::sin (start_yaw) * (-shift_to_outside);
268
- right_start_point.position .y += std::cos (start_yaw) * (-shift_to_outside);
269
- left_end_point.position .x -= std::sin (end_yaw) * (shift_to_outside);
270
- left_end_point.position .y += std::cos (end_yaw) * (shift_to_outside);
271
- right_end_point.position .x -= std::sin (end_yaw) * (-shift_to_outside);
272
- right_end_point.position .y += std::cos (end_yaw) * (-shift_to_outside);
273
- }
274
-
275
- bool left_start_point_is_in_lane = false ;
276
- bool right_start_point_is_in_lane = false ;
277
- bool left_end_point_is_in_lane = false ;
278
- bool right_end_point_is_in_lane = false ;
279
- {
280
- for (const auto & llt : current_lanes) {
281
- if (lanelet::utils::isInLanelet (left_start_point, llt, 0.1 )) {
282
- left_start_point_is_in_lane = true ;
283
- }
284
- if (lanelet::utils::isInLanelet (right_start_point, llt, 0.1 )) {
285
- right_start_point_is_in_lane = true ;
286
- }
287
- if (lanelet::utils::isInLanelet (left_end_point, llt, 0.1 )) {
288
- left_end_point_is_in_lane = true ;
289
- }
290
- if (lanelet::utils::isInLanelet (right_end_point, llt, 0.1 )) {
291
- right_end_point_is_in_lane = true ;
292
- }
293
- }
294
- }
295
-
296
- const bool cross_line = std::invoke ([&]() {
297
- constexpr bool temporary_set_cross_line_true =
298
- true ; // due to a bug. See link:
299
- // https://github.com/autowarefoundation/autoware.universe/pull/748
300
- if (temporary_set_cross_line_true) {
301
- return true ;
302
- }
303
- return (
304
- left_start_point_is_in_lane != left_end_point_is_in_lane ||
305
- right_start_point_is_in_lane != right_end_point_is_in_lane);
306
- });
307
-
308
- if (
309
- time_to_shift_start < turn_signal_search_time ||
310
- distance_to_shift_start < turn_signal_minimum_search_distance) {
311
- if (diff > turn_signal_shift_length_threshold && cross_line) {
312
- turn_signal.command = TurnIndicatorsCommand::ENABLE_LEFT;
313
- } else if (diff < -turn_signal_shift_length_threshold && cross_line) {
314
- turn_signal.command = TurnIndicatorsCommand::ENABLE_RIGHT;
315
- }
316
- }
317
-
318
- // calc distance from ego vehicle front to shift end point.
319
- const double distance_from_vehicle_front =
320
- std::invoke ([¤t_lanes, &shift_line, &arc_position_current_pose, &base_link2front]() {
321
- const auto arc_position_shift_end =
322
- lanelet::utils::getArcCoordinates (current_lanes, shift_line.end );
323
- return arc_position_shift_end.length - arc_position_current_pose.length - base_link2front;
324
- });
325
-
326
- if (distance_from_vehicle_front >= 0.0 ) {
327
- return std::make_pair (turn_signal, distance_from_vehicle_front);
328
- }
329
-
330
- return std::make_pair (turn_signal, max_distance);
331
- }
332
-
333
212
PathWithLaneId convertWayPointsToPathWithLaneId (
334
213
const autoware::freespace_planning_algorithms::PlannerWaypoints & waypoints,
335
214
const double velocity, const lanelet::ConstLanelets & lanelets)
@@ -431,18 +310,6 @@ void correctDividedPathVelocity(std::vector<PathWithLaneId> & divided_paths)
431
310
}
432
311
}
433
312
434
- bool isCloseToPath (const PathWithLaneId & path, const Pose & pose, const double distance_threshold)
435
- {
436
- for (const auto & point : path.points ) {
437
- const auto & p = point.point .pose .position ;
438
- const double dist = std::hypot (pose.position .x - p.x , pose.position .y - p.y );
439
- if (dist < distance_threshold) {
440
- return true ;
441
- }
442
- }
443
- return false ;
444
- }
445
-
446
313
// only two points is supported
447
314
std::vector<double > splineTwoPoints (
448
315
const std::vector<double > & base_s, const std::vector<double > & base_x, const double begin_diff,
@@ -579,16 +446,6 @@ PathWithLaneId combinePath(const PathWithLaneId & path1, const PathWithLaneId &
579
446
return filtered_path;
580
447
}
581
448
582
- std::optional<Pose> getFirstStopPoseFromPath (const PathWithLaneId & path)
583
- {
584
- for (const auto & p : path.points ) {
585
- if (std::abs (p.point .longitudinal_velocity_mps ) < 0.01 ) {
586
- return p.point .pose ;
587
- }
588
- }
589
- return std::nullopt;
590
- }
591
-
592
449
BehaviorModuleOutput getReferencePath (
593
450
const lanelet::ConstLanelet & current_lane,
594
451
const std::shared_ptr<const PlannerData> & planner_data)
0 commit comments