这一块代码作用没有看的很明白,后续planning模块若有涉及再结合其他代码一起思考。

Smoother类就是当足够接近停止点10m内,规划轨迹就保持上一帧的数据?来达到平滑的效果?

modules\planning\common\smoothers\smoother.h

#pragma once#include "modules/common/status/status.h"
#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
#include "modules/planning/common/frame.h"
#include "modules/planning/proto/decision.pb.h"namespace apollo {
namespace planning {class Smoother { //Smoother类顾名思义平滑器类?public://默认构造函数及默认析构函数Smoother() = default;  virtual ~Smoother() = default;//核心函数Smooth,输入参数frame_history,current_frame,current_trajectory_pb//current_frame:Frame帧类变量, Frame帧类包含一个规划周期规划所有相关数据//frame_history:FrameHistory帧历史类变量,就是Frame类的队列,所有历史周期的规划相关数据//Frame类型包含哪些内容?参见modules\planning\common\frame.h//Frame类型包含规划sequence_num轨迹段数?local_view规划模块的全部输入,planning_start_point//规划起始点,vehicle_state车辆状态,reference_line_provider道路参考线//current_trajectory_pb用来存放平滑后的结果apollo::common::Status Smooth(const FrameHistory* frame_history,const Frame* current_frame,ADCTrajectory* const current_trajectory_pb);private://是否足够接近停止点?bool IsCloseStop(const common::VehicleState& vehicle_state,const MainStop& main_stop);
};}  // namespace planning
}  // namespace apollo

modules\planning\common\smoothers\smoother.cc

