ApolloCyberRT学习日记(一)

更新时间:2023-05-28 07:00:01 阅读: 评论:0

ApolloCyberRT学习⽇记(⼀)
ROS学习⽇记(⼀)
Cyber RT介绍
Apollo Cyber RT是百度⾃研得⽆⼈车计算任务实时并⾏计算框架,Apollo Cyber RT框架基于组件的概念构建、加载各功能模块。Localization、 Perception、Prediction、Planning、Control等功能模块均作为Apollo Cyber RT框架的⼀个组件⽽存在,基于Cyber RT提供的调度程序mainboard加载运⾏。实际上,在框架中,每个组件代表⼀个专⽤的算法模块。
Apollo Cyber RT framework is built bad on the concept of component. As a basic building block of Apollo Cyber RT framework, each component contains a specific algorithm module which process a t of data inputs and generate a t of outputs.
Apollo Cyber RT is an open source, high performance runtime framework designed specifically for autonomous driving scenarios. Bad on a centralized computing model, it is greatly optimized for high concurrency, low latency, and high throughput in autonomous driving.汽车挡风玻璃修复
During the last few years of the development of autonomous driving technologies, we have learned a
lot from our previous experience with Apollo. The industry is evolving and so is Apollo. Going forward, Apollo has already moved from development to productization, with volume deployments in the real world, we e the demands for the highest level of robustness and performance. That’s why we spent years building and perfecting Apollo Cyber RT, which address that requirements of autonomous driving solutions.
Cyber官⽅⽂档总结
由于我学习Cyber RT是通过查看apollo的源码中的帮助⽂档学习,所以在此将⽂档内容进⾏总结,具体细节可以查看apollo源码中的相关⽂档。
1.Cyber RT的专有名词解释
⽬录:apollo/docs/cyber/CyberRT_Terms.md
Component
In an autonomous driving system, modules(like perception, localization, control systems…) exist in the form of components under Cyber RT. Each component communicates with the others through Cyber channels. The component concept not only decouples modules but also provides the flexibility for modules to be divided into components bad individual module design.
Channel
Channels are ud to manage data communication in Cyber RT. Urs can publish/subscribe to the same channel to
achieve p2p communication.
Task
唐朝窦皇后Task is the abstract description of an asynchronous computation task in Cyber RT.
Node
Node is the fundamental building block of Cyber RT; every module contains and communicates through the node. A module can have different types of communication by defining read/write and/or rvice/client in a node.
Reader/Writer
Message read/write class from/to channel. Reader/Writer are normally created within a node as the major message transfer interface in Cyber RT.
Service/Client事业单位考核办法
Besides Reader/writer, Cyber RT also provides rvice/client pattern for module communication. It supports two-way communication between nodes. A client node will receive a respon when a request is made to a rvice.
Parameter
Parameter rvice provides a global parameter access interface in Cyber RT. It’s built bad on the rvice/client pattern.
Service discovery
As a decentralized design framework, Cyber RT does not have a master/central node for rvice registration. All nodes are treated equally and can find other rvice nodes through rvice discovery. UDP is ud in Service discovery.
CRoutine
Referred to as Coroutine concept, Cyber RT implemented CRoutine to optimize thread usage and system resource allocation.
Scheduler
To better support autonomous driving scenarios, Cyber RT provides different kinds of resource scheduling algorithms for developers to choo from.
Message
Message is the data unit ud in Cyber RT for data transfer between modules.
Dag file
Dag file is the config file of module topology. You can define components ud and upstream/downstream channels in the dag file.
Launch files
The Launch file provides an easy way to start modules. By defining one or multiple dag files in the launch file, you can start multiple modules at the same time.
Record file
The Record file is ud to record messages nt/received to/from channels in Cyber RT. Reply record files can help reproduce the behavior of previous operations of Cyber RT.
2.创建并运⾏⼀个新的组件 in Apollo Cyber RT
⽬录:apollo/docs/cyber/CyberRT_Quick_Start.md
⽂档所述,要创建并启动⼀个算法组件,需要通过以下 4 个步骤:
初始化组件的⽂件结构
实现组件类
实现组件头⽂件
实现组件源⽂件
创建 BUILD 编译⽂件
设置配置⽂件
配置 DAG 依赖⽂件
配置 launch 启动⽂件
启动组件
如果想更深⼊的探索 Apollo Cyber RT 框架,可以在这个⽬录/apollo/cyber/examples/找到很多例⼦,这些例⼦详细展⽰了如何使⽤Cyber 框架的各种功能。
Note: 这些例⼦必须运⾏在 Apollo docker 环境, 且需要通过 Bazel 来编译。
因此可以按该流程将原基于ROS的module移植到基于Cyber RT,接下来将基于该官⽅指导⽂档,以Planning模块为例讲述如何移植。2.1 初始化组件⽂件结构
热汤面条怎么做好吃基于路径${APOLLO_HOME}/modules/planning(${APOLLO_HOME}表⽰Apollo项⽬的根⽬录,以我的机器为例,Docker外部
为/home/charles/code/apollo,Docker内部全部为/apollo。为描述简单起见,下⽂全部以Docker内部的路径/apollo为准)设置如下组件⽂件结构:
怎样找回qq密码Header file: planning_component.h
Source file:
Build file: BUILD带梦的诗句
DAG dependency file: dag/planning.dag
Launch file: launch/planning.launch
2.2 实现组件类
实现组件类步骤如下:
基于模板类 Component 派⽣出规划模块的组件类PlanningComponent
在派⽣类PlanningComponent中覆盖虚函数Init()和Proc(),其中Proc()需要指定输⼊数椐类型。
使⽤宏CYBER_REGISTER_COMPONENT(PlanningComponent)注册组件类PlanningComponent,以便Cyber RT能正确创建并加载该类对象。这⾥可以参考博客
2.2.1 实现组件头⽂件,组件类PlanningComponent的声明
⽂件⽬录:/apollo/modules/planning/planning_component.h
namespace apollo {
namespace planning {
class PlanningComponent final
:public cyber::Component<prediction::PredictionObstacles, canbus::Chassis,                              localization::LocalizationEstimate>{
public:
PlanningComponent()=default;
~PlanningComponent()=default;
public:
bool Init() override;
bool Proc(const std::shared_ptr<prediction::PredictionObstacles>&
prediction_obstacles,
const std::shared_ptr<canbus::Chassis>& chassis,
const std::shared_ptr<localization::LocalizationEstimate>&
localization_estimate) override;
private:
void CheckRerouting();
bool CheckInput();
private:
std::shared_ptr<cyber::Reader<perception::TrafficLightDetection>>
traffic_light_reader_;
std::shared_ptr<cyber::Reader<routing::RoutingRespon>> routing_reader_;  std::shared_ptr<cyber::Reader<planning::PadMessage>> pad_msg_reader_;
std::shared_ptr<cyber::Reader<relative_map::MapMsg>> relative_map_reader_;
std::shared_ptr<cyber::Writer<ADCTrajectory>> planning_writer_;
std::shared_ptr<cyber::Writer<routing::RoutingRequest>> rerouting_writer_;
std::mutex mutex_;
perception::TrafficLightDetection traffic_light_;
祭灵魂
routing::RoutingRespon routing_;
planning::PadMessage pad_msg_;
relative_map::MapMsg relative_map_;
LocalView local_view_;
std::unique_ptr<PlanningBa> planning_ba_;
PlanningConfig config_;
};
CYBER_REGISTER_COMPONENT(PlanningComponent)
}// namespace planning
}// namespace apollo
注意到基类Component的定义为:
可见,Component类最多接受4个模板参数,每个模板参数均表⽰⼀种输⼊的消息类型,这些消息在Proc函数中被周期性地接收并处理;⽽PlanningComponent继承的是该模板类接受3个参数的⼀个特化版本:
testo350
即PlanningComponent继承⾃cyber::Component<prediction::PredictionObstacles,canbus::Chassis,localization::LocalizationEstimate>,3个消息参数分别为:prediction::PredictionObstacles、canbus::Chassis、localization::LocalizationEstimate,这些消息在Proc函数中被周期性地接收并处理。
2.2.2 实现组件源⽂件,组件类PlanningComponent的实现
⽂件⽬录:/apollo/modules/planning/
对于源⽂件 common_, Init 和 Proc 这两个函数需要实现。所以对于PlanningComponent的实现主要包括两个覆盖的虚函数Init() and Proc()函数:

本文发布于:2023-05-28 07:00:01,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/941083.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:组件   实现   源码   模板   函数   消息   参数
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图