AutoWare.auto 与ROS2 亲测安装成功

  • AutoWare.auto 与ROS2 亲测安装成功已关闭评论
  • 31 次浏览
  • A+
所属分类:linux技术
摘要

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站ubuntu版本:20.04 ADE:4.4.0

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

AutoWare.auto 安装实践

1. 相关程序版本说明

ubuntu版本:20.04 ADE:4.4.0

Autoware.auto版本(基于ROS2):autoware.auto foxy, ros foxy

2. Docker安装

以下操作,请确定自己已经换源了,不然下载很慢的,参考Ubuntu20.04软件源更换 - 知乎

Ubuntu系统中,软件源文件地址为:/etc/apt/sources.list

1.备份原来的源,将以前的源备份一下,以防以后可以用的。

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.打开/etc/apt/sources.list文件,在前面添加如下条目,并保存。

$ sudo vim /etc/apt/sources.list(可将vim更换为自己熟悉的编辑器)

添加阿里源

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse # deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse # deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse # deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse # deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse # deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse # deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse 

3.更新

更新源

$ sudo apt-get update

如出现依赖问题,解决方式如下:

$ sudo apt-get -f install

更新软件:

$ sudo apt-get upgrade

官方安装教程:Install Docker Engine on Ubuntu | Docker Documentation

// 卸载旧版本docker

#Uninstall old versions $ sudo apt-get remove docker docker-engine docker.io containerd runc  #Uninstall Docker Engine $ sudo apt-get purge docker-ce docker-ce-cli containerd.io $ sudo rm -rf /var/lib/docker $ sudo rm -rf /var/lib/containerd 

// 使用docker repository安装docker engine

#step1:在新主机上首次安装Docker Engine之前,需要设置Docker存储库。之后,您可以从存储库安装和更新Docker #更新apt软件包索引并安装软件包,以允许apt通过HTTPS使用存储库 $ sudo apt-get install      ca-certificates      curl      gnupg      lsb-release  #Step2:Add Docker’s official GPG key: $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg  #Step3: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. $ echo    "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null    #Step4:Install Docker Engine $ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io //如果没有指定版本,默认安装最高版本  #Step5:Verify that Docker Engine is installed correctly by running the hello-world image. $ sudo docker run hello-world  Hello from Docker! This message shows that your installation appears to be working correctly. 

Manage Docker as a non-root user

# 创建docker用户组 $ sudo groupadd docker #将当前用户加入docker用户组 $ sudo usermod -aG docker $USER #Log out and log back in so that your group membership is re-evaluated. $ newgrp docker  #Verify that you can run docker commands without sudo. $ docker run hello-world  $ sudo chmod 666 /var/run/docker.sock #重启电脑或者重启docker服务 $ sudo systemctl daemon-reload $ sudo systemctl restart docker $ sudo docker login registry.gitlab.com # Use token from Gitlab 

3. Autoware.auto容器安装

3.1 程序说明

基于Docker封装的开发容器,包含以下内容:

AutoWare.auto 与ROS2 亲测安装成功

3.2 ADE安装

ADE 是模块化的 Docker-based 工具,它确保所有的开发者构建项目时有一个共同的、一致的开发环境

官网安装文档:Installation — ADE 4.4.0dev documentation

#install it in “/usr/local/bin” PATH $ cd  /usr/local/bin  $ sudo wget https://gitlab.com/ApexAI/ade-cli/-/jobs/1859684348/artifacts/raw/dist/ade+x86_64 $ sudo mv ade+x86_64 ade $ sudo chmod +x ade $ which ade /path/to/ade # 查看ade版本号 $ ade --version <version> # Update ade $ sudo ./ade update-cli     #这个地方需要一段时间 Newer version available:   4.4.0   4.3.0   4.2.0 Do you want to update to version 4.4.0 [y/N]: y ​ <!-- '注意:升级ade版本可能会报错 “PermissionError: [Errno 13] Permission denied: '/usr/local/bin/ade'”,切换root用户再次执行,问题解决'-> 

3.3 Autoware容器安装

官网安装文档:Installation with ADE

  1. 使用ADE安装Autoware.auto环境,ROS2和Autoware.auto已经预编译,安装了二进制版本,默认安装在/opt目录下