#include "modules/planning/common/smoothers/smoother.h"#include <string>#include "modules/common/configs/vehicle_config_helper.h"
#include "modules/common/math/vec2d.h"
#include "modules/planning/common/planning_gflags.h"namespace apollo {
namespace planning {using apollo::common::ErrorCode;
using apollo::common::Status;
using apollo::common::math::Vec2d; //vec2d就是apollo定义的二维向量数据结构(x,y)//该函数就是判断车辆当前位置到主停止点位置是否已经小于平滑器所需最小距离
//是否接近停止?输入参数车辆状态,
//MainStop类参见modules\planning\proto\decision.proto
//main_stop就是车辆的主停止点?MainStop类是主停止点的数据结构,包含停止点,停止原因航向等
bool Smoother::IsCloseStop(const common::VehicleState& vehicle_state,const MainStop& main_stop) {//判断main_stop是否为空if (!main_stop.has_stop_point()) {ADEBUG << "not close for main stop:" << main_stop.DebugString();return false;}//车辆当前位置(x,y)去初始化Vec2d类对象current_car_posVec2d current_car_pos(vehicle_state.x(), vehicle_state.y());//车辆main_stop主停止点位置(x,y)去初始化Vec2d类对象stop_posVec2d stop_pos(main_stop.stop_point().x(), main_stop.stop_point().y());//距停止点的距离stop_distance 就是车辆当前位置到主停止点的位置的距离//调用vec2d的成员函数.DistanceTo()计算二维向量之间的距离auto stop_distance = stop_pos.DistanceTo(current_car_pos);//如果车辆当前位置到主停止点的距离大于平滑最小距离smoother_stop_distance//FLAGS_是gflag库用法去apollo\modules\planning\common\planning_gflags.cc取出//smoother_stop_distance的值,默认为10m//也就是说如果车辆当前位置到主停止点的距离大于10m那么就返回false否则返回trueif (stop_distance > FLAGS_smoother_stop_distance) {ADEBUG << "distance between ADC position and stop position:"<< stop_distance;return false;}return true;
}//平滑主函数,输入参数规划周期的历史数据frame_history,当前帧规划所有数据current_frame,平滑结果
//放入current_trajectory_pb
apollo::common::Status Smoother::Smooth(const FrameHistory* frame_history, const Frame* current_frame,ADCTrajectory* const current_trajectory_pb) {//如果规划历史周期数据为空,报errorif (frame_history == nullptr) {const std::string msg = "frame history is null.";AERROR << msg;return Status(ErrorCode::PLANNING_ERROR, msg);}//如果规划模块当前周期所有相关数据为空,报errorif (current_frame == nullptr) {const std::string msg = "frame is null.";AERROR << msg;return Status(ErrorCode::PLANNING_ERROR, msg);}//如果平滑前的轨迹指针为空,报errorif (current_trajectory_pb == nullptr) {const std::string msg = "current trajectory pb is null";AERROR << msg;return Status(ErrorCode::PLANNING_ERROR, msg);}//主决策main_decision就是当前轨迹访问成员->decision().main_decision()//decision主要决策是换道,停车,巡航等行为决策//decision详细定义参见modules\planning\proto\decision.protoconst auto& main_decision = current_trajectory_pb->decision().main_decision();//如果主决策没有停车就跳过平滑?if (!main_decision.has_stop()) {// skip for current planning is not stop.ADEBUG << "skip smoothing for current planning is not stop";return Status::OK();}//车辆当前状态vehicle_state通过当前帧frame去获得const auto& vehicle_state = current_frame->vehicle_state();//最大停车速度,即速度小于该值认为车辆已经停住了,实际上是访问配置文件中//max_abs_speed_when_stopped,去vehicle_param里modules\common\data\vehicle_param.pb.txt//找出max_abs_speed_when_stopped的值,默认为0.2m/sconst double max_adc_stop_speed = common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param().max_abs_speed_when_stopped();//如果车辆当前速度大于停车速度//也跳过平滑?if (vehicle_state.linear_velocity() > max_adc_stop_speed) {ADEBUG << "vehicle speed:" << vehicle_state.linear_velocity()<< " skip smoothing for non-stop scenario";return Status::OK();}//如果车辆当前位置距离主停车位置不是足够近的话,也跳过平滑?if (!IsCloseStop(vehicle_state, main_decision.stop())) {ADEBUG << "vehicle state:" << vehicle_state.DebugString()<< " skip smoothing for ADC is not close to stop point";return Status::OK();}//获取前一帧的规划相关所有数据auto previous_frame = frame_history->Latest();//如果前一帧规划数据为空。返回警告信息if (previous_frame == nullptr) {const std::string msg = "previous frame is null";AWARN << msg;return Status(ErrorCode::PLANNING_ERROR, msg);}//将之前一帧的规划结果轨迹也就是当前的规划轨迹存放到previous_planning const auto& previous_planning =previous_frame->current_frame_planned_trajectory();//获取当前轨迹的头部header——包含标题时间戳等?auto header = current_trajectory_pb->header();//当前的规划轨迹存放到current_trajectory_pb 轨迹指针*current_trajectory_pb = previous_planning;//将header又copy进去?不是就从里面拿的吗?current_trajectory_pb->mutable_header()->CopyFrom(header);//smoother_debug为当前规划轨迹的debug下的planning_data下的smootherauto smoother_debug = current_trajectory_pb->mutable_debug()->mutable_planning_data()->mutable_smoother();//设置smoother_debug下的is_smoothed设置为truesmoother_debug->set_is_smoothed(true);//设置smoother_debug下的type设置为SMOOTHER_CLOSE_STOPsmoother_debug->set_type(planning_internal::SmootherDebug::SMOOTHER_CLOSE_STOP);return Status::OK();
}}  // namespace planning
}  // namespace apollo

