EurekaMoments

This is my studying logs about Autonomous driving, Machine learning technologies and etc.

Baiduの自動運転プラットフォームApolloを動かすまでの手順

要求スペックを満たす環境を準備する

  • 必要なスペックはこちらの通り f:id:sy4310:20211031222615p:plain
  • 今回はこの記事に書いたようなゲーミングPCを購入して環境構築した www.eureka-moments-blog.com

GitHubリポジトリをForkする

  • OSS活動としてコントリビュートするために、自分のリポジトリに複製を作成する
  • 本家のリポジトリはこちら
    github.com
  • こちらの記事を参考にForkする
    tadaken3.hatenablog.jp

本家リポジトリの変更を取り込めるようにする

  • まずはForkしたApolloのリポジトリをcloneする
$ git clone https://github.com/ShisatoYano/apollo.git
Cloning into 'apollo'...
remote: Enumerating objects: 313807, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 313807 (delta 1), reused 0 (delta 0), pack-reused 313805
Receiving objects: 100% (313807/313807), 2.44 GiB | 1.16 MiB/s, done.
Resolving deltas: 100% (234940/234940), done.
Checking out files: 100% (9721/9721), done.
  • ブランチの状態を確認
$ cd apollo/
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/control_lego_sim
  remotes/origin/demo_dev
  remotes/origin/dependabot/npm_and_yarn/modules/dreamview/frontend/path-parse-1.0.7
  remotes/origin/dependabot/npm_and_yarn/modules/dreamview/frontend/url-parse-1.5.3
  remotes/origin/dependabot/npm_and_yarn/modules/dreamview/frontend/ws-6.2.2
  remotes/origin/lego_dev
  remotes/origin/master
  remotes/origin/mpi_dev
  remotes/origin/pre6
  remotes/origin/r1.0.0
  remotes/origin/r1.5.0
  remotes/origin/r2.0.0
  remotes/origin/r2.5.0
  remotes/origin/r3.0.0
  remotes/origin/r3.5.0
  remotes/origin/r5.0.0
  remotes/origin/r5.5.0
  remotes/origin/r6.0.0
  remotes/origin/revert-13819-r55_bugfix
  remotes/origin/revert-13826-github
  remotes/origin/revert-13963-lhn_dev
  remotes/origin/revert-13965-lhn_dev
  remotes/origin/revert-13985-ftr_parking_fix_new1
  remotes/origin/ubuntu_14.04
  remotes/origin/v3.1_dev
  remotes/origin/v6.0_edu
  • リモートリポジトリとして、本家のリポジトリをupstreamという名前で設定する
$ git remote add upstream https://github.com/ApolloAuto/apollo.git
  • git fetchコマンドでupstreamの最新情報をローカルに持ってくる
$ git fetch upstream
From https://github.com/ApolloAuto/apollo
 * [new branch]            control_lego_sim        -> upstream/control_lego_sim
 * [new branch]            demo_dev                -> upstream/demo_dev
 * [new branch]            dependabot/npm_and_yarn/modules/dreamview/frontend/path-parse-1.0.7 -> upstream/dependabot/npm_and_yarn/modules/dreamview/frontend/path-parse-1.0.7
 * [new branch]            dependabot/npm_and_yarn/modules/dreamview/frontend/url-parse-1.5.3 -> upstream/dependabot/npm_and_yarn/modules/dreamview/frontend/url-parse-1.5.3
 * [new branch]            dependabot/npm_and_yarn/modules/dreamview/frontend/ws-6.2.2 -> upstream/dependabot/npm_and_yarn/modules/dreamview/frontend/ws-6.2.2
 * [new branch]            lego_dev                -> upstream/lego_dev
 * [new branch]            master                  -> upstream/master
 * [new branch]            mpi_dev                 -> upstream/mpi_dev
 * [new branch]            pre6                    -> upstream/pre6
 * [new branch]            r1.0.0                  -> upstream/r1.0.0
 * [new branch]            r1.5.0                  -> upstream/r1.5.0
 * [new branch]            r2.0.0                  -> upstream/r2.0.0
 * [new branch]            r2.5.0                  -> upstream/r2.5.0
 * [new branch]            r3.0.0                  -> upstream/r3.0.0
 * [new branch]            r3.5.0                  -> upstream/r3.5.0
 * [new branch]            r5.0.0                  -> upstream/r5.0.0
 * [new branch]            r5.5.0                  -> upstream/r5.5.0
 * [new branch]            r6.0.0                  -> upstream/r6.0.0
 * [new branch]            revert-13819-r55_bugfix -> upstream/revert-13819-r55_bugfix
 * [new branch]            revert-13826-github     -> upstream/revert-13826-github
 * [new branch]            revert-13963-lhn_dev    -> upstream/revert-13963-lhn_dev
 * [new branch]            revert-13965-lhn_dev    -> upstream/revert-13965-lhn_dev
 * [new branch]            revert-13985-ftr_parking_fix_new1 -> upstream/revert-13985-ftr_parking_fix_new1
 * [new branch]            ubuntu_14.04            -> upstream/ubuntu_14.04
 * [new branch]            v3.1_dev                -> upstream/v3.1_dev
 * [new branch]            v6.0_edu                -> upstream/v6.0_edu
  • 再度git branch -aコマンドでブランチを確認する
  • リモートにupstreamが追加されていることがわかる