$ mkdir -p ~/adehome $ cd ~/adehome $ touch .adehome $ git clone https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto.git '注意:不要使用官网视频课程里面的递归循环安装,编译会报错'  'git clone --recurse-submodules https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto.git'  $ cd AutowareAuto  #拉取一些其他分支到master $ vcs import < autoware.auto.$ROS_DISTRO.repos  #切换到发布分支,如果不切换,默认使用master 分支代码,可能包含一些正在开发的功能,建议切换稳定发布版本 $ git checkout tags/1.0.0 -b release-1.0.0  #共享环境变量 $ cd ~ $ mv ~/.bashrc ~/adehome/.bashrc $ ln -s ~/adehome/.bashrc  $ cd ~/adehome/AutowareAuto #其实,有很多预先配置好的ADE环境供我们选择,官网提供了三个ADE配置文件:AMD64/ARM64/AMD64+LGSVL $ ls -l .aderc*  lrwxrwxrwx 1 wtcl wtcl  17 12月 23 12:14 .aderc -> .aderc-amd64-foxy -rw-rw-r-- 1 wtcl wtcl 407 12月 23 12:25 .aderc-amd64-dashing -rw-rw-r-- 1 wtcl wtcl 499 12月 23 12:25 .aderc-amd64-dashing-lgsvl -rw-rw-r-- 1 wtcl wtcl 401 12月 23 12:25 .aderc-amd64-foxy -rw-rw-r-- 1 wtcl wtcl 490 12月 23 12:25 .aderc-amd64-foxy-lgsvl lrwxrwxrwx 1 wtcl wtcl  17 12月 23 12:14 .aderc-arm64 -> .aderc-arm64-foxy -rw-rw-r-- 1 wtcl wtcl 407 12月 23 12:25 .aderc-arm64-dashing -rw-rw-r-- 1 wtcl wtcl 401 12月 23 12:25 .aderc-arm64-foxy lrwxrwxrwx 1 wtcl wtcl  23 12月 23 12:14 .aderc-lgsvl -> .aderc-amd64-foxy-lgsvl  #可以看到有好几种可选的环境,其中.aderc-lgsvl对应的环境中包含LGSVL模拟器。然后,可以通过如下命令,切换并进入相应的ADE环境: #二选一安装,这个地方安装有点慢,需要等待一会,ade --rc 命令可以加载并启动相关的镜像容器 $ ade --rc .aderc-amd64-foxy  start --update --enter  <!-- '注意:启动ade报错  “Starting ade with the following images: ade-foxy    | ec7293d289ad | master | registry.gitlab.com/autowarefoundation/autoware.auto/autowareauto/amd64/ade-foxy:master    binary-foxy | 9ffc6c658b7a | master | registry.gitlab.com/autowarefoundation/autoware.auto/autowareauto/amd64/binary-foxy:master ade_registry.gitlab.com_autowarefoundation_autoware.auto_autowareauto_amd64_binary-foxy_master xhost:  unable to open display "localhost:10.0" WARNING: Could not find xhost, you won't be able to launch X applications" 解决办法:设置本地显示命令-- $ export DISPLAY=localhost:10.0 $ xhost +>  #What is where inside ADE? ade$ls /opt AutowareAuto # image: binary-foxy:master lgsvl        # image: ade-lgsvl/foxy:2020.06 ros          # image: ade-foxy:master 

ade安装过程中可能需要访问gitlab的令牌,需要登录gitlab申请

In one terminal, source the setup file and then run a C++ talker:  ade$ ade enter ade$ source ~/AutowareAuto/install/setup.bash ade$ ros2 run demo_nodes_cpp talker In another terminal source the setup file and then run a Python listener:  ade$ cd ~/AutowareAuto ade$ source ~/AutowareAuto/install/setup.bash ade$ ros2 run demo_nodes_py listener You should see the talker saying that it’s Publishing messages and the listener saying I heard those messages. This verifies both the C++ and Python APIs are working properly. Hooray!  #docker容器 清理无用镜像,卷 $ cd ~/adehome/AutowareAuto $ ade start  #To assess the disk usage situation, run the following command: $ docker system df  #Use docker system prune to remove any Docker items not used for currently running containers: $ docker system prune -a --volumes  #Restart your system after installing the new NVIDIA driver. ade$ exit $ ade stop $ ade start --update --enter 

安装完成后运行

ade $ros2 run demo_nodes_cpp talker 不工作,没办法,继续使用源码进行编译安装

