本文主要是介绍APOLLO:lane_borrow_decider代码解读,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
APOLLO:lane_borrow_decider代码解读
- 一、作用:是否产生变道决策
- 二、数据结构
- 三、代码逻辑
- 四、参考链接
一、作用:是否产生变道决策
是否nuge前方静态、低速障碍物),并将决策结果保存到 reference_line_info和mutable_path_decider_status 中。
二、数据结构
定义了一个path_decider_status:(message PathDeciderStatus)
auto* mutable_path_decider_status = injector_->planning_context() ->mutable_planning_status() ->mutable_path_decider();
Injector_是DependencyInjector类的对象, 通过planning_context()方法返回一个PlanningContext对象, 然后通过mutable_planning_status()返回PlanningStatus 对象,
PlanningStatus 是proto定义的一个类,至于如何通过->mutable_path_decider()调用到PathDeciderStatus,这点还不太清楚。
message PathDeciderStatus {enum LaneBorrowDirection {LEFT_BORROW = 1; // borrow left neighbor laneRIGHT_BORROW = 2; // borrow right neighbor lane}optional int32 front_static_obstacle_cycle_counter = 1 [default = 0];optional int32 able_to_use_self_lane_counter = 2 [default = 0];optional bool is_in_path_lane_borrow_scenario = 3 [default = false];optional string front_static_obstacle_id = 4 [default = ""];repeated LaneBorrowDirection decided_side_pass_direction = 5;
}
三、代码逻辑
1、首先在Process()中判断路径是否复用,如果是则跳过,然后调用IsNecessaryToBorrowLane(*frame, *reference_line_info))来判断是否进行变道,如果是在把变道决策信息存入 reference_line_info中;
2、判断是否变道:
bool PathLaneBorrowDecider::IsNecessaryToBorrowLane(const Frame& frame, const ReferenceLineInfo& reference_line_info) {auto* mutable_path_decider_status = injector_->planning_context()->mutable_planning_status()->mutable_path_decider();//判断当前是否借道场景中if (mutable_path_decider_status->is_in_path_lane_borrow_scenario()) {// If originally borrowing neighbor lane:// 根据数值优化求解轨迹后的信息计算是否退出借道场景(如:避让输出轨迹无解时退出借道)if (mutable_path_decider_status->able_to_use_self_lane_counter() >= 6) {// If have been able to use self-lane for some time, then switch to// non-lane-borrowing.mutable_path_decider_status->set_is_in_path_lane_borrow_scenario(false);mutable_path_decider_status->clear_decided_side_pass_direction();AINFO << "Switch from LANE-BORROW path to SELF-LANE path.";}} else {//如果当前不处于借道场景中,以下条件都满足时才能借道// If originally not borrowing neighbor lane:// ADC requirements check for lane-borrowing:// 只有一条参考线,才能借道// 起点速度小于最大借道允许速度// 阻塞障碍物必须远离路口// 阻塞障碍物会一直存在// 阻塞障碍物与终点位置满足要求// 为可侧面通过的障碍物ADEBUG << "Blocking obstacle ID["<< mutable_path_decider_status->front_static_obstacle_id() << "]";// ADC requirements check for lane-borrowing:if (!HasSingleReferenceLine(frame)) { //只有一条参考线return false;}if (!IsWithinSidePassingSpeedADC(frame)) { //起点速度小于最大借道允许速度return false;}// Obstacle condition check for lane-borrowing:if (!IsBlockingObstacleFarFromIntersection(reference_line_info)) {return false; //阻塞障碍物必须远离路口}if (!IsLongTermBlockingObstacle()) { //阻塞障碍物会一直存在return false;}if (!IsBlockingObstacleWithinDestination(reference_line_info)) {return false; // 阻塞障碍物与终点位置满足要求}if (!IsSidePassableObstacle(reference_line_info)) {return false; //为可侧面通过的障碍物}// switch to lane-borrowing// set side-pass direction// 在无避让方向时重新计算避让方向,若左、右借道空间均不满足则不借道,is_in_path_lane_borrow_scenario_标志为false;// 左借道条件满足左借道、右借道条件满足右借道,is_in_path_lane_borrow_scenario_为true。const auto& path_decider_status =injector_->planning_context()->planning_status().path_decider();if (path_decider_status.decided_side_pass_direction().empty()) {// first time init decided_side_pass_directionbool left_borrowable;bool right_borrowable;//根据车道线类型判断是否可以借道CheckLaneBorrow(reference_line_info, &left_borrowable, &right_borrowable);if (!left_borrowable && !right_borrowable) {mutable_path_decider_status->set_is_in_path_lane_borrow_scenario(false);return false; //左右借道都不满足时,重新计算} else {//满足左侧或者右侧借道条件mutable_path_decider_status->set_is_in_path_lane_borrow_scenario(true);if (left_borrowable) {mutable_path_decider_status->add_decided_side_pass_direction(PathDeciderStatus::LEFT_BORROW);}if (right_borrowable) {mutable_path_decider_status->add_decided_side_pass_direction(PathDeciderStatus::RIGHT_BORROW);}}}AINFO << "Switch from SELF-LANE path to LANE-BORROW path.";}return mutable_path_decider_status->is_in_path_lane_borrow_scenario();
}
2.1 IsWithinSidePassingSpeedADC
bool PathLaneBorrowDecider::IsWithinSidePassingSpeedADC(const Frame& frame) {return frame.PlanningStartPoint().v() < FLAGS_lane_borrow_max_speed;()这个值为5m/s,也就是初始速度不能大于5m/s?
}
2.2 IsLongTermBlockingObstacle() ,FLAGS_long_term_blocking_obstacle_cycle_threshold的默认值是3,具体代表啥意思?
bool PathLaneBorrowDecider::IsLongTermBlockingObstacle() {if (injector_->planning_context()->planning_status().path_decider().front_static_obstacle_cycle_counter() >=FLAGS_long_term_blocking_obstacle_cycle_threshold) {ADEBUG << "The blocking obstacle is long-term existing.";return true;} else {ADEBUG << "The blocking obstacle is not long-term existing.";return false;}
}
2.3IsBlockingObstacleWithinDestination 障碍物不在终点范围内
if (blocking_obstacle_s - adc_end_s >reference_line_info.SDistanceToDestination()) {return false;}return true;I0516 20:26:24.494535 2986 path_lane_borrow_decider.cc:193] Blocking obstacle is at s = 59.4525
I0516 20:26:24.494540 2986 path_lane_borrow_decider.cc:194] ADC is at s = 53.983
I0516 20:26:24.494544 2986 path_lane_borrow_decider.cc:195] Destination is at s = 87.8644
2.4 IsSidePassableObstacle里面的IsNonmovableObstacle,前方最近的障碍物距离自车不是很远(35m),前方最近的障碍物在路边,或者是在停车道上,前方最近的障碍物的前方(15m内)没有其他障碍物
//目标太远,不借道if (obstacle.PerceptionSLBoundary().start_s() >adc_sl_boundary.end_s() + kAdcDistanceThreshold) {ADEBUG << " - It is too far ahead and we are not so sure of its status.";return false;}// Obstacle is parked obstacle.//目标停止时借道if (IsParkedVehicle(reference_line_info.reference_line(), &obstacle)) {ADEBUG << "It is Parked and NON-MOVABLE.";return true;}double delta_s = other_obstacle->PerceptionSLBoundary().start_s() -obstacle.PerceptionSLBoundary().end_s();if (delta_s < 0.0 || delta_s > kObstaclesDistanceThreshold) {continue;}
2.5 CheckLaneBorrow,以2米为间隔遍历车前100m的参考线,判断左右车道线,如果是白线或者黄线,则不变道,log信息如下:
I0516 20:26:24.494583 2986 path_lane_borrow_decider.cc:316] s[53.983] left_lane_boundary_type[DOTTED_YELLOW]
I0516 20:26:24.494601 2986 path_lane_borrow_decider.cc:330] s[53.983] right_neighbor_lane_borrowable[SOLID_WHITE]
I0516 20:26:24.494607 2986 path_lane_borrow_decider.cc:316] s[55.983] left_lane_boundary_type[DOTTED_YELLOW]
I0516 20:26:24.494613 2986 path_lane_borrow_decider.cc:316] s[57.983] left_lane_boundary_type[DOTTED_YELLOW]
I0516 20:26:24.494618 2986 path_lane_borrow_decider.cc:316] s[59.983] left_lane_boundary_type[DOTTED_YELLOW]
I0516 20:26:24.494623 2986 path_lane_borrow_decider.cc:316] s[61.983] left_lane_boundary_type[DOTTED_YELLOW]
I0516 20:26:24.494628 2986 path_lane_borrow_decider.cc:316] s[63.983] left_lane_boundary_type[DOTTED_YELLOW]
I0516 20:26:24.494633 2986 path_lane_borrow_decider.cc:316] s[65.983] left_lane_boundary_type[DOTTED_YELLOW]
I0516 20:26:24.494638 2986 path_lane_borrow_decider.cc:316] s[67.983] left_lane_boundary_type[DOTTED_YELLOW]
四、参考链接
1、参考资料1
2、参考资料2
这篇关于APOLLO:lane_borrow_decider代码解读的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!