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

相关文章

Python实例题之pygame开发打飞机游戏实例代码

《Python实例题之pygame开发打飞机游戏实例代码》对于python的学习者,能够写出一个飞机大战的程序代码,是不是感觉到非常的开心,:本文主要介绍Python实例题之pygame开发打飞机... 目录题目pygame-aircraft-game使用 Pygame 开发的打飞机游戏脚本代码解释初始化部

Java中Map.Entry()含义及方法使用代码

《Java中Map.Entry()含义及方法使用代码》:本文主要介绍Java中Map.Entry()含义及方法使用的相关资料,Map.Entry是Java中Map的静态内部接口,用于表示键值对,其... 目录前言 Map.Entry作用核心方法常见使用场景1. 遍历 Map 的所有键值对2. 直接修改 Ma

深入解析 Java Future 类及代码示例

《深入解析JavaFuture类及代码示例》JavaFuture是java.util.concurrent包中用于表示异步计算结果的核心接口,下面给大家介绍JavaFuture类及实例代码,感兴... 目录一、Future 类概述二、核心工作机制代码示例执行流程2. 状态机模型3. 核心方法解析行为总结:三

Nacos注册中心和配置中心的底层原理全面解读

《Nacos注册中心和配置中心的底层原理全面解读》:本文主要介绍Nacos注册中心和配置中心的底层原理的全面解读,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录临时实例和永久实例为什么 Nacos 要将服务实例分为临时实例和永久实例?1.x 版本和2.x版本的区别

python获取cmd环境变量值的实现代码

《python获取cmd环境变量值的实现代码》:本文主要介绍在Python中获取命令行(cmd)环境变量的值,可以使用标准库中的os模块,需要的朋友可以参考下... 前言全局说明在执行py过程中,总要使用到系统环境变量一、说明1.1 环境:Windows 11 家庭版 24H2 26100.4061

pandas实现数据concat拼接的示例代码

《pandas实现数据concat拼接的示例代码》pandas.concat用于合并DataFrame或Series,本文主要介绍了pandas实现数据concat拼接的示例代码,具有一定的参考价值,... 目录语法示例:使用pandas.concat合并数据默认的concat:参数axis=0,join=

C#代码实现解析WTGPS和BD数据

《C#代码实现解析WTGPS和BD数据》在现代的导航与定位应用中,准确解析GPS和北斗(BD)等卫星定位数据至关重要,本文将使用C#语言实现解析WTGPS和BD数据,需要的可以了解下... 目录一、代码结构概览1. 核心解析方法2. 位置信息解析3. 经纬度转换方法4. 日期和时间戳解析5. 辅助方法二、L

Python使用Code2flow将代码转化为流程图的操作教程

《Python使用Code2flow将代码转化为流程图的操作教程》Code2flow是一款开源工具,能够将代码自动转换为流程图,该工具对于代码审查、调试和理解大型代码库非常有用,在这篇博客中,我们将深... 目录引言1nVflRA、为什么选择 Code2flow?2、安装 Code2flow3、基本功能演示

C++类和对象之默认成员函数的使用解读

《C++类和对象之默认成员函数的使用解读》:本文主要介绍C++类和对象之默认成员函数的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、默认成员函数有哪些二、各默认成员函数详解默认构造函数析构函数拷贝构造函数拷贝赋值运算符三、默认成员函数的注意事项总结一

IIS 7.0 及更高版本中的 FTP 状态代码

《IIS7.0及更高版本中的FTP状态代码》本文介绍IIS7.0中的FTP状态代码,方便大家在使用iis中发现ftp的问题... 简介尝试使用 FTP 访问运行 Internet Information Services (IIS) 7.0 或更高版本的服务器上的内容时,IIS 将返回指示响应状态的数字代