APOLLO:lane_borrow_decider代码解读

2023-10-17 01:59

本文主要是介绍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代码解读的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/222191

相关文章

解读GC日志中的各项指标用法

《解读GC日志中的各项指标用法》:本文主要介绍GC日志中的各项指标用法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、基础 GC 日志格式(以 G1 为例)1. Minor GC 日志2. Full GC 日志二、关键指标解析1. GC 类型与触发原因2. 堆

Java设计模式---迭代器模式(Iterator)解读

《Java设计模式---迭代器模式(Iterator)解读》:本文主要介绍Java设计模式---迭代器模式(Iterator),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录1、迭代器(Iterator)1.1、结构1.2、常用方法1.3、本质1、解耦集合与遍历逻辑2、统一

Java中调用数据库存储过程的示例代码

《Java中调用数据库存储过程的示例代码》本文介绍Java通过JDBC调用数据库存储过程的方法,涵盖参数类型、执行步骤及数据库差异,需注意异常处理与资源管理,以优化性能并实现复杂业务逻辑,感兴趣的朋友... 目录一、存储过程概述二、Java调用存储过程的基本javascript步骤三、Java调用存储过程示

Visual Studio 2022 编译C++20代码的图文步骤

《VisualStudio2022编译C++20代码的图文步骤》在VisualStudio中启用C++20import功能,需设置语言标准为ISOC++20,开启扫描源查找模块依赖及实验性标... 默认创建Visual Studio桌面控制台项目代码包含C++20的import方法。右键项目的属性:

MySQL之InnoDB存储页的独立表空间解读

《MySQL之InnoDB存储页的独立表空间解读》:本文主要介绍MySQL之InnoDB存储页的独立表空间,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、背景2、独立表空间【1】表空间大小【2】区【3】组【4】段【5】区的类型【6】XDES Entry区结构【

MySQL数据库的内嵌函数和联合查询实例代码

《MySQL数据库的内嵌函数和联合查询实例代码》联合查询是一种将多个查询结果组合在一起的方法,通常使用UNION、UNIONALL、INTERSECT和EXCEPT关键字,下面:本文主要介绍MyS... 目录一.数据库的内嵌函数1.1聚合函数COUNT([DISTINCT] expr)SUM([DISTIN

Java实现自定义table宽高的示例代码

《Java实现自定义table宽高的示例代码》在桌面应用、管理系统乃至报表工具中,表格(JTable)作为最常用的数据展示组件,不仅承载对数据的增删改查,还需要配合布局与视觉需求,而JavaSwing... 目录一、项目背景详细介绍二、项目需求详细介绍三、相关技术详细介绍四、实现思路详细介绍五、完整实现代码

Go语言代码格式化的技巧分享

《Go语言代码格式化的技巧分享》在Go语言的开发过程中,代码格式化是一个看似细微却至关重要的环节,良好的代码格式化不仅能提升代码的可读性,还能促进团队协作,减少因代码风格差异引发的问题,Go在代码格式... 目录一、Go 语言代码格式化的重要性二、Go 语言代码格式化工具:gofmt 与 go fmt(一)

MySQL主从复制与读写分离的用法解读

《MySQL主从复制与读写分离的用法解读》:本文主要介绍MySQL主从复制与读写分离的用法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、主从复制mysql主从复制原理实验案例二、读写分离实验案例安装并配置mycat 软件设置mycat读写分离验证mycat读

Python的端到端测试框架SeleniumBase使用解读

《Python的端到端测试框架SeleniumBase使用解读》:本文主要介绍Python的端到端测试框架SeleniumBase使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录SeleniumBase详细介绍及用法指南什么是 SeleniumBase?SeleniumBase