上次我们大概了解了Autoware是什么,以及它的基本原理。作为一个完备的自动驾驶框架,Autoware看起来很有吸引力,那么今天就带大家动手实践下,看它是不是像描述的那么好用。
先贴下最后的仿真导航效果:
一、部署
为了了解Autoware最新特性,本文采用最新的Autoware Core/Universe版本进行功能和效果验证。
依赖版本如下:
- Ubuntu 22.04 x86 64
- Python 3.10
- ROS 2 Humble
- CUDA 12.3
- cuDNN 8.9
- TensorRT 8.6
1.准备工作
1.1 切换apt源
推荐鱼香ros一键安装更换源:
wget http://fishros.com/install -O fishros && . fishros
也可以手动更新:(下方为x86的,ARM的板子,需要使用Ubuntu Ports Arm Tsinghua source)
vim /etc/apt/sources.list
# base
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# security
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# proposed
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
1.2 基础环境
# 安装git/python3.10
sudo apt -y update
sudo apt -y install git python3 python3-distutils python3-distro python3-venv
# 准备工作
sudo vim /etc/hosts
185.199.108.133 raw.githubusercontent.com
23.218.94.215 www.nvidia.com
152.199.39.144 developer.nvidia.com
152.199.39.144 developer.download.nvidia.com
2.Autoware源码
# 克隆Autoware到本地
cd ~/
git clone https://github.com/autowarefoundation/autoware.git
cd ~/autoware
3.自动安装依赖项
# 自动安装相关依赖(如果安装失败,可以修改自动安装脚本,或参考4-9步骤手动安装)
./setup-dev-env.sh
*注:
- ARM板子需要使用JetPack 6.0刷写。JetPack 6.0基于Ubuntu 22.04、CUDA 12.2、CuDNN 8.9、Tensorrt 8.6,满足Autoware的工作条件。6.1基于Tensorrt 10.x,Autoware暂不支持。
- 建议开着VPN执行,速度会快很多(从3个多小时下降到1小时内)。
*注:全部安装完毕预计耗时1小时+,中间有些环节类似egm2008、cuda等会有点慢,只要不报错就耐心等待,遇到timeout之类的基本是域名需要翻墙,hosts里加上ip基本重试就可以通过。如果有实在通过不了的,就参考~/autoware/ansible/roles/目录下找到对应安装环节tasks下的yaml配置,或参考官方文档每个环节操作步骤手动安装即可。
我安装时cuda环节重试几次都没有成功,后续步骤改为手动安装了,具体详见接下来的手动安装部分。
*注:Nvidia Jetson的arm板子,别用sdk-manager安装cuda,一定用autoware的脚本来安装。
4.手动安装依赖项
以下为手动安装过程,最新版本可以参考:Autoware官方文档 – Humble – Ubuntu 22.04 。
4.1 安装 Ansible 自动化部署工具
# 1. Ansible 安装
# Remove apt installed ansible (In Ubuntu 22.04, ansible the version is old)
sudo apt purge ansible
# Install pipx
sudo apt -y update
sudo apt -y install pipx
python3 -m pipx ensurepath
# Install ansible
pipx install --include-deps --force "ansible==6.*"
# 2. 安装 ansible 集合
cd ~/autoware
ansible-galaxy collection install -f -r "ansible-galaxy-requirements.yaml"
4.2 安装构建工具
sudo apt update
sudo apt install -y ccache
4.3 安装开发工具
sudo aptupdate
# Install Git LFS
sudo aptinstall -y git-lfs
git lfs install
# Install pre-commit using pip3
pip3 install pre-commit
# Install a specific version of clang-format using pip3
pip3 install clang-format==${pre_commit_clang_format_version}
# Install Go
sudo apt install -y golang
# Install PlotJuggler
sudo apt install -y ros-${ROS_DISTRO}-plotjuggler-ros
4.4 安装 gdown 下载工具
# Install gdown to download files from CMakeLists.txt
pip3 install gdown
4.5 安装 geoslib 地理库
sudo apt install geographiclib-tools
# Add EGM2008 geoid grid to geographiclib
sudo geographiclib-get-geoids egm2008-1
4.6 安装 pacmod 线控驱动库
使用 PACMod 线控驱动系统可以控制车辆(通过CAN DBC)。
cd ~/autoware
source amd64.env
# Taken from https://github.com/astuff/pacmod3#installation
sudo apt install apt-transport-https
sudo sh -c 'echo "deb [trusted=yes] https://s3.amazonaws.com/autonomoustuff-repo/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/autonomoustuff-public.list'
sudo apt update
sudo apt install ros-${rosdistro}-pacmod3
4.7 安装 RMW 性能库
RMW允许读一块共享数据的同时还原地修改它的值。
cd ~/autoware
wget -O amd64.env https://raw.githubusercontent.com/autowarefoundation/autoware/main/amd64.env
source amd64.env
# For details: https://docs.ros.org/en/humble/How-To-Guides/Working-with-multiple-RMW-implementations.html
sudo apt update
rmw_implementation_dashed=$(eval sed -e "s/_/-/g" <<< "${rmw_implementation}")
sudo apt install ros-${rosdistro}-${rmw_implementation_dashed}
# (Optional) You set the default RMW implementation in the ~/.bashrc file.
echo '' >> ~/.bashrc && echo "export RMW_IMPLEMENTATION=${rmw_implementation}" >> ~/.bashrc
4.8 安装ROS 2 Humble
自动安装:一键安装ROS环境
手动安装:
cd ~/autoware
source amd64.env
# Taken from: https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html
# You will need to add the ROS 2 apt repository to your system. First, make sure that the Ubuntu Universe repository is enabled by checking the output of this command.
apt-cache policy | grep universe
# If you don’t see an output line like the one above, then enable the Universe repository with these instructions.
sudo apt install software-properties-common
sudo add-apt-repository universe
# 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
# Update your apt repository caches after setting up the repositories.
sudo apt update
# Desktop Install
ros2_installation_type=desktop
sudo apt install ros-${rosdistro}-${ros2_installation_type}
# Environment setup
# (Optional) You can source ros2 in the ~/.bashrc file.
echo '' >> ~/.bashrc && echo "source /opt/ros/${rosdistro}/setup.bash" >> ~/.bashrc
4.9 安装ROS 2 开发工具
# Taken from https://docs.ros.org/en/humble/Installation/Ubuntu-Development-Setup.html
sudo apt update && sudo apt install -y \
python3-colcon-mixin \
python3-flake8-docstrings \
python3-pip \
python3-pytest-cov \
ros-dev-tools \
python3-flake8-blind-except \
python3-flake8-builtins \
python3-flake8-class-newline \
python3-flake8-comprehensions \
python3-flake8-deprecated \
python3-flake8-import-order \
python3-flake8-quotes \
python3-pytest-repeat \
python3-pytest-rerunfailures
# Initialize rosdep
sudo rosdep init
rosdep update --include-eol-distros
4.10 安装 Nvidia CUDA 12.3
# 1. cuda-keyring
os=ubuntu2204
wget https://developer.download.nvidia.com/compute/cuda/repos/$os/$(uname -m)/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
# 2. cuda-12-3
sudo apt update
source amd64.env
cuda_version_dashed=$(eval sed -e "s/[.]/-/g" <<< "${cuda_version}")
sudo apt -y install cuda-12-3
# 3. env
echo 'export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
source ~/.bashrc
# 4. register Vulkan, OpenGL, and OpenCL GPU vendors
# create directory
sudo mkdir -p /etc/vulkan/icd.d
sudo mkdir -p /etc/glvnd/egl_vendor.d
sudo mkdir -p /etc/OpenCL/vendors
sudo chmod 0755 /etc/vulkan/icd.d
sudo chmod 0755 /etc/glvnd/egl_vendor.d
sudo chmod 0755 /etc/OpenCL/vendors
# download and set permissions for Vulkan GPU vendors JSON
sudo wget https://gitlab.com/nvidia/container-images/vulkan/raw/dc389b0445c788901fda1d85be96fd1cb9410164/nvidia_icd.json -O /etc/vulkan/icd.d/nvidia_icd.json
sudo chmod 0644 /etc/vulkan/icd.d/nvidia_icd.json
# download and set permissions for OpenGL GPU vendors JSON
sudo wget https://gitlab.com/nvidia/container-images/opengl/raw/5191cf205d3e4bb1150091f9464499b076104354/glvnd/runtime/10_nvidia.json -O /etc/glvnd/egl_vendor.d/10_nvidia.json
sudo chmod 0644 /etc/glvnd/egl_vendor.d/10_nvidia.json
# register and set permissions for OpenCL GPU vendors
sudo touch /etc/OpenCL/vendors/nvidia.icd
echo "libnvidia-opencl.so.1" | sudo tee /etc/OpenCL/vendors/nvidia.icd > /dev/null
sudo chmod 0644 /etc/OpenCL/vendors/nvidia.icd
4.11 安装 Nvidia cuDNN 8 和 TensorRT 8
cd ~/autoware
wget -O amd64.env https://raw.githubusercontent.com/autowarefoundation/autoware/main/amd64.env && source amd64.env
# Can also be found at: https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing
sudo apt install -y \
libcudnn8=${cudnn_version} \
libnvinfer8=${tensorrt_version} \
libnvinfer-plugin8=${tensorrt_version} \
libnvparsers8=${tensorrt_version} \
libnvonnxparsers8=${tensorrt_version} \
sudo apt-mark hold \
libcudnn8 \
libnvinfer8 \
libnvinfer-plugin8 \
libnvparsers8 \
libnvonnxparsers8
sudo apt install -y \
libcudnn8-dev=${cudnn_version} \
libnvinfer-dev=${tensorrt_version} \
libnvinfer-plugin-dev=${tensorrt_version} \
libnvinfer-headers-dev=${tensorrt_version} \
libnvinfer-headers-plugin-dev=${tensorrt_version} \
libnvparsers-dev=${tensorrt_version} \
libnvonnxparsers-dev=${tensorrt_version}
sudo apt-mark hold \
libcudnn8-dev \
libnvinfer-dev \
libnvinfer-plugin-dev \
libnvparsers-dev \
libnvonnxparsers-dev \
libnvinfer-headers-dev \
libnvinfer-headers-plugin-dev
4.12 安装 Autoware RViz 主题(仅影响 Autoware RViz)
# 安装主题
cd ~/autoware
ansible-galaxy collection install -f -r "ansible-galaxy-requirements.yaml"
ansible-playbook autoware.dev_env.install_rviz_theme --ask-become-pass
# 手动启动使用
export QT_QPA_PLATFORMTHEME=qt5ct
rviz2
# autoware自动启动
# autoware.launch.xml文件会自动设置QT_QPA_PLATFORMTHEME环境变量,所以在启动 Autoware 时无需手动设置此环境变量。QT_QPA_PLATFORMTHEME配置位置:
<node
pkg="rviz2"
exec="rviz2"
name="rviz2"
output="screen"
args="-d $(var rviz_config) -s $(find-pkg-share autoware_launch)/rviz/image/autoware.png"
if="$(var rviz)"
respawn="$(var rviz_respawn)">
<env name="QT_QPA_PLATFORMTHEME" value="qt5ct"/>
</node>
4.13 下载Artifacts(用于感知推理)
# 安装 ansible 集合
ansible-galaxy collection install -f -r "ansible-galaxy-requirements.yaml"
# 下载并提取artifacts到~/autoware_data目录并校验
ansible-playbook autoware.dev_env.download_artifacts -e "data_dir=$HOME/autoware_data" --ask-become-pass
二、编译源码
1.下载Autoware Universe源码
# init
cd ~/autoware
mkdir src
# 下载源码到本地
vcs import src < autoware.repos
2.安装Autoware ROS依赖包
# 更新依赖
sudo apt update && sudo apt upgrade
# 安装ROS依赖
cd ~/autoware
source /opt/ros/humble/setup.bash
rosdep update --include-eol-distros
pip install open3d # 这个包通过rosdep安装太慢,先提前安装下
rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
# 如果rosdep失败,参考下方法手动解决
# 1.手动模拟 rosdep init(参考https://mirrors.tuna.tsinghua.edu.cn/help/rosdistro/)
sudo mv /etc/ros/rosdep/sources.list.d/20-default.list /etc/ros/rosdep/sources.list.d/20-default.list.bak
sudo curl -o /etc/ros/rosdep/sources.list.d/20-default.list https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
# 2.为rosdep update 换源
export ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml
# 后面的参数是为了不跳过ROS版本(注意:如果成功但是跳过了galactic也是不行的!)
rosdep update --include-eol-distros
# 3.每次rosdep update之前,均需要增加该环境变量,为了持久化该设定,可以将其写入 .bashrc 中,例如
echo 'export ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml' >> ~/.bashrc
3.调大swap交换空间
Ubuntu默认2G的swap交换空间,接下来全部200+模块编译时内存+swap不足会导致编译卡死,需要提前调大。具体参考:Ubuntu Swap交换区满问题解法
4.启动Ccache加速重新编译
Ccache是一种编译器缓存,它可以通过缓存以前的编译并在再次进行相同编译时重用它们来显著加快重新编译的速度。强烈建议希望优化构建时间的开发人员使用它,除非有特殊原因要避免使用它。
# 安装Ccache
sudo apt update
sudo apt install -y ccache
# 配置 Ccache
mkdir -p ~/.cache/ccache
touch ~/.cache/ccache/ccache.conf
echo "max_size = 60G" >> ~/.cache/ccache/ccache.conf
# .bashrc
vim ~/.bashrc
export CC="/usr/lib/ccache/gcc"
export CXX="/usr/lib/ccache/g++"
export CCACHE_DIR="$HOME/.cache/ccache/"
source ~/.bashrc
# check ccache is working
ccache -s
5.检查版本
5.1 检查版本
Orin最终安装的版本为:
- CUDA 12.3
- CuDNN 8.9.5.29-1+cuda12.2
- TensorRT 8.6.1.6-1+cuda12.0
- Opencv 4.5.4
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Wed_Nov_22_10:17:15_PST_2023
Cuda compilation tools, release 12.3, V12.3.107
Build cuda_12.3.r12.3/compiler.33567101_0
$ dpkg -l | grep -i cudnn
hi libcudnn8 8.9.5.29-1+cuda12.2 amd64 cuDNN runtime libraries
hi libcudnn8-dev 8.9.5.29-1+cuda12.2 amd64 cuDNN development libraries and headers
ii ros-humble-cudnn-cmake-module 0.0.1-3jammy.20240728.201041 amd64 Exports a CMake module to find cuDNN.
$ dpkg -l | grep -i libnvinfer-dev
hi libnvinfer-dev 8.6.1.6-1+cuda12.0 amd64 TensorRT development libraries
or
$ dpkg-query -W tensorrt
tensorrt 10.3.0.30-1+cuda12.5
$ opencv_version
4.5.4
5.2 修改版本配置
# x86
vim amd64.env
rosdistro=humble
rmw_implementation=rmw_cyclonedds_cpp
base_image=ros:humble-ros-base-jammy
cuda_version=12.3
cudnn_version=8.9.5.29-1+cuda12.2
tensorrt_version=8.6.1.6-1+cuda12.0
pre_commit_clang_format_version=17.0.5
source amd64.env
# arm
vim arm64.env
cuda_version=12.6
cudnn_version=9.3.0.75-1+cuda12.6
tensorrt_version=10.3.0.30-1+cuda12.5
source amd64.env
source arm64.env
6.编译工作空间
# clear
rm -rf build/ install/ log/
# 全部编译(推荐:限制编译使用的CPU核数、限制并行编译包数量)
MAKEFLAGS="-j6" colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --continue-on-error --parallel-workers 1
or
export MAKEFLAGS="-j 8"
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=1
# 全部编译
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
# 只编译指定包
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-select 包名
# 忽略指定包
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-ignore 包名
# 遇到编译错误继续编译其他模块
MAKEFLAGS="-j6" colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --continue-on-error
我本机用6核单并发编译,花了2个小时,有26个包报了stderr。
Summary: 370 packages finished [2h 7min 11s]
26 packages had stderr output: autoware_carla_interface autoware_costmap_generator autoware_elevation_map_loader autoware_freespace_planning_algorithms autoware_lanelet2_extension_python autoware_overlay_rviz_plugin autoware_radar_scan_to_pointcloud2 autoware_shape_estimation autoware_smart_mpc_trajectory_follower autoware_tensorrt_classifier bag_time_manager_rviz_plugin eagleye_can_velocity_converter eagleye_coordinate eagleye_geo_pose_fusion eagleye_rt lanelet2_extension_python ndt_omp nebula_common nebula_examples nebula_hw_interfaces pointcloud_to_laserscan system_monitor yabloc_common yabloc_image_processing yabloc_particle_filter yabloc_pose_initializer
其中25个用–packages-select指定包名重编成功,只有autoware_carla_interface这个卡罗拉车辆适配库编译不过,报easy_install命令已弃用,最终通过回退setuptools版本解决。
7.网络配置
7.1 调整系统网络设置
# 1. 手动设置
# 扩大 Linux 内核最大缓冲区大小
# Increase the maximum receive buffer size for network packets
sudo sysctl -w net.core.rmem_max=2147483647 # 2 GiB, default is 208 KiB
# IP fragmentation settings
sudo sysctl -w net.ipv4.ipfrag_time=3 # in seconds, default is 30 s
sudo sysctl -w net.ipv4.ipfrag_high_thresh=134217728 # 128 MiB, default is 256 KiB
# 2. 自动设置
sudo vim /etc/sysctl.d/10-cyclone-max.conf
# Increase the maximum receive buffer size for network packets
net.core.rmem_max=2147483647 # 2 GiB, default is 208 KiB
# IP fragmentation settings
net.ipv4.ipfrag_time=3 # in seconds, default is 30 s
net.ipv4.ipfrag_high_thresh=134217728 # 128 MiB, default is 256 KiB
# check
sysctl net.core.rmem_max net.ipv4.ipfrag_time net.ipv4.ipfrag_high_thresh
net.core.rmem_max = 2147483647
net.ipv4.ipfrag_time = 3
net.ipv4.ipfrag_high_thresh = 134217728
7.2 打开网卡组播
必须打开指定的网卡组播(我这里配置的是lo,可以在下一步的cyclonedds.xml中配置),否则autoware会无法正常启动。
# 1. 手动方式
sudo ip link set lo multicast on
# 1. 自动方式
sudo vim /etc/systemd/system/multicast-lo.service
[Unit]
Description=Enable Multicast on Loopback
[Service]
Type=oneshot
ExecStart=/usr/sbin/ip link set lo multicast on
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable multicast-lo.service
sudo systemctl start multicast-lo.service
# check
sudo systemctl status multicast-lo.service
# remove
sudo systemctl stop multicast-lo.service
sudo systemctl disable multicast-lo.service
sudo rm /etc/systemd/system/multicast-lo.service
sudo systemctl daemon-reload
7.3 CycloneDDS 配置
# 1. conf
vim ~/cyclonedds.xml
<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
<Domain Id="any">
<General>
<Interfaces>
<NetworkInterface autodetermine="false" name="lo" priority="default" multicast="default" />
</Interfaces>
<AllowMulticast>default</AllowMulticast>
<MaxMessageSize>65500B</MaxMessageSize>
</General>
<Internal>
<SocketReceiveBufferSize min="10MB"/>
<Watermarks>
<WhcHigh>500kB</WhcHigh>
</Watermarks>
</Internal>
</Domain>
</CycloneDDS>
# 2. bashrc
vim ~/.bashrc
# ROS
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI=file:///home/work/cyclonedds.xml
export ROS_DOMAIN_ID=3 # (number 1 to 255,默认0)
export RCUTILS_COLORIZED_OUTPUT=1 # ROS2控制台着色
export GTEST_COLOR=1 # 彩色的GoogleTest输出
export RCUTILS_CONSOLE_OUTPUT_FORMAT="[{severity} {time}] [{name}]: {message} ({function_name}() at {file_name}:{line_number})" # ROS详细日志打印(文件名、函数名或行号)
export ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml
*注意:lo为手动配置的网卡名称。如涉及跨机通信,需要进行多机时钟同步,可参考多PC AWSIM + Autoware测试,使用chrony同步时间
三、运行示例
1.下载地图
# 注意:从google.com下载地图包需要开VPN科学上网,我这里使用自己的一个代理配置
export ALL_PROXY=http://127.0.0.1:8118
gdown -O ~/autoware_map/ 'https://docs.google.com/uc?export=download&id=1499_nsbUbIeturZaDj7jhUownh5fvXHd'
unzip -d ~/autoware_map ~/autoware_map/sample-map-planning.zip
# 检查data
cd ~/autoware_data
ls -C -w 30
image_projection_based_fusion
lidar_apollo_instance_segmentation
lidar_centerpoint
tensorrt_yolo
tensorrt_yolox
traffic_light_classifier
traffic_light_fine_detector
traffic_light_ssd_fine_detector
yabloc_pose_initializer
2.启动Autoware仿真
2.1 命令行启动
# 启动Autoware
source ~/autoware/install/setup.bash
ros2 launch autoware_launch planning_simulator.launch.xml map_path:=$HOME/autoware_map/sample-map-planning vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit
*注意:上边的$HOME绝对路径不能用~代替,会导致地图无法正常加载
2.2 GUI界面启动
# 1. 安装依赖
sudo apt install libwebkit2gtk-4.1-0 libjavascriptcoregtk-4.1-0 libsoup-3.0-0 libsoup-3.0-common
# rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh
rustc --version
rustc 1.81.0 (eeb90cda1 2024-09-04)
# nodejs
sudo apt update
sudo apt install npm
sudo npm install -g n
sudo n stable
sudo npm install -g pnpm
node --version
v20.17.0
# 2. 安装autoware launch gui
wget https://github.com/autowarefoundation/autoware-launch-gui/releases/download/v1.0.5/autoware-launch-gui_1.0.5_amd64.deb
sudo apt install ./autoware-launch-gui_1.0.5_amd64.deb
or
git clone https://github.com/leo-drive/autoware-launch-gui.git
cd autoware-launch-gui
pnpm i
pnpm tauri dev
# 3. 启动
autoware-launch-gui
设置参数,点击Launch Autoware按钮,效果跟命令启动一样,同时GUI提供了一些可视化的工具:
3.路径规划模拟
3.1 路径规划与车道跟随
通过2D Pose Estimate给定初始位姿,小车模型会显示出来:
通过2D Goal Pose设置目标点会自动生成导航路径,这里需要注意的是,仿真地图是老外按靠左行驶画的,所以如果发现在右侧车道不能规划路线不用懵,因为我帮你们懵过了,照着车道的三角箭头方向规划路径即可…
通过选择左侧的Auto按钮即开始自动行驶:
3.2 虚拟障碍物
使用2D Dummy Car或2D Dummy Pedestrian按钮设置虚拟障碍物
3.3 泊入车位
目的地选择车位,当车辆接近目标时,它会从车道行驶模式自动切换到停车模式,并完成倒车入库。
3.4 车道切换
# 多车道地图
gdown -O ~/autoware_map/ 'https://github.com/tier4/AWSIM/releases/download/v1.1.0/nishishinjuku_autoware_map.zip'
unzip -d ~/autoware_map ~/autoware_map/nishishinjuku_autoware_map.zip
使用新的地图启动,设置起终点在不同的车道,可以让车辆变道。
我在执行车道上放置虚拟障碍物,试图迫使车辆变道绕行,发现默认的算法不太好,只有障碍物提前100米左右扫到才会规划绕行,如果近出突然出现了障碍物,它会停在那里不绕过去,需要后边看下planner的部分怎么解决。
另外放障碍后发现,qt5ct风格的rviz工具栏缺少Delete All Objects清除虚拟障碍物按钮,没试出来怎么添加,临时把autoware.launch.xml里的qt5ct主题注释掉即可显示出来:
<!-- env name="QT_QPA_PLATFORMTHEME" value="qt5ct"/ -->
3.5 交通灯识别
默认情况下,地图上的交通信号灯都被设置为绿色了,所以在通过交通灯的交叉路口的路径时,车辆都是不停车直接通过路口的。我们这里模拟设置下交通信号灯,看下车辆的反应。
a. 查看交通灯ID:在右上角Displays区域的Map-> Lanelet2VectorMap->Namespaces中点选交通灯ID(行驶线等其他可视化组件可以自行选择),然后取消并重新选中Map即可加载显示地图上的交通灯的ID,方便等下设置用。我这里如图左边路上的交通灯ID是1533、1536。
b. 设置交通灯:点击菜单Panels – >New Panel,选择TrafficLightPublishPanel,添加交通等设置面板;在面板中选择1533、1536交通灯 + RED红灯并SET,点击PUBLISH按钮,将交通灯状态发送到模拟器。规划车辆让车辆通过交通,可以看到会识别到红灯并等待:
c. 设置1536左转灯为绿灯,车辆继续行驶:
3.6 随即障碍物
a. 随机障碍物依赖仿真工具库,需要单独下载编译:
# 下载sim/tools源码
cd ~/autoware
vcs import src < simulator.repos
vcs import src < tools.repos
# 自动安装依赖
source /opt/ros/humble/setup.bash
rosdep update --include-eol-distros
# 其他依赖
sudo apt -y install libqt5charts5-dev libzmq5 libpcl-dev libpcl-ros-dev ros-humble-pcl-* libeigen3-dev freeglut3-dev libcjson-dev
#sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen
#sudo ln -s /usr/include/pcl-1.12/pcl /usr/include/pcl
# 重新编译
MAKEFLAGS="-j6" colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --continue-on-error
# 只编译指定包
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-select 包名
*注:如果遇到找不到zmqpp.hpp问题,可以参考这里解决。
b.启动随机障碍物仿真
source ~/autoware/install/setup.bash
ros2 launch random_test_runner random_test.launch.py \
architecture_type:=awf/universe \
sensor_model:=sample_sensor_kit \
vehicle_model:=sample_vehicle
4.Rosbag包重放
# 下载map
gdown -O ~/autoware_map/ 'https://docs.google.com/uc?export=download&id=1A-8BvYRX3DhSzkAnOcGWFw5T30xTlwZI'
unzip -d ~/autoware_map/ ~/autoware_map/sample-map-rosbag.zip
# 下载rosbag包
gdown -O ~/autoware_map/ 'https://docs.google.com/uc?export=download&id=1sU5wbxlXAfHIksuHjP3PyI2UVED8lZkP'
unzip -d ~/autoware_map/ ~/autoware_map/sample-rosbag.zip
# 启动
source ~/autoware/install/setup.bash
ros2 launch autoware_launch logging_simulator.launch.xml map_path:=$HOME/autoware_map/sample-map-rosbag vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit
# 播包
source ~/autoware/install/setup.bash
ros2 bag play ~/autoware_map/sample-rosbag/ -r 0.2 -s sqlite3
也可以使用autoware-launch-gui工具启动,并使用Menu菜单中的RosbagPlay功能进行播包:
四、AWSIM 3D仿真
AWSIM是autoware官方3D仿真器,兼容性更好些,但是功能相对简单。由于CARLA依赖的openplanner编译暂时没搞定,我们这里先试下AWSIM。
1.安装并启动AWSIM
# Install Vulkan Graphics Library
sudo apt update
sudo apt install libvulkan1
# Download and Run AWSIM Demo binary
cd ~/autoware_tools
wget -c https://github.com/autowarefoundation/AWSIM-Labs/releases/download/v1.5.1/awsim_labs_v1.5.1.zip
unzip awsim_labs_v1.5.1.zip
# Run
chmod +x ~/autoware_tools/awsim_labs_v1.5.1/awsim_labs.x86_64
~/autoware_tools/awsim_labs_v1.5.1/awsim_labs.x86_64
打开后,左上角选择nishishinjuku地图,然后点击右下角的Load按钮:
2.启动autoware
# 多车道地图
gdown -O ~/autoware_map/ 'https://github.com/tier4/AWSIM/releases/download/v1.1.0/nishishinjuku_autoware_map.zip'
unzip -d ~/autoware_map ~/autoware_map/nishishinjuku_autoware_map.zip
# 启动
source ~/autoware/install/setup.bash
ros2 launch autoware_launch e2e_simulator.launch.xml vehicle_model:=awsim_labs_vehicle sensor_model:=awsim_labs_sensor_kit map_path:=$HOME/autoware_map/nishishinjuku_autoware_map launch_vehicle_interface:=true
启动后稍等一会儿,autoware会自动定位车辆位置:
选择目的地,开始3D仿真:
我的电脑16核CPU,16G内存、RTX2070显卡,打开后有点卡,风扇嗷嗷的,2D仿真其实就够了,这个3D仿真没有高性能机器就体验下就得了…
五、总结
好了,今天带大家部署了Autoware universe,并通过仿真程序验证了基本的自动驾驶效果,下一次,我们将验证更多的自动驾驶场景效果,并尝试进行实际的硬件选型和安装调试。
参考:
Autoware官方文档 – Humble – Ubuntu 22.04
Autoware.universe部署01:Ubuntu20.04安装Autoware.universe并与Awsim联调
TypeError: canonicalize_version() got an unexpected keyword argument ‘strip_trailing_zero’问题解决
open_planner编译报proj_api.h: No such file or directory问题解决
fatal error: zmqpp/zmqpp.hpp: No such file or directory问题解决
Nvidia Jetson AGX Orin系统刷写&性能检测
TensorRT 10.x NOTFOUND TENSORRT_NVPARSERS_LIBRARY 问题