issue回复:colcon build failed on trajectory.hpp file not found (#67) · Issues · ApexAI / AutowareClass2020 · GitLab

  1. 使用源码编译安装Autoware.auto 和 ROS2

Autoware.auto官网安装文档:Installation w/o ADE

ROS2官网安装文档:Building ROS 2 on Ubuntu Linux — ROS 2 Documentation: Foxy documentation

#如果安装了旧版本,先卸载 $ sudo apt-get purge ros-foxy* $ sudo rm -rf /etc/ros $ sudo gedit ~/.bashrc 删除那个东西bash $ source ~/.bashrc ​ #安装编译工具包 #Apt packages $ sudo apt install -y git cmake python3-pip ​ #Python modules $ pip3 install -U colcon-common-extensions vcstool ​ #First, the ROS 2 core components and tools must be installed ​ #安装ROS2核心包 ​ #设置语言环境,确保语言环境支持UTF-8 $ locale  # check for UTF-8 ​ #只检查是否有可用更新,给出汇总报告和提示信息 $ sudo apt update ​ #查看可升级的软件的全部版本信息 $ sudo apt list --upgradable -a $ sudo apt install locales $ sudo locale-gen en_US en_US.UTF-8 $ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $ export LANG=en_US.UTF-8 $ locale  # verify settings ​ #确保ros2仓库可用 $ apt-cache policy | grep universe ​ #如果不可用,执行下面命令 $ sudo apt install software-properties-common $ sudo add-apt-repository universe ​ #需要在系统中添加ROS 2 apt存储库。为此,请首先使用如下所示的apt授权GPG密钥: #Now add the ROS 2 apt repository to your system. First authorize our GPG key with apt. $ sudo apt update $ sudo apt install curl gnupg lsb-release $ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg ​ #然后将存储库添加到源列表中  #Then add the repository to your sources list. $  echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null ​ #Install development tools and ROS tools sudo apt update && sudo apt install -y    build-essential    cmake    git    python3-colcon-common-extensions    python3-flake8    python3-pip    python3-pytest-cov    python3-rosdep    python3-setuptools    python3-vcstool    wget # install some pip packages needed for testing python3 -m pip install -U    flake8-blind-except    flake8-builtins    flake8-class-newline    flake8-comprehensions    flake8-deprecated    flake8-docstrings    flake8-import-order    flake8-quotes    pytest-repeat    pytest-rerunfailures    pytest    # install Fast-RTPS dependencies sudo apt install --no-install-recommends -y    libasio-dev    libtinyxml2-dev # install Cyclone DDS dependencies sudo apt install --no-install-recommends -y    libcunit1-dev ​ # Get ROS 2 code  # ROS2源码下载,Install ROS 2 packages  $ mkdir -p ~/ros2_foxy/src $ cd ~/ros2_foxy $ wget https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos $ vcs import src < ros2.repos ​ #Install dependencies using rosdep $ sudo apt update $ sudo rm -rf /etc/ros/rosdep/sources.list.d/20-default.list $ sudo rosdep init $ rosdep update $ rosdep install --from-paths src --reinstall --ignore-src -y --rosdistro=foxy --skip-keys "fastcdr rti-connext-dds-5.3.1 urdfdom_headers" $ rosdep check --from-paths src --ignore-src -y --skip-keys "fastcdr  rti-connext-dds-5.3.1 urdfdom_headers" ​ 'Note: If you’re using a distribution that is based on Ubuntu (like Linux Mint) but does not identify itself as such, you’ll get an error message like Unsupported OS [mint]. In this case append --os=ubuntu:focal to the above command.' #rti-dds可以单独安装 #https://docs.ros.org/en/foxy/Installation/DDS-Implementations.html ​ #工作空间编译源码安装 #检查ROS环境变量,确保没有使用“source /opt/ros/${ROS_DISTRO}/setup.bash”设置过环境变量 $ printenv | grep -i ROS  #如果显示空,后面编译会有问题 PWD=/pathto/ros2_foxy $ cd ~/ros2_foxy/ $ colcon build --symlink-install $ colcon test $ colcon test-result --verbose ​ ​ #Demo test,In one terminal, source the setup file and then run a C++ talker: $ source ~/ros2_foxy/install/setup.bash $ ros2 run demo_nodes_cpp talker ​ #In another terminal source the setup file and then run a Python listener: $ source ~/ros2_foxy/install/setup.bash $ ros2 run demo_nodes_py listener ​ =================================================以上是ROS2 源码安装,下面是安装Autoware.auto源码安装  ============================= ​ $ export ROS_DISTRO = foxy $ echo $ROS_DISTRO ​ #ROS2安装完成后, 设置环境变量 $ source ~/ros2_foxy/install/setup.bash ​ #将ROS环境变量添加到bashrc文件里面 $ echo "source ~/ros2_foxy/install/setup.bash" >> ~/.bashrc $ source ~/.bashrc ​ # Autoware.Auto project requires some ROS 2 packages in addition to the core components. The tool rosdep allows an automatic search and installation of such dependencies. $ sudo apt update $ sudo apt install -y python3-rosdep $ sudo rosdep init $ rosdep update ​ #安装Autoware.Auto依赖的ROS2的其它包,rosdep会自动搜索安装 $ mkdir -p ~/adehome $ cd ~/adehome $ touch .adehome $ git clone https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto.git $ cd AutowareAuto $ vcs import < autoware.auto.$ROS_DISTRO.repos $ export ROS_VERSION=2 ​ #rosdep 一次安装src下所有依赖 $ rosdep install --reinstall -y -i --from-paths src ​ // 这一步可有可不有。 //目的是切换想要安装的autoware版本,如果不切换master将使用最新分支 #Checkout the latest release by checking out the corresponding tag or release branch. $ git checkout tags/1.0.0 -b release-1.0.0 ​ # If running tests or demos, also pull binary files with $ git lfs pull --exclude="" --include="*" ​ #共享环境变量 $ cd ~ $ mv ~/.bashrc ~/adehome/.bashrc $ ln -s ~/adehome/.bashrc ​ #打开一个干净的ade容器进行编译 $ ade stop $ sudo ade update-cli $ ade --rc .aderc-amd64-foxy-lgsvl start --update --enter ade$ cd AutowareAuto ade$ rm -rf build/ install/ log/ ​ #To build all packages in Autoware.Auto, navigate into the AutowareAuto directory and run ade$ colcon build ade$ colcon test ade$ colcon test-result --verbose 上述步骤中,第二步命令可以拉取一些其他分支到master,补充一些文件。我开始没有执行这个命令,  导致在执行colcon build,出现无法找到文件  autoware_auto_msgs/msg/trajectory.hpp的错误。  如果colcon 不起作用,配置colcon 环境变量  Take the defaults file that comes with the Autoware.Auto source checkout and add it to your shell startup;  echo COLCON_DEFAULTS_FILE  $ echo "export COLCON_DEFAULTS_FILE=/path/to/AutowareAuto/tools/ade_image/colcon-defaults.yaml" >> .bashrc  或者手工导入  $ export COLCON_DEFAULTS_FILE=/path/to/AutowareAuto/tools/ade_image/colcon-defaults.yaml  编译完一定要source:  $ source /opt/AutowareAuto/setup.bash 或  $ source ~/AutowareAuto/install/setup.bash 

------使用一个干净的ADE环境------

我们可能遇到的很多问题都是由于代码版本、旧的编译文件存在等导致,所以需要更新ade和docker容器,以及清理一些旧的build等文件,可以通过以下操作完成:

$ ade stop $ sudo ade update-cli $ ade start --update --enter ade$ cd AutowareAuto ade$ rm -rf build/ install/ log/ src/external/ ade$ git pull ade$ vcs import < autoware.auto.$ROS_DISTRO.repos 

------ADE环境的使用------

  • 执行ade命令(如ade start、ade enter等)时,要确保当前命令行在路径

~/adehome/AutowareAuto 中;

  • 开启ADE环境:

$ ade start

  • 进入ADE环境(此时,会输出一些镜像信息):

$ ade enter

  • 所有的镜像挂在在/opt下面,可以查看:

ade$ ls /opt

  • 退出并停止ADE环境(使用完最好手动停止ADE环境,以关闭Docker):

ade$ exit

$ ade stop

------安装过程中可能会出现少包,版本不兼容问题,可以使用下面命令排查------

#查找所有已安装的软件包 $dpkg -l——查看所有已安装的软件包 ​ #清除所以删除包的残余配置文件 $dpkg -l |grep ^rc|awk ‘{print $2}’ |tr [”"n”] [” “]|sudo xargs dpkg -P - ​ #查看需卸载的软件包 $dpkg -l |grep 软件名 ​ #clean 命令删除所有的软件安装包。 $ sudo apt-get clean ​ #autoclean 命令删除不再可用的软件安装包。 $ sudo apt-get autoclean ​ #remove 命令移除 以及任何依赖这个包的其它包 $sudo apt-get remove 软件名 ​ #用purge 命令清除式卸载 $apt-get purge  <pakage_name> ​ #autoremove 命令删除不再需要的依赖软件包。 $ sudo apt-get autoremove ​ #install 命令下载软件包,以及所有依赖的包,同时进行包的安装或升级 $ apt-get install 软件名   #libc6-dev : Depends: libc6 (= 2.31-0ubuntu9.2) but 2.31-0ubuntu9.4 is to be installed $ sudo apt install libc6=2.31-0ubuntu9.2 libc-bin=2.31-0ubuntu9.2 ​ #reinstall 命令重新安装软件包。 $ apt-get --reinstall install softname1 ​ #升级来自 Debian 镜像的包列表,如果你想安装当天的任何软件,至少每天运行一次,而且每次修改了 $ sudo apt-get update ​ #升级所有已经安装的包为最新可用版本。不会安装新的或移除老的包。建议同时使用 '-u' 选项,因为这样你就能看到哪些包将会被升级 $ apt-get upgrade -u ​ #apt-get upgrade 类似,除了 dist-upgrade 会安装和移除包来满足依赖关系。因此具有一定的危险性 $ apt-get dist-upgrade -u ​ #在软件包名称和描述中,搜索包含xxx的软件包 $ apt-cache search ​ #显示某个软件包的完整的描述 $apt-cache show ​ #Dpkg方式安装软件源 $ dpkg -i package_name.deb ​ #移除式卸载: $dpkg -r pkg1 pkg2 ... ​ #清除式卸载: $dpkg -P pkg1 pkg2.. ​ #将删除相关软件,同时删除该软件的配置文件 $ dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -p ​ #重新安装已安装的包 $ dpkg -l | grep ^ii | awk '{print $2}' | xargs sudo apt-get reinstall 

3.4 Autoware.auto 相机车道线检测demo 展示

1. 代码及录制视频下载

代码下载

$ cd ~/adehome/AutowareAuto/ $ ade start $ ade enter $ git clone https://gitee.com/knowmefly/camera-hands-on-ws.git 

视频下载:https://download.csdn.net/download/jiluonian/22771297 下载 laneVideo.h264 视频文件放置在 ~/adehome/camera-hands-on-ws/src/lane_detection_data_loader/resources/ 目录下

2. 编译安装

$ ade enter $ cd camera-hands-on-ws/ $ rm -rf build/ install/ log/ $ colcon build '可能找不到opencv,安装opencv库' $sudo apt install libopencv-dev python3-opencv 

3.运行视频加载、图像处理、可视化节点

  • 运行视频加载节点
# terminal 1 $ ade enter $ cd  camera-hands-on-ws/ $ source install/setup.bash $ ros2 run lane_detection_data_loader lane_detection_data_loader_node 
  • 运行图像处理节点
# terminal 2 $ ade enter $ cd  camera-hands-on-ws/ $ source install/setup.bash $ ros2 run lane_detection_projection lane_detection_projection_node 
  • 运行可视化节点
# terminal 3 $ ade enter $ cd  camera-hands-on-ws/ $ source install/setup.bash $ ros2 run lane_detection_visualization lane_detection_visualization_node # terminal 4 $ ade enter $ export QT_DEBUG_PLUGINS=1 $ export DISPLAY=:0.0 $ rviz2 
  • 运行rviz2报错
'qt.qpa.xcb: could not connect to display localhost:10.0 'qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. 'This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.  'Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.  'Aborted (core dumped)'' 

解决办法:

加载插件跟踪

$ export QT_DEBUG_PLUGINS=1

$ export DISPLAY=:0.0

在vi /etc/profile内添加export DISPLAY=xserverip:0.0 执行source /etc/profile 第二步:然后ssh终端安装xorg并使用xclock测试能否回传图像:

apt-get install xorg

xclock

执行后桌面会跳出一个时钟的图案

AutoWare.auto 与ROS2 亲测安装成功

本文转自:https://blog.csdn.net/baiyefenglin/article/details/122921360