Apollo环境配置

常用命令及技巧:

修改分辨率:xrandr   --size   1360x768

vim命令:修改i,保存并退出:wq

提高GitHub下载速度:

参考:

方法1:(仅参考,未必有效!)

https://blog.csdn.net/chikui6724/article/details/100644265?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

https://blog.csdn.net/qq_44621510/article/details/95251993?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

方法2:(亲测可行)

将GitHub仓库复制到Gitee仓库,网速可以拉满!!!(需要创建Gitee账号)

官方网址:https://gitee.com/

参考:https://blog.csdn.net/dlshtian/article/details/87782195?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

具体方法:在Gitee中新建仓库,填入GitHub的仓库链接,Gitee后台会自动复制仓库到个人的Gitee账户中(注意:大容量仓库迁移需要开通企业版账号)

 

进入正文——————————————————————————

1.安装Ubuntu,具体自行百度

2.Download the Apollo Release Package

安装官方的教程下载源代码前确保Ubuntu的git命令可用!

安装git命令:sudo apt install git(可能会报错!!!)

解决方法:
sudo apt-get update
sudo apt-get upgrade

执行后,再次执行 sudo apt install git 

【可能会出现进程冲突——

解决:删除锁定文件:

sudo rm /var/lib/dpkg/lock-frontend       

sudo rm /var/lib/dpkg/lock】

注意:

执行这两条命令可能会遇到下载网速非常慢的问题!!!

解决方法:更换下载源(默认美国的服务器,修改为国内的镜像源(如:阿里云)网速会大大提高)

参考:https://blog.csdn.net/zhangmeimei_pku/article/details/79597951

 

到这里,可以按照官方教程进行。。。(若下面第一条命令没报错,则上面的操作可忽略!)

Download Apollo Source

  1. Download Apollo source code from the github source and check out the correct branch:

    git clone git@github.com:ApolloAuto/apollo.git
    cd apollo
    git checkout [release_branch_name]
    
  2. Set up environment variable APOLLO_HOME by the following command:

    echo "export APOLLO_HOME=$(pwd)" >> ~/.bashrc && source ~/.bashrc
    
  3. Open a new terminal or run source ~/.bashrc in an existing terminal.

tip In the following sections, it is assumed that the Apollo directory is located in $APOLLO_HOME.

 

3.Set Up the Docker Environment

The Docker container is the simplest way to set up the build environment for Apollo.

For more information, see the detailed Docker tutorial here.

1.Please follow the official guide to install the docker-ce 19.03+.

Don't forget the post-installation steps for Linux.

2.After the installation, log out and then log back into the system to enable Docker.

3.(Optional) If you already have Docker installed (before you installed the Apollo Kernel), add the following line in /etc/default/docker:

DOCKER_OPTS = "-s overlay"

Install latest nvidia-container-toolkit by following the official doc.

We encourage you to continue the Build process using Build the Dev docker environment if you have not already set it up.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

3.1 Docker

按照Docker官方文档安装最新版Docker(版本要19.03+)

3.1.1 Follow the official guide to install the docker-ce 19.03+.

参考:

https://docs.docker.com/install/linux/docker-ce/ubuntu/

②nvidia-docker (optional):

简易安装:参考:https://github.com/ApolloAuto/apollo/blob/master/docker/scripts/README.md#install-docker

 

# Install nvidia-docker (optional)
# To use the host machine's GPUs, you need to install nvidia docker.

bash docker/setup_host/install_nvidia_docker.sh
 

官方教程:(有三种安装方法,这里只显示第一种方法)

链接:https://docs.docker.com/install/linux/docker-ce/ubuntu/

Install Docker Engine - Community🔗

You can install Docker Engine - Community in different ways, depending on your needs:(Docker有三种安装方法)

  • Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.

  • Some users download the DEB package and install it manually and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.

  • In testing and development environments, some users choose to use automated convenience scripts to install Docker.

Install using the repository(第一种方法)

Before you install Docker Engine - Community for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