remotes/upstream/control_lego_sim
  remotes/upstream/demo_dev
  remotes/upstream/dependabot/npm_and_yarn/modules/dreamview/frontend/path-parse-1.0.7
  remotes/upstream/dependabot/npm_and_yarn/modules/dreamview/frontend/url-parse-1.5.3
  remotes/upstream/dependabot/npm_and_yarn/modules/dreamview/frontend/ws-6.2.2
  remotes/upstream/lego_dev
  remotes/upstream/master
  remotes/upstream/mpi_dev
  remotes/upstream/pre6
  remotes/upstream/r1.0.0
  remotes/upstream/r1.5.0
  remotes/upstream/r2.0.0
  remotes/upstream/r2.5.0
  remotes/upstream/r3.0.0
  remotes/upstream/r3.5.0
  remotes/upstream/r5.0.0
  remotes/upstream/r5.5.0
  remotes/upstream/r6.0.0
  remotes/upstream/revert-13819-r55_bugfix
  remotes/upstream/revert-13826-github
  remotes/upstream/revert-13963-lhn_dev
  remotes/upstream/revert-13965-lhn_dev
  remotes/upstream/revert-13985-ftr_parking_fix_new1
  remotes/upstream/ubuntu_14.04
  remotes/upstream/v3.1_dev
  remotes/upstream/v6.0_edu
  • 次にブランチをmasterにし、mergeコマンドでupstream/masterをマージすれば本家との差分を取り込むことができる
$ git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.

$ git merge upstream/master
Already up to date.
  • 参考にした記事

qiita.com

Apolloのビルド環境を構築する

  • Apolloのビルド環境はDockerを使って構築される
  • なのでまずはDockerデーモンを起動させておく
$ sudo service docker start
  • 続いて下記のスクリプトを起動してDockerイメージをダウンロードする
$ ./docker/scripts/dev_start.sh
  • 初回起動時は、下記のようにライセンス規約に同意するか聞かれる
  • yを入力して同意して先に進める
Copyright (c) 2018 Various License Holders. All Rights Reserved

Apollo software is built on top of various other open source software packages, a complete list of licenses are located at https://github.com/ApolloAuto/apollo/blob/master/third_party/ACKNOWLEDGEMENT.txt

By accepting this Service License Agreements, you confirm that you are not a resident or citizen of any country currently embargoed by the U.S. and that you are not otherwise prohibited from receiving the Licensed Software.

You agree to the terms of all the License Agreements.
Type 'y' or 'Y' to agree to the license agreement above, or type any other key to exit:y
  • そしてDockerイメージのpullと環境構築が自動実行され、最後に下記のメッセージが出力されれば完了
[ OK ] Congratulations! You have successfully finished setting up Apollo Dev Environment.
[ OK ] To login into the newly created apollo_dev_shisato container, please run the following command:
[ OK ]   bash docker/scripts/dev_into.sh
[ OK ] Enjoy!

Apolloをビルドする

  • 下記コマンドで先程立ち上げたDockerコンテナにログインする
./docker/scripts/dev_into.sh
  • すると、ターミナルがこんな風になる
[user_name@in-dev-docker:/apollo]$
  • そしたら下記コマンドでビルド開始
  • 最後にこんなメッセージが出たらビルド成功
(14:03:37) INFO: Elapsed time: 2162.564s, Critical Path: 246.81s
(14:03:37) INFO: 30719 processes: 18777 internal, 11942 local.
(14:03:37) INFO: Build completed successfully, 30719 total actions
==============================================
[ OK ] Done building apollo. Enjoy!
==============================================

デモレコードを動かして動作確認

  • 下記コマンドでDreamviewのバックエンドを起動する
  • DreamviewはApolloの処理をモニタリングするGUIツール
$ ./scripts/bootstrap.sh
nohup: appending output to 'nohup.out'
[ OK ] Launched module monitor.
nohup: appending output to 'nohup.out'
[ OK ] Launched module dreamview.
Dreamview is running at http://localhost:8888
  • http://localhost:8888からDreamviewをブラウザで開く
    f:id:sy4310:20211101231912p:plain
  • モードを"Mkz Standard Debug", マップを"Sunnyvale with Two Offices"に設定
    f:id:sy4310:20211101232345p:plain
  • 下記コマンドでデモレコードをダウンロードする
$ cd docs/demo_guide/
$ python record_helper.py demo_3.5.record
  • デモ用レコードのデータをダウンロードする
  • ダウンロード用スクリプトがあるディレクトリに移動
$ cd docs/demo_guide/
  • ダウンロードスクリプトを下記コマンドで実行
$ python record_helper.py demo_3.5.record
  • このメッセージが出ればダウンロード成功
Successfully downloaded demo_3.5.record
  • 下記コマンドを実行してレコードを再生
  • -lオプションを付けるとループ再生される
$ cyber_recorder play -f docs/demo_guide/demo_3.5.record -l
file: docs/demo_guide/demo_3.5.record, chunk_number: 3, begin_time: 1546888377338834894 (2019-01-08-04:12:57), end_time: 1546888422886740928 (2019-01-08-04:13:42), message_number: 61615
earliest_begin_time: 1546888377338834894, latest_end_time: 1546888422886740928, total_msg_num: 61615

Please wait 3 second(s) for loading...
Hit Ctrl+C to stop, Space to pause, or 's' to step.

[RUNNING] Record Time: 1546888393.846    Progress: 16.507 / 45.548
  • 3秒くらいまって、Dreamview上でアニメーションが動き出せばOK f:id:sy4310:20211102083108p:plain