自动驾驶apollo项目从0到1本地亲测

1.apollo项目

apollo是国内百度公司开源的自动驾驶项目,目前在github已经超过20k star,是自动驾驶学习入门比较好的参考资料。

项目地址: apollo项目

趁工作空隙时间,在本地进行了一下测试并成功运行起来。安装调试过程还是比较辛苦的,特此记录一下,方便自己也方便他人。

2.安装ubuntu 18.04

本地安装,需要准备的主要是ubuntu 18.04与docker环境。如果有NVIDIA的GPU,还需要安装NVIDIA GPU的驱动。

ubuntu的官方安装指南
ubuntu安装指南

因为我原来的ubuntu版本是14,所以需要先升级到18。
在升级前,先对apt进行更新

sudo apt update
sudo apt upgrade

因为网络的问题,最好是将apt的源提前换成aliyun,否则可能会更新很慢甚至连不上服务器。

更新完毕,执行命令

sudo apt install update-manager-core

然后用以下命令更新管理器

sudo update-manager -d

这将打开软件更新程序并显示它将通知Ubuntu 18.04的可用性,点击更新按钮即可。
然后顺着提示点击下去,等待系统更新即可,全程只需要网络保持连通。如果中途有提示重启系统,那就重启系统。

3.安装docker

安装docker的过程,来自参考文献1,已经走完流程并测试通过。

3.1 删除旧版本

旧版本的docker称为docker或者docker-engine,我们先删除旧版本

sudo apt-get remove docker docker-engine docker.io

3.2 使用apt安装

由于 apt 源使用 HTTPS 以确保软件下载过程中不被篡改。因此,我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release

前面提到了,需要先将apt源配置成aliyun,否则会很慢。
为了确认所下载软件包的合法性,需要添加软件源的 GPG 密钥。

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

然后,我们需要向 sources.list 中添加 Docker 软件源

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

以上命令会添加稳定版本的 Docker APT 镜像源,如果需要测试版本的 Docker 请将 stable 改为 test。

3.3 安装docker

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

3.4 新建docker用户组

默认情况下,只有root用户与docker组用户才能访问docker引擎。而linux系统一般不会直接使用root用户,因此我们需要将使用docker的用户加入docker用户组。

首先建立 docker 组:

sudo groupadd docker

然后再讲当前用户加入docker用户组

$ sudo usermod -aG docker $USER

退出当前终端并重新登录即可。

3.5测试dokcer是否正常安装

$ docker run --rm hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

若输出上述信息,说明已经正常安装docker。

4.安装apollo

安装apollo的过程,主要是参考官方文档,下面我按照自己安装使用流程,将重点步骤以及注意事项挑出来。

4.1 下载源码

从github上拉下源码,没啥好说的,常规操作。

git clone git@github.com:ApolloAuto/apollo.git
cd apollo
git checkout master

4.2 设置环境变量

echo "export APOLLO_ROOT_DIR=$(pwd)" >> ~/.bashrc  && source ~/.bashrc

4.3 进入apollo docker容器

在$APOLLO_ROOT_DIR下面,进行如下操作

bash docker/scripts/dev_start.sh

成功会有如下显示

[ OK ] Congratulations! You have successfully finished setting up Apollo Dev Environment.
[ OK ] To login into the newly created apollo_dev_michael container, please run the following command:
[ OK ]   bash docker/scripts/dev_into.sh
[ OK ] Enjoy!

此时已经打开了容器,再进入刚打开的容器

bash docker/scripts/dev_into.sh

4.4 编译

进入容器以后,重点来了,开始进行编译

./apollo.sh build_opt

首先,因为项目大,编译过程会很久,此时可以准备好板凳瓜子花生米,再泡杯咖啡。
其次,因为项目大,编译有可能会失败,本人第一次编译的时候,就失败了。第二次,还是失败了。因为接触项目不久,也不是很熟悉,想解决编译的问题,几乎不太可能。
最后,劝大家不要放弃。本人试着拔网线,reboot,第三次再编译,OK了,通过。别问我为什么,问就是不知道。

5.在本地运行

如果上面的安装环节没有问题,运行就比较容易了,具体可以看参考文献3,按照上面的操作执行就可以了。

6.使用release版本

前面我们通过编译源码的方式,会存在编译失败的风险。如果一时半会编译不过无法在本地运行,可以尝试release版本。

release版本最大的优点就是帮我们省了编译的过程,能让我们快速上手实现。
首先我们下载安装包,具体地址见参考文献5。
下载完以后,再进行实验,具体步骤见参考文献6。

特别提醒:
本人在实践尝试release版本过程中,也出现了前两次下载docker容器中镜像不成功整体失败的情况,后来也是尝试了好几次,拔网线reboot最后才成功。猜测可能跟网络有关系?反正也是薛定谔式安装运行,一定要有耐心多尝试几次。

参考文献

1.https://yeasy.gitbook.io/docker_practice/install/ubuntu ubuntu上安装docker
2. https://github.com/ApolloAuto/apollo/blob/master/docs/quickstart/apollo_software_installation_guide.md apollo安装指导文档
3.https://github.com/ApolloAuto/apollo/blob/master/docs/howto/how_to_launch_and_run_apollo.md apollo运行文档
4.https://github.com/ApolloAuto/apollo/blob/master/docs/specs/apollo_build_and_test_explained.md apollo build文档
5.https://developer.apollo.auto/developer_cn.html 快速安装下载
6.https://developer.apollo.auto/document_cn.html?target=/Apollo-Homepage-Document/Apollo_Doc_CN_6_0/%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B/%E4%BD%BF%E7%94%A8Dreamview%E6%9F%A5%E7%9C%8B%E6%95%B0%E6%8D%AE%E5%8C%85

  • 3
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值