最近開始搭建apollo環境,記錄一下搭建過程。
百度Apollo1.0 Github:https://github.com/ApolloAuto/apollo/tree/r1.0.0
1. 安裝Ubuntu14.04雙系統
由於apollo1.0官方推薦環境是Ubuntu14.04,那么就直接按着官方推薦的來。
關於雙系統的安裝就不多贅述了,很多博主也寫的很詳細,大家按着來一般都沒啥問題。
這里貼兩個資源吧,一個Ubuntu14.04的阿里雲下載鏈接,一個U盤啟動盤制作工具:
- http://mirrors.aliyun.com/ubuntu-releases/14.04/
- 鏈接:https://pan.baidu.com/s/1v9lLHGK48jRY0piprn3pkQ
- 提取碼:enj9
在Windows上給Ubuntu分區的時候如果磁盤多的話可以分大點,盡量60G往上,然后在安裝Ubuntu時電腦內存小的話盡量分一個swap區,省得在后面編譯apollo時報錯。
2. 下載Apollo r1.0.0源碼
進入Ubuntu系統,可以在上面給的github鏈接直接下載源碼,也可以通過git下載。
git下載的話首先打開終端(ctrl+alt+t)安裝git:
sudo apt-get install git
下載指定版本:
git clone --branch v1.0.0 https://github.com/ApolloAuto/apollo.git
下載后應該是一個apollo-r.1.0.0的壓縮包。
在Download文件夾下找到這個包,拉到home下解壓,修改名字為apollo。
3. 安裝ROS indigo
#添加源 sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list' #設置key wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
#更新源 sudo apt-get update #下載安裝,半小時左右 sudo apt-get install ros-indigo-desktop-full #初始化ros,若提示rosdep update 則執行rosdep update sudo rosdep init #設置環境變量 echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc source ~/.bashrc
4. 更換Apollo的kernel
在Apollo官方Github下載1.5.0內核:
https://github.com/ApolloAuto/apollo-kernel/releases

下載完后解壓安裝:
tar zxvf linux-4.4.32-apollo-1.0.0.tar.gz cd install sudo ./install_kernel.sh
重啟機器使內核生效:
sudo reboot
查看內核:
cat /proc/version
5. 安裝Docker-ce
#若之前安裝過其他版本的docker,先刪除,沒有的話不用執行 sudo apt-get remove docker docker-engine docker.io #安裝依賴 sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common #添加key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#arm64架構的計算機,添加軟件倉庫: sudo add-apt-repository \ "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \ stable" #若非arm64架構,如樹莓派或其它ARM架構計算機,請運行: echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list #安裝docker-ce sudo apt-get update sudo apt-get install docker-ce #添加用戶組 sudo groupadd docker #將自己的用戶名添加進用戶組(myusername修改為你的計算機用戶名) sudo gpasswd -a myusername docker #重啟docker后台服務(如果沒把docker加入開機自動啟動,每次啟動apollo之前都得執行一次該語句) sudo service docker restart #切換用戶 newgrp - docker #確認docker可以非sudo運行 docker ps
6. 安裝apollo-platform
下載apollo-platfor並解壓
https://github.com/ApolloAuto/apollo-platform/releases

將文件夾中的ros拷貝到apollo工程中:
rsync -av ros/ ~/apollo/third_party/ros_x86_64 cd apollo source ./third_party/ros_x86_64/setup.bash
7. 安裝apollo的docker映像
cd apollo #拉取映像總共10G左右, -C是代表從國內下載,速度快些: bash docker/scripts/dev_start.sh -C
成功拉取完后建議把映像保存到移動硬盤,這樣下次重裝就不用再下載了:
#導出鏡像到本地文件 (這樣你可以把下載到的image備份,而不必重新安裝時,每次都要下載。) docker save apolloauto/apollo > apollo.tar #從本地文件導入文件到鏡像庫 sudo docker load --input apollo.tar
進入docker環境:
bash docker/scripts/dev_into.sh
這時命令窗口顯示前綴的方式會發生改變: ***@in_dev_docker:/apollo$
8. 編譯Apollo
#在第7步進入docker環境下執行:
bash apollo.sh build
#bash apollo.sh build -j 4 //指定使用cpu內核個數來編譯
#在編譯時如果電腦內存不夠可能會失敗並報錯,這時可以添加一個swap區,具體方法可以參考其他博客
9. 啟動HMI
Apollo編譯完成之后,接着輸入:
bash scripts/hmi.sh
這時在谷歌瀏覽器打開網址:http://localhost:8887就能進入apollo的HMI了。

如果你成功的到了這一步,那恭喜你,apollo1.0的環境就已經搭建成功啦! 遇到問題的同學也不用着急,多看看別人的博客都是會找到解決辦法的!
參考博客:
https://zhuanlan.zhihu.com/p/51160743
https://blog.csdn.net/qq_34906391/article/details/81478968
https://blog.csdn.net/ss910/article/details/74998172
https://blog.csdn.net/qq_33125039/article/details/87886908
https://gitee.com/wuwenxian/apolloauto
https://www.pianshen.com/article/7711267534/
