【Apollo源码分析】系列的第三部分【prediction】
来源:互联网 发布:sql server 进程死锁 编辑:程序博客网 时间:2024/06/09 08:22
【Apollo源码分析】系列的第三部分【prediction】
prediction
prediction模块目前依然处于待完善的状态,代码大概只有200行左右。
预测模块的任务主要是:接收来自perception感知模块的基本信息,包括障碍物的位置,运动方向角,移动速度,加速度等。然后结合这些信息对障碍物进行轨迹预测trajectories Prediction,综合判断物体移动方向。
prediction/main.cc
先看main.cc的内容,只有一行代码。
APOLLO_MAIN(apollo::prediction::Prediction);
注册Prediction模块,并执行该模块的内容。
prediction/prediction.h
本文件代码也不多。
class Prediction : public apollo::common::ApolloApp {
public:
~Prediction() = default;
std::string Name() const override; //模块名称
common::Status Init() override; //初始化操作
common::Status Start() override; //模块的内容
void Stop() override; //清理函数
private:
void OnPerception(//预测的回调函数
const perception::PerceptionObstacles &perception_obstacles);
};
.cc文件:
apollo::common::Status Prediction::Init() {
AdapterManager::instance()->Init();
//注册预测部分的回调函数
AdapterManager::SetPerceptionObstaclesCallback(&Prediction::OnPerception,this);
return apollo::common::Status::OK();
}
apollo::common::Status Prediction::Start() {
return apollo::common::Status::OK();
}
void Prediction::Stop() {}
以上都是常规例行代码。
void Prediction::OnPerception(const PerceptionObstacles &perception_obstacles) {
PredictionObstacles prediction_obstacles;
AdapterManager::FillPredictionHeader(Name(),
prediction_obstacles.mutable_header());
AdapterManager::PublishPrediction(prediction_obstacles);
//发送预测结果。但是这里并没有任何结果。还需要完善...。
ADEBUG << prediction_obstacles.ShortDebugString();
}
prediction/common/prediction_gflags.h
// System gflags
DECLARE_string(prediction_module_name);//声明模块名称
.cc文件:
// System gflags
DEFINE_string(prediction_module_name, "prediction",
"Default prediciton module name");//定义模块名称
prediction/proto/prediction_obstacle.proto
以下是prediction_obstacle的定义。
syntax = "proto2";
package apollo.prediction;
import "modules/common/proto/error_code.proto";
import "modules/common/proto/header.proto";
import "modules/perception/proto/perception_obstacle.proto";
// 预测的障碍物轨迹节点,[x,y,z]表示位置,velocity表示速度 m/s.
message TrajectoryPoint {
optional double x = 1; // x,y,z表示轨迹point位置,单位是m.
optional double y = 2; //
optional double z = 3; //
optional double velocity = 4; // 速度 v
optional double t = 5; //节点point距离message发布的时间
optional double heading = 6; // head角。
}
//以概率表示的轨迹节点
message Trajectory {
optional double probability = 1; //概率
repeated TrajectoryPoint trajectory_point = 2;//多个轨迹节点point
}
//预测障碍物信息
message PredictionObstacle {
//障碍物描述子
optional apollo.perception.PerceptionObstacle perception_obstacle = 1;
optional double time_stamp = 2; //以GPS计算的时间 GPS time in seconds
// the length of the time for this prediction (e.g. 10s)
optional double predicted_period = 3;//预测持续时间段
repeated Trajectory trajectory = 4;//多个轨迹节点
}
message PredictionObstacles {
optional apollo.common.Header header = 1;
repeated PredictionObstacle prediction_obstacle = 2;//多个预测的障碍物,以概率表示
optional apollo.common.ErrorCode perception_error_code = 3;//预测错误码
}
总结
预测部分的代码就是这么多。是不是很简洁?
自动驾驶难不难?我个人觉得这是一件很难的事情。
但是把复杂的事分解为简单的事的能力却很重要。
Apollo的一个优点是模块化的工作做的非常好。
有很清晰的分工,有良好的架构设计。
最重要的一点:
化繁为简的能力很重要。
过一段时间推荐些 Motion prediction的 文章。
本文首发于微信公众号slamcode
注释版源码:源码
阅读全文
1 0
- 【Apollo源码分析】系列的第三部分【prediction】
- 【Apollo源码分析】系列的第一部分【common】
- 【Apollo源码分析】系列的第二部分【perception】
- 【Apollo源码分析】系列的第四部分【decision】
- 【Apollo源码分析】系列的第五部分【localization】
- 【Apollo源码分析】系列的第六部分【planning】
- 25-总结-【cartographer源码分析】系列的第三部分【sensor源码分析】
- apollo 消息分发源码分析
- 45-总结-【cartographer源码分析】系列的第五部分【kalman_filter】
- 58-总结-【cartographer源码分析】系列的第六部分【 mapping 】
- 自动驾驶框架 Apollo 1.0 -源码分析
- 百度自动驾驶系统Apollo源码分析
- 12-总结-【cartographer源码分析】系列的第一部分【common源码分析】
- 16 -总结-【cartographer源码分析】系列的第二部分【transform源码分析】
- 40-总结-【cartographer源码分析】系列的第四部分【io源码分析】
- ThreadPoolExecutor的部分源码分析
- 第三部分 MediaPlayer的主要实现分析
- 第三部分 需求分析
- c++模板
- php无限分类的删除
- JSON
- Python基础学习<二>
- MySQL定时执行脚本(计划任务)命令实例
- 【Apollo源码分析】系列的第三部分【prediction】
- java 快速幂取模算法
- 20170825考试总结
- 数据类型
- 解决Redis之MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on d
- 初识c#---分支结构
- 日♂常
- 事件对象
- Eclipse下载与安装以及selenium自动化运行浏览器