Apollo无人车入门


先插播一条广告,这里有完整的优达学城(udacity)无人驾驶车完整的教程,带中英文字幕(每一学期的中英文字幕都有哟!),对学习自动驾驶的小伙伴帮助很大,需要的私信我, 嘻嘻~~。
在这里插入图片描述

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官方文档

通用组件例子
定时器组件例子
img

通过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 的触发有两种方式:

  1. 指定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;
        }
      
  2. 定时器触发

    • 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;
      }
      

常用运行命令

  1. 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
  1. 启动dreamview运行
bash scripts/bootstrap.sh start
  1. 回放包文件
cyber_recorder play -f data/bag/20190716141739.record.00001 -s 10 -l 
  1. 启动/关闭某一个模块
cyber_launch start modules/planning/launch/planning.launch
cyber_launch stop
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值