SET UP THE REPOSITORY

  1. Update the apt package index:

    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:

    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common
    
  3. Add Docker’s official GPG key:

    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

    Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

    $ sudo apt-key fingerprint 0EBFCD88
        
    pub   rsa4096 2017-02-22 [SCEA]
          9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
    sub   rsa4096 2017-02-22 [S]
    
  4. Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

    Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. Sometimes, in a distribution like Linux Mint, you might need to change $(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are using Linux Mint Tessa, you could use bionic. Docker does not offer any guarantees on untested and unsupported Ubuntu distributions.

    • x86_64 / amd64
    • armhf
    • arm64
    • ppc64le (IBM Power)
    • s390x (IBM Z)
    $ sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
    

     

INSTALL DOCKER ENGINE - COMMUNITY

  1. Update the apt package index.

    $ sudo apt-get update
    
  2. Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:

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

    Got multiple Docker repositories?

    If you have multiple Docker repositories enabled, installing or updating without specifying a version in theapt-get install or apt-get update command always installs the highest possible version, which may not be appropriate for your stability needs.

  3. To install a specific version of Docker Engine - Community, list the available versions in the repo, then select and install:

    a. List the versions available in your repo:(第2步和第3步只需要执行一种即可!)

    $ apt-cache madison docker-ce
    
      docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 18.06.1~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 18.06.0~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      ...
    

    b. Install a specific version using the version string from the second column, for example, 5:18.09.1~3-0~ubuntu-xenial.

    $ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
    
  4. Verify that Docker Engine - Community is installed correctly by running the hello-world image.

    $ sudo docker run hello-world
    

    This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

注意:此步骤可能会报错:docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
解决方法:修改docker镜像源,参考:https://blog.csdn.net/qq_37189082/article/details/100047697

$ cd /etc/docker
$ vim daemon.json 


 # 添加以下内容
{
  "registry-mirrors": ["http://hub-mirror.c.163.com"]
}
# 也可以添加多个国内源
{
"registry-mirrors": ["http://hub-mirror.c.163.com", "https://registry.docker-cn.com"]
}


几个国内镜像源:

             网易  http://hub-mirror.c.163.com     |    中国科技大学      https://docker.mirrors.ustc.edu.cn

              阿里云    https://pee6w651.mirror.aliyuncs.com

       ②  修改完之后,需要重新启动Docker。(当修改配置文件时候都需要进行重启服务)

$ systemctl daemon-reload    # 重新载入 systemd,扫描新的或有变动的单元
$ systemctl restart docker          # 重新启动Docker服务

 

Docker Engine - Community is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

UPGRADE DOCKER ENGINE - COMMUNITY

To upgrade Docker Engine - Community, first run sudo apt-get update, then follow the installation instructions, choosing the new version you want to install.

 

3.1.2 Continue to Post-installation steps for Linux.

参考:

https://docs.docker.com/install/linux/linux-postinstall/

https://docs.docker.com/engine/security/rootless/

(若官方的方法无效,可参考:https://www.cnblogs.com/satng/p/7493621.html

将当前用户添加到一个group中,使得可以不用sudo执行docker

(这部分有点晕,暂且跳过。。)

3.2 After the installation, log out and then log back into the system to enable Docker.

3.3 (Optional) If you already have Docker installed (before you installed the Apollo Kernel), add the following line in /etc/default/docker:

DOCKER_OPTS = "-s overlay"

Install latest nvidia-container-toolkit by following the official doc.

We encourage you to continue the Build process using Build the Dev docker environment if you have not already set it up.

3.4 Install latest nvidia-container-toolkit by following the official doc.

注:虚拟机里面无法安装英伟达显卡驱动,此步骤跳过。。。

可参考:https://blog.csdn.net/qq_34009929/article/details/94595656

 

4.Support a new Vehicle in DreamView

In order to support a new vehicle in DreamView, please follow the steps below:

  1. Create a new folder for your vehicle under modules/calibration/data

  2. There is already a sample file in the modules/calibration/data folder named mkz_example. Refer to this structure and include all necessary configuration files in the same file structure as “mkz_example”. Remember to update the configuration files with your own parameters if needed.

  3. Restart DreamView and you will be able to see your new vehicle (name is the same as your newly created folder) in the selected vehicle.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

5.Install Apollo Kernel(下面步骤2选1,默认用5.1)

The Apollo runtime in the vehicle requires the Apollo Kernel. It is strongly recommended to install the pre-built kernel.

5.1 Use the pre-built Apollo Kernel

You get access to and install the pre-built kernel using the following commands.

  1. Download the release packages from the release section on GitHub:
https://github.com/ApolloAuto/apollo-kernel/releases

2.Install the kernel after having downloaded the release package:

tar zxvf linux-4.4.32-apollo-1.5.0.tar.gz
cd install
sudo bash install_kernel.sh

3.Reboot your system using the reboot command.

4.[Optional - if you are using CAN card for interface] Build the CAN driver source code, according to the vendor's instructions

5.2 Build your own kernel

If you have modified the kernel, or the pre-built kernel is not the best for your platform, you can build your own kernel using the following steps:

1. Clone the code from the repository

git clone https://github.com/ApolloAuto/apollo-kernel.git
cd apollo-kernel

2. Add the CAN driver source code according to vendor's instruction

3. Build the kernel using the following command:

bash build.sh

4. Install the kernel using the steps for a pre-built Apollo Kernel as described in the previous section.

6.Run Apollo in Ubuntu 16

Please refer to How to run Apollo with Ubuntu 16

运行Apollo————————————————————————————————————————————————————————

参考:https://blog.csdn.net/jinzhuojun/article/details/80210180

首先下载apollo源代码。可以选择直接从github上拉,也可以下载release包。这里选择后者,从https://github.com/ApolloAuto/apollo/下载代码,然后解压。假设解压后目录为APOLLO_HOME。进入该目录后(在第2节已完成)

运行以下脚本初始化apollo的开发和运行环境。

bash docker/scripts/dev_start.sh

1.其中会去从网上拉几个所需的docker image并基于这些image启动container。(此步骤下载的文件比较多,请耐心等待...)

出现上图即表示下载完成!

拉完后用 docker images 命令可以看到以下的几个新增image:

REPOSITORY          TAG                                            IMAGE ID            CREATED             SIZE
apolloauto/apollo   dev-18.04-x86_64-20200316_1730                 673b988116f4        2 weeks ago         17GB
apolloauto/apollo   map_volume-sunnyvale_with_two_offices-latest   93a347cea6a0        3 weeks ago         509MB
apolloauto/apollo   map_volume-san_mateo-latest                    48cd73de58ba        5 months ago        202MB
apolloauto/apollo   map_volume-sunnyvale_big_loop-latest           1b805b4390f5        8 months ago        438MB
apolloauto/apollo   paddlepaddle_volume-x86_64-2.0.0               1c8194382ee9        8 months ago        1.03GB
apolloauto/apollo   localization_volume-x86_64-latest              109001137d4a        9 months ago        5.44MB
apolloauto/apollo   local_third_party_volume-x86_64-latest         5df2bf3cc4b9        9 months ago        156MB
hello-world         latest                                         fce289e99eb9        15 months ago       1.84kB
apolloauto/apollo   yolo3d_volume-x86_64-latest                    6a9cbf71163e        20 months ago       275MB
apolloauto/apollo   map_volume-sunnyvale_loop-latest               36dc0d1c2551        2 years ago         906MB

用 docker ps 可以看到启动了以下container:

CONTAINER ID        IMAGE                                                            COMMAND             CREATED             STATUS              PORTS               NAMES
a0b047493e12        apolloauto/apollo:dev-18.04-x86_64-20200316_1730                 "/bin/bash"         13 minutes ago      Up 13 minutes                           apollo_dev_yofer
89dabb5c3e18        apolloauto/apollo:local_third_party_volume-x86_64-latest         "/bin/sh"           14 minutes ago      Up 14 minutes                           apollo_local_third_party_volume_yofer
c330adde2f5f        apolloauto/apollo:paddlepaddle_volume-x86_64-2.0.0               "/bin/sh"           15 minutes ago      Up 14 minutes                           apollo_paddlepaddle_volume_yofer
6fd2719b7ac4        apolloauto/apollo:localization_volume-x86_64-latest              "/bin/sh"           16 minutes ago      Up 16 minutes                           apollo_localization_volume_yofer
3ee37fbb8949        apolloauto/apollo:yolo3d_volume-x86_64-latest                    "/bin/sh"           16 minutes ago      Up 16 minutes                           apollo_yolo3d_volume_yofer
f75c2290a78b        apolloauto/apollo:map_volume-san_mateo-latest                    "/bin/sh"           17 minutes ago      Up 16 minutes                           apollo_map_volume-san_mateo_yofer
647436ea0997        apolloauto/apollo:map_volume-sunnyvale_with_two_offices-latest   "/bin/sh"           19 minutes ago      Up 18 minutes                           apollo_map_volume-sunnyvale_with_two_offices_yofer
c45670c7fcbd        apolloauto/apollo:map_volume-sunnyvale_loop-latest               "/bin/bash"         21 minutes ago      Up 20 minutes                           apollo_map_volume-sunnyvale_loop_yofer
e6b8950c3675        apolloauto/apollo:map_volume-sunnyvale_big_loop-latest           "/bin/sh"           23 minutes ago      Up 22 minutes                           apollo_map_volume-sunnyvale_big_loop_yofer

接下来就可以通过以下命令进入开发环境了,其实就是进入前面pull下来的dev-18.04-x86_64-20200316_1730 那个image创建的container(名为apollo_dev)。前面的apollo代码根目录APOLLO_HOME会被映射到container中的/apollo目录下。

bash docker/scripts/dev_into.sh

然后就可以编译整个系统了。等编译完后,根据官方文档How to Launch and Run Apollo就可以用下面命令启动Apollo并运行可视化工具Dreamview:

 

注意:有GPU和无GPU(/虚拟机)

First check and make sure you are in development docker container before you proceed. Now you will need to build from the source. If you want to run the entire system, make sure you have an nVidia GPU and that you have installed the Linux nVidia drivers. You could still proceed with the next few steps even if you are missing the Linux nVidia drivers, as the system will run but with the CUDA-based perception and other modules.

# To get a list of build commands
./apollo.sh
# To make sure you start clean
./apollo.sh clean
# This will build the full system and requires that you have an nVidia GPU with nVidia drivers loaded
bash apollo.sh build

If you do not have an nVidia GPU, the system will run but with the CUDA-based perception and other modules. You must specify either dbg for debug mode or opt for optimized code

./apollo.sh build_no_perception dbg

If you make modifications to the Dreamview frontend, then you must run ./apollo.sh build_fe before you run the full build.

If the computer is very slow, you can enter the following command to limit the CPU.

bash apollo.sh build --local_resources 2048,1.0,1.0

出现以下界面表示编译成功!(注意:编译的时候要保留充足的内存(最好8G及以上,否则容易失败;Apollo文件所在的分区也要预留一定的空间,否则会因为空间不足而中断。博主因为这两个原因失败了两次。。。)

Run Apollo

Follow the steps below to launch Apollo. Note that you must build the system first before you run it. Note that the bootstrap.sh will actually succeed but the user interface will not come up if you skip the build step.

Start Apollo

Running Apollo will start the ROS core and then startup a web user interface called Dreamview, this is handled by the bootstrap script, so from within the docker container, you should run:

# start module monitor
bash scripts/bootstrap.sh

输入这个命令会出现一些信息

此时,用浏览器打开网址http://localhost:8888,出现以下界面表示成功!

Access Dreamview

Access Dreamview by opening your favorite browser, e.g. Chrome, go to http://localhost:8888 and you should see this screen However, there will be nothing running in the system.

 

Select Drive Mode

From the dropdown box selet "Navigation" mode.

 

Replay demo record

To see if the system works, use the demo 'record' which feeds the system.

# You need to download the demo record using the following commands
cd docs/demo_guide/
python3 rosbag_helper.py demo_3.5.record

# You can now replay this demo "record" in a loop with the '-l' flag
cyber_recorder play -f docs/demo_guide/demo_3.5.record -l

Dreamview should show a running vehicle now. (The following image might be different due to changes in frontend.)

 

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

浅若清风cyf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值