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

相关文章

C++使用栈实现括号匹配的代码详解

《C++使用栈实现括号匹配的代码详解》在编程中,括号匹配是一个常见问题,尤其是在处理数学表达式、编译器解析等任务时,栈是一种非常适合处理此类问题的数据结构,能够精确地管理括号的匹配问题,本文将通过C+... 目录引言问题描述代码讲解代码解析栈的状态表示测试总结引言在编程中,括号匹配是一个常见问题,尤其是在

Java调用DeepSeek API的最佳实践及详细代码示例

《Java调用DeepSeekAPI的最佳实践及详细代码示例》:本文主要介绍如何使用Java调用DeepSeekAPI,包括获取API密钥、添加HTTP客户端依赖、创建HTTP请求、处理响应、... 目录1. 获取API密钥2. 添加HTTP客户端依赖3. 创建HTTP请求4. 处理响应5. 错误处理6.

使用 sql-research-assistant进行 SQL 数据库研究的实战指南(代码实现演示)

《使用sql-research-assistant进行SQL数据库研究的实战指南(代码实现演示)》本文介绍了sql-research-assistant工具,该工具基于LangChain框架,集... 目录技术背景介绍核心原理解析代码实现演示安装和配置项目集成LangSmith 配置(可选)启动服务应用场景

Python中顺序结构和循环结构示例代码

《Python中顺序结构和循环结构示例代码》:本文主要介绍Python中的条件语句和循环语句,条件语句用于根据条件执行不同的代码块,循环语句用于重复执行一段代码,文章还详细说明了range函数的使... 目录一、条件语句(1)条件语句的定义(2)条件语句的语法(a)单分支 if(b)双分支 if-else(

MySQL数据库函数之JSON_EXTRACT示例代码

《MySQL数据库函数之JSON_EXTRACT示例代码》:本文主要介绍MySQL数据库函数之JSON_EXTRACT的相关资料,JSON_EXTRACT()函数用于从JSON文档中提取值,支持对... 目录前言基本语法路径表达式示例示例 1: 提取简单值示例 2: 提取嵌套值示例 3: 提取数组中的值注意

CSS3中使用flex和grid实现等高元素布局的示例代码

《CSS3中使用flex和grid实现等高元素布局的示例代码》:本文主要介绍了使用CSS3中的Flexbox和Grid布局实现等高元素布局的方法,通过简单的两列实现、每行放置3列以及全部代码的展示,展示了这两种布局方式的实现细节和效果,详细内容请阅读本文,希望能对你有所帮助... 过往的实现方法是使用浮动加

JAVA调用Deepseek的api完成基本对话简单代码示例

《JAVA调用Deepseek的api完成基本对话简单代码示例》:本文主要介绍JAVA调用Deepseek的api完成基本对话的相关资料,文中详细讲解了如何获取DeepSeekAPI密钥、添加H... 获取API密钥首先,从DeepSeek平台获取API密钥,用于身份验证。添加HTTP客户端依赖使用Jav

Java实现状态模式的示例代码

《Java实现状态模式的示例代码》状态模式是一种行为型设计模式,允许对象根据其内部状态改变行为,本文主要介绍了Java实现状态模式的示例代码,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来... 目录一、简介1、定义2、状态模式的结构二、Java实现案例1、电灯开关状态案例2、番茄工作法状态案例

nginx-rtmp-module模块实现视频点播的示例代码

《nginx-rtmp-module模块实现视频点播的示例代码》本文主要介绍了nginx-rtmp-module模块实现视频点播,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习... 目录预置条件Nginx点播基本配置点播远程文件指定多个播放位置参考预置条件配置点播服务器 192.

MySQL中的MVCC底层原理解读

《MySQL中的MVCC底层原理解读》本文详细介绍了MySQL中的多版本并发控制(MVCC)机制,包括版本链、ReadView以及在不同事务隔离级别下MVCC的工作原理,通过一个具体的示例演示了在可重... 目录简介ReadView版本链演示过程总结简介MVCC(Multi-Version Concurr