当前位置:   article > 正文

ubuntu20.04源码安装apollo 9.0.0_apollo9.0安装

apollo9.0安装

注意:以下教程amd64计算机可使用!!!

一、安装基础软件

1. 安装 Ubuntu Linux

安装 Ubuntu 18.04+ 的步骤,参见 官方安装指南

完成安装后更新相关软件:

  1. sudo apt-get update
  2. sudo apt-get upgrade

2. 安装 Docker Engine

Apollo 依赖于 Docker 19.03+。安装 Docker 引擎,可用鱼香ROS一键安装。将下列代码输入到终端。然后选择8,即可安装。

wget http://fishros.com/install -O fishros && . fishros 

还可以者通过 Apollo 提供的安装脚本直接安装:

  1. wget http://apollo-pkg-beta.bj.bcebos.com/docker_install.sh
  2. bash docker_install.sh

这个过程可能会运行多次脚本,根据脚本提示执行即可。

二、Nvidia显卡驱动以及Nvidia container toolkit

Apollo某些模块需要GPU的支持才能够编译、运行(例如感知模块),如果需要使用此类模块,需要安装Nvidia显卡驱动以及Nvidia container toolkit以获取GPU支持。如果仅使用apollo的NPC模块,则可以无视这一步骤。虚拟机选手请跳过!!!

1.安装驱动

打开终端输入

ubuntu-drivers devices

查看显卡推荐,如下图所示,driver后带有recommended字样的即为推荐驱动(无视server、open等字眼,只需要关注版本号即可)。

 然后使用以下命令安装显卡驱动(以下nvidia-535为我个人的显卡驱动),然后重启电脑

sudo apt-get install nvidia-535

2. 安装 Nvidia container toolkit

为了在容器内获得 GPU 支持,在安装完 docker 后需要安装 NVIDIA Container Toolkit。 运行以下指令安装 NVIDIA Container Toolkit:

  1. distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
  2. curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
  3. curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
  4. sudo apt-get -y update
  5. sudo apt-get install -y nvidia-docker2

安装完毕后,需要手动重启下docker:

sudo systemctl restart docker

三、下载安装 Apollo 源码

1. 克隆 Apollo 源码

执行以下命令克隆 Apollo 源码:

  1. # SSH 方式
  2. git clone git@github.com:ApolloAuto/apollo.git
  3. # HTTPS 方式
  4. git clone https://github.com/ApolloAuto/apollo.git

也可将以下网址直接复制到浏览器,下载apollo-9.0.0,解压至home目录下,并重命名为apollo

https://github.com/ApolloAuto/apollo/tree/v9.0.0

2. 启动 Apollo 环境容器

在 apollo 目录下输入以下命令来启动环境容器

  1. cd apollo
  2. bash docker/scripts/dev_start.sh

操作成功后您将会看到如下样式的提示输出

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

3. 进入 Apollo 环境容器

在 apollo 目录下输入以下命令进入容器

bash docker/scripts/dev_into.sh

4. 编译

在容器内的 /apollo 目录下输出以下命令编译整个工程

./apollo.sh build

若需要开启编译优化,则通过以下命令进行编译

./apollo.sh build_opt

5. 启动 Apollo

启动 Dreamview+

bash scripts/bootstrap.sh start_plus

启动 Dreamview+ 之后,在浏览器输入 localhost:8888 进入 Dreamview+ 界面。

三、遇到的错误

