文章目录
先插播一条广告,这里有完整的优达学城(udacity)无人驾驶车完整的教程,带中英文字幕(每一学期的中英文字幕都有哟!),对学习自动驾驶的小伙伴帮助很大,需要的私信我, 嘻嘻~~。
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200515143727146.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L09fTU1NTV9P,size_16,color_FFFFFF,t_70)
Apollo Cyber架构
Cyber 介绍
Apollo 3.5开始使用Cyber1作为自动驾驶框架,取代原有的ROS.每个模块,如感知,预测都作为一个组件实现.每个模块框架(套路)的主要变化有:
-
模块的编译出一个库,而不是可执行文件,因此模块启动需要编写一个launch文件.
1. The name of the component 2. The dag file you just created in the previous step. 3. The name of the process which the component runs within <cyber> <component> <name>common</name> <dag_conf>/apollo/cyber/examples/common_component_example/common.dag</dag_conf> <process_name>common</process_name> </component> </cyber>
-
通过dag文件来配置启动参数,如Reader的配置信息,而原本通过Adapter配置ROS的订阅信息.
1. Channel names: for data input and output 2. Library path: library built from component class 3. Class name: the class name of the component # Define all coms in DAG streaming. component_config { component_library : "/apollo/bazel-bin/cyber/examples/common_component_example/libcommon_component_example.so" components { class_name : "CommonComponentSample" config { name : "common" readers { channel: "/apollo/prediction" } readers { channel: "/apollo/test" } } } }
启动/关闭某一个模块
cyber_launch start modules/planning/launch/planning.launch cyber_launch stop modules/planning/launch/planning.launch ---------------------------或者------------------------ mainboard -d modules/prediction/dag/prediction.dag
例子参见Apollo官方文档。
通过dag文件描述任务,然后通过Mainboard调度程序加载进去mainboard -d modules/prediction/dag/prediction.dag
某一个模块任务,开始运行程序。
component
Apollo Cyber RT框架基于组件的概念构建、加载各功能模块。Localization、Perception、Prediction、Planning、Control等功能模块均作为Apollo Cyber RT框架的一个组件而存在,基于Cyber RT提供的调度程序Mainboard加载运行。
Cyber RT为开发者提供了Component 类,开发者的算法业务模块只需要继承该类,实现其中的 Proc 接口即可。该接口类似于 ROS 中的 Callback,消息通过参数的方式传递,用户只要在Proc中实现算法、消息处理相关的逻辑。
Proc 的触发有两种方式:
-
指定channel msg触发
-
感知模块
class SegmentationComponent : public cyber::Component<drivers::PointCloud> { public: bool Init() override; bool Proc(const std::shared_ptr<drivers::PointCloud>& message) override; }
-
预测模块
class PredictionComponent : public cyber::Component<perception::PerceptionObstacles> { public: bool Init() override; /** * @brief Data callback upon receiving a perception obstacle message. * @param Perception obstacle message. */ bool Proc(const std::shared_ptr<perception::PerceptionObstacles>&) override; }
-
规划模块
class PlanningComponent final : public cyber::Component<prediction::PredictionObstacles, canbus::Chassis, localization::LocalizationEstimate> { 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; }
-
-
定时器触发
-
canbus模块
class CanbusComponent final : public apollo::cyber::TimerComponent { private: bool Init() override; /** * @brief module on_time function */ bool Proc() override; }
-
control模块
class ControlComponent final : public apollo::cyber::TimerComponent { friend class ControlTestBase; public: bool Init() override; bool Proc() override; }
-
常用运行命令
- docker中编译组件
bash apollo.sh -h
Options:
build: run build only
build_opt: build optimized binary for the code
build_cpu: dbg build with CPU
build_gpu: run build only with Caffe GPU mode support
build_opt_gpu: build optimized binary with Caffe GPU mode support
build_fe: compile frontend javascript code, this requires all the node_modules to be installed already
build_drivers [dbg|opt]: build drivers only
build_planning: compile planning and its dependencies.
build_control: compile control and its dependencies.
build_prediction: compile prediction and its dependencies.
-----------------------------------------------------------------------------------------
bash apollo.sh build
- 启动dreamview运行
bash scripts/bootstrap.sh start
- 回放包文件
cyber_recorder play -f data/bag/20190716141739.record.00001 -s 10 -l
- 启动/关闭某一个模块
cyber_launch start modules/planning/launch/planning.launch
cyber_launch stop