百度apollo自动驾驶planning代码学习-Apollo/modules/planning/common/Smoother类代码详解相关推荐

  1. Apollo自动驾驶开发笔记47——apollo编译报错this rule is missing dependency declarations for the following files

    Apollo自动驾驶开发笔记47--apollo编译报错this rule is missing dependency declarations for the following files 报错信 ...

  2. 百度语音+自动驾驶感知+深度学习平台技术解析

    HIEV快讯(文/戒僧)本文将解析三部分技术内容,出自百度2023 Create大会-技术开放日: •百度如何用"手机全双工语音交互"改善使用导航应用的体验 •如何用"上 ...

  3. 百度Apollo自动驾驶感知模块学习笔记、入门

    3个跟HM对象跟踪相关的对象类 Object.TrackedObject.ObjectTrack Object类:感知到的车辆信息.包含物体的点云.多边形轮廓(Polygon).类别(vehicle, ...

  4. 聊聊自动驾驶必须解决哪些感知问题?交通标志识别技术详解

    交通标志识别系统是智能交通系统与先进辅助驾驶系统的重要组成部分,由于道路交通较为复杂,提高交通检测与识别算法的准确率和实时性是走向实际应用进程中需要解决的关键问题. 算法的准确率是交通标志识别研究中一 ...

  5. [自动调参]深度学习模型的超参数自动化调优详解

    向AI转型的程序员都关注了这个号

  6. 百度Apollo自动驾驶学习笔记

    Apollo学习笔记 作者:邹镇洪(清华大学车辆学院,个人主页 转到Github项目主页查看持续更新 转到Github项目主页查看持续更新 转到Github项目主页查看持续更新 本文是对百度Apoll ...

  7. apollo自动驾驶进阶学习之:canbus模块代码分析

    文章目录 封面 代码架构 内容结构 封面 apollo自动驾驶:canbus模块代码讲解及测试(1)引言 apollo自动驾驶:canbus模块代码讲解及测试(2)框架讲解 代码架构 但是apollo ...

  8. 解析百度Apollo自动驾驶平台

    最近对百度的自动驾驶平台Apollo项目做了一些了解.下面将我所了解到的一些信息分享给大家. Apollo项目介绍 阿波罗(Apollo)是百度发布的面向汽车行业及自动驾驶领域的合作伙伴提供的软件平台 ...

  9. 百度Apollo自动驾驶专题讲座笔记之运动规划模块

    在百度技术学院有Apollo的技术专题课程,对各个模块都有一个入门级的课程,对于了解各个模块间的相互作用关系有很大的作用,很适合对自动驾驶领域感兴趣的人的入门课程.感谢百度Apollo开放了这么好的课 ...

最新文章

  1. 【1024创造营】精彩课程回顾
  2. redis日志追加频率
  3. 新闻发布系统java ee_Java EE 7发布–反馈和新闻报道
  4. xcode 开发ios兼容性问题的上下黑边 和 coco2d-x 游戏分辨率适配 ResolutionPolicy::FIXED_WIDTH 都会引起上下黑边问题!!!...
  5. 笨办法学 Python · 续 练习 8:`cut`
  6. hue集成mysql报错_hue集成hive访问报database is locked
  7. 变身抓重点小能手:机器学习中的文本摘要入门指南 | 资源
  8. vant组件做表格_vue实现简单表格组件
  9. 软件开发报价的计算方法
  10. 使用iOS AirPrint 让你的APP轻松实现打印功能
  11. CISP考试真题,CISP测试题
  12. POST 请求的四种提交数据方式
  13. 常用照片尺寸对照表,照片大小看这个表就对了
  14. 阿里云Aliplayer视频播放2(断点续播--根据上次播放记录实现续播功能)
  15. Windows API串口编程详解
  16. 天津大学计算机组成原理,天津大学计算机学院计算机组成原理复习材料.docx
  17. 【新知实验室】实时音视频(TRTC)之初体验
  18. Android 7.0 Vold工作流程
  19. babylon创建文字
  20. 30条实用信息教你读懂电影版本

热门文章

  1. 微信也能鉴别山寨iPhone【微信高级教程2】
  2. BZOJ3894 文理分科
  3. Linux 常用命令参考手册, 非常适合入门, 基本能满足工作日常使用。
  4. PhotoScan:为冲印的照片拍摄无眩光照片
  5. 前端常见面试题 - JS篇
  6. 自己做量化交易软件(9通通量化框架的雏形建立
  7. 文件的属性 计算机知识,电脑文件属性是什么
  8. 手风琴控件android,手风琴控件 | Accordion Control
  9. 嵌入式Linux中tmp目录大小修改
  10. 从融360到理财魔方、再到韭菜财经,新金融正确姿势为哪般?