1.rules_java下载超时

  1. INFO] Apollo Environment Settings:
  2. [INFO] APOLLO_ROOT_DIR: /apollo
  3. [INFO] APOLLO_CACHE_DIR: /apollo/.cache
  4. [INFO] APOLLO_IN_DOCKER: true
  5. [INFO] APOLLO_VERSION: predtr-2021-12-28-463fb82f9e
  6. [INFO] DOCKER_IMG:
  7. [INFO] APOLLO_ENV: STAGE=dev USE_ESD_CAN=false
  8. [INFO] USE_GPU: USE_GPU_HOST= USE_GPU_TARGET=1
  9. [ OK ] Running GPU build on x86_64 platform.
  10. [WARNING] ESD CAN library supplied by ESD Electronics doesn't exist.
  11. [WARNING] If you need ESD CAN, please refer to:
  12. [WARNING] third_party/can_card_library/esd_can/README.md
  13. [INFO] Build Overview:
  14. [INFO] USE_GPU: 1 [ 0 for CPU, 1 for GPU ]
  15. [INFO] Bazel Options: --config=gpu
  16. [INFO] Build Targets: //modules/... union //cyber/...
  17. [INFO] Disabled: except //modules/drivers/canbus/can_client/esd/...
  18. Starting local Bazel server and connecting to it...
  19. WARNING: ignoring LD_PRELOAD in environment.
  20. (00:29:33) INFO: Invocation ID: 40695d7b-c7dd-416c-b7ae-de72a1612dec
  21. (00:29:33) INFO: Current date is 2022-01-28
  22. (00:30:32) INFO: Repository build_bazel_rules_swift instantiated at:
  23. /apollo/WORKSPACE:68:16: in <toplevel>
  24. /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:38:29: in grpc_extra_deps
  25. /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/build_bazel_rules_apple/apple/repositories.bzl:117:11: in apple_rules_dependencies
  26. /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/build_bazel_rules_apple/apple/repositories.bzl:84:14: in _maybe
  27. Repository rule http_archive defined at:
  28. /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
  29. (00:30:32) INFO: Repository rules_java instantiated at:
  30. /apollo/WORKSPACE:68:16: in <toplevel>
  31. /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:29:18: in grpc_extra_deps
  32. /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/com_google_protobuf/protobuf_deps.bzl:44:21: in protobuf_deps
  33. Repository rule http_archive defined at:
  34. /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
  35. (00:30:32) WARNING: Download from https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz failed: class java.io.IOException connect timed out
  36. (00:30:32) ERROR: An error occurred during the fetch of repository 'rules_java':
  37. Traceback (most recent call last):
  38. File "/apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/bazel_tools/tools/build_defs/repo/http.bzl", line 111, column 45, in _http_archive_impl
  39. download_info = ctx.download_and_extract(
  40. Error in download_and_extract: java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz] to /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/rules_java/temp14011213055655260428/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz: connect timed out
  41. (00:30:32) ERROR: While resolving toolchains for target //modules/v2x/v2x_proxy/os_interface:os_interface_cpplint: invalid registered toolchain '@bazel_tools//tools/jdk:all': while parsing '@bazel_tools//tools/jdk:all': no such package '@rules_java//java': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz] to /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/rules_java/temp14011213055655260428/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz: connect timed out
  42. (00:30:32) ERROR: Analysis of target '//modules/v2x/v2x_proxy/os_interface:os_interface_cpplint' failed; build aborted: invalid registered toolchain '@bazel_tools//tools/jdk:all': while parsing '@bazel_tools//tools/jdk:all': no such package '@rules_java//java': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz] to /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/rules_java/temp14011213055655260428/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz: connect timed out
  43. (00:30:32) INFO: Elapsed time: 59.517s
  44. (00:30:32) INFO: 0 processes.
  45. (00:30:32) FAILED: Build did NOT complete successfully (595 packages loaded, 6242 targets configured)
  46. currently loading: @bazel_tools//tools/jdk ... (3 packages)

这个错误出现在代码编译过程。原因是docker内无法连接到这个下载地址。解决办法是更改rules_java的下载路径。首先将下面网址复制到浏览器。

https://github.com/protocolbuffers/protobuf/blob/main/protobuf_deps.bzl

找到对应的下载信息,并复制。

然后打开apollo中的索引文件,路径为~/apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/com_google_protobuf/protobuf_deps.bzl,打开并找到对应的下载信息,更换为先前复制的下载信息。

(本办法可以编译通过,但无法确定对使用apollo有没有影响)

以上教程可以使apollo通过编译,由于对apollo接触的不多,所以难免会有错误,若发现错误,各位可以在评论区提出。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/213550
推荐阅读
相关标签
  

闽ICP备14008679号