鏡像下載、功能變數名稱解析、時間同步請點擊 阿裡雲開源鏡像站 AutoWare.auto 安裝實踐 1. 相關程式版本說明 ubuntu版本:20.04 ADE:4.4.0 Autoware.auto版本(基於ROS2):autoware.auto foxy, ros foxy 2. Docker安裝 以下 ...
鏡像下載、功能變數名稱解析、時間同步請點擊 阿裡雲開源鏡像站
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封裝的開發容器,包含以下內容:
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
- 使用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
- 使用源碼編譯安裝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
執行後桌面會跳出一個時鐘的圖案
本文轉自:https://blog.csdn.net/baiyefenglin/article/details/122921360