本文内容&顺序:
建议:
如果只想试试Autoware,强烈建议先用官方发布的docker玩一玩(一言难尽,请自行体验)。
如果决定一定要用Autoware做自车的自动驾驶平台,那请往下看源码编译吧
参考资料 autoware官网:
步骤:参照官网一步步做,但遇到了一堆问题 在这个文章里记录一下。
环境:docker。因为autoware要安装的库很多,防止它搞坏我外面的电脑环境,我就用docker(方便重来)。事实证明我的确重来了三次orz。。。
源码编译流程:环境配置(CUDA & QT & ROS)、下载autoware、编译autoware。下面从环境配置开始说~ 我的软硬件环境是:
NVIDIA RTX 2060
CPU: Intel® Core™ i7-9700 CPU @ 3.00GHz × 8
Ubuntu 18.04 including Python 3.6 environment
NVIDIA CUDA 10.2.89 including cuBLAS 10.2.2.89
NVIDIA cuDNN 7.6.5
TensorRT 7.0.0
我用的是pytorch的docker image
https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel_20-01.html#rel_20-01
docker run -it --ipc=host -p 10001:22 --name=‘my_autoware’ -v /home/zsw/shared_dir/:/home/autoware/shared_dir --gpus all nvcr.io/nvidia/pytorch:20.01-py3 /bin/bash
由于qt没啥官网教程, 我是按照这个博客安装: https://blog.csdn.net/qq_43627981/article/details/105164183
其中,下载5.9.5版本的QT的下载地址是: http://download.qt.io/archive/qt/5.9/5.9.5/
安装步骤我就不记录了,下面是一些报错和解决:
解决:
sudo apt-get install libdbus-1-3
解决:
sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
如果有什么没装上,在上面那条命令后面加上 --fix-missing
我试过阿里云和国外(bionic) source互相切换。但是最好不要总切,比如ros安装的时候key会有一些问题很麻烦。
vim /etc/profile
export PATH="/home/autoware/installation/Tools/QtCreator/bin:$PATH"
export PATH="/home/autoware/installation/5.9.5/gcc_64/bin:$PATH"
事实证明我后来安装了opengl
官网: http://wiki.ros.org/melodic/Installation/Ubuntu
参考博客: https://forum.ouster.at/d/19-ros-melodic-installation-on-ubuntu-18-04-bionic
基本是按照官网来装的.注意要用ubuntu bionic的源
按照官网步骤一步步走,我就不记录了:
https://github.com/Autoware-AI/autoware.ai/wiki/Source-Build
命令改为:
$ wget -O autoware.ai.repos “https://raw.githubusercontent.com/Autoware-AI/autoware.ai/1.14.0/autoware.ai.repos”
请好好记住这条命令,它在接下来的流程会时刻伴随我们orz:
AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
说当前的CUDA版本不对,需要<=10.0。估计是开发者没有测试其他CUDA版本这里偷个懒直接限制住不让编译。。但我用10.2也可以编译通过的。(用10.2是为了以后测试较新的算法,比如使用高版本pytorch)。所以先把这个报错改了:
/home/autoware/autoware.ai/src/autoware/common/autoware_build_flags/cmake/autoware_build_flags-extras.cmake 第21行,把10.0全部改成10.2:
if(NOT ${CUDA_VERSION} VERSION_LESS "10.2"
AND NOT ${CUDA_VERSION} VERSION_EQUAL "10.2" )
message(FATAL_ERROR "GPU support on Melodic requires CUDA<=10.2")
编译很慢,164个package,大概要8分钟。编译成功。
用这条命令测试Autoware是否安装成功(打开图形界面):
roslaunch runtime_manager runtime_manager.launch
会出现报错,打不开界面,下面记录了我debug的过程:
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
这是因为docker环境中为加入英伟达环境硬件加速,需要build image的时候加入环境变量
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
并在run.sh内的docker run命令中添加
--env="QT_X11_NO_MITSHM=1" \
参考链接:https://stackoverflow.com/questions/59388345/rviz-in-nvidia-docker-container
/home/autoware/Autoware/src/autoware/utilities/runtime_manager/scripts/subnet.py
print “Usage: {}
分析:此错误是python版本不对,(按理说解决方法是在anaconda下建立py27的环境,运行launch),但请注意!!!!这是个大坑!!不要建python2.7的环境!不要!不要!如果改了,会蹦出一个框说时区不对。。。我搞了3小时也没改好时区,后来直接用python3跑,这个时区问题就神奇的消失了
解决:所以说直接用python3的环境跑就ok,这个错无伤大雅的
此错误是终端未安装gnome插件
sudo apt-get install gnome
运行run_manager的launch在log文件 /home/autoware/.ros/log/07992312-b231-11ea-adba-0013eff13975/run-2*.log中报错:
WSL(Linux子系统) gedit 报错 failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)
sudo apt-get install x11-xserver-utils dconf-editor dbus-x11 -y
参考链接:https://blog.csdn.net/wistral/article/details/95603645
sudo apt-get install libcanberra-gtk3-module
到此为止终端和log里都不报错了!但是依然显示不出来图形界面(闪退)
参考链接: https://www.jianshu.com/p/5be271096e85
思路就是把runtime_manager.launch代码看明白,一条条执行,看哪条会报错。我发现代码里的关键一步就是:
rosrun runtime_manager_dialog.py
所以直接运行这条,看还有什么报错。下面是具体步骤:
(a) 找到/home/autoware/autoware.ai/src/autoware/utilities/runtime_manager/scripts/run文件,最后一行查看运行
(b) 另起终端进入docker, 启动roscore
docker exec -it c o n t a i n e r n a m e container name containername /bin/bash
(c) 运行rosrun runtime_manager runtime_manager_dialog.py按照顺序安装
报错:no module named “wx” 解决:conda install wxpython
报错:no module named “rospkg” 解决:pip install rospkg
报错:no module named “yaml” 解决:pip install pyyaml
报错:‘module’ object has not attribute ‘HyperlinkCtrl’
解决:pip install -U -f
https://extras.wxpython.org/wxPython4/extras/linux/gtk2/ubuntu-18.04 wxPython
sudo apt install libsdl1.2-dev
报错:cann’t set locale language to English(就是我之前说的不要再py27下运行的原因,会出现这个问题。虽然这里给出了解决方案,但可以不用解决,直接使用python3环境启动)
解决:参考链接:https://lintut.com/how-to-set-up-system-locale-on-ubuntu-18-04/
5条命令:
locale;locale -a; sudo dpkg-reconfigure locales(选择en_US.UTF-8);
sudo update-locale LANG=en_US.UTF-8; export LANG=en_US.UTF-8
(d)在python3环境下成功启动
yolo3的从操作流程我介绍的比较详细,后面的ssd和point pillar和这个差不多 就不介绍了。
解决:权重和config必须放在:
[ INFO] [1592121585.936264005]: Network Definition File (Config): /home/autoware/Autoware/install/vision_darknet_detect/share/vision_darknet_detect/darknet/cfg/yolov3.cfg
[ INFO] [1592121585.936476337]: Pretrained Model File (Weights): /home/autoware/Autoware/install/vision_darknet_detect/share/vision_darknet_detect/darknet/data/yolov3.weights
[ INFO] [1592121585.936754384]: Names File: /home/autoware/Autoware/install/vision_darknet_detect/share/vision_darknet_detect/darknet/cfg/coco.names
roslaunch runtime_manager runtime_manager.launch
2.2.1 在Autoware GUI界面,找到Simulation,点击 ref ,选中自己的rosbag:/home/autoware/.autoware/camera1.bag
2.2.2 点击play,再点击pause。(目的是先暂停一下等待我们把rviz打开)
2.2.3 注意 这个rosbag需要包括image_raw这个topic,官方的dample rosbag是没有的。
2.3.1 在Autoware GUI界面,找到 Computing – Detection – vision_detector – vision_darknet_yolo3
2.3.2 点开app,注意确认权重config之类的都是yolo3的、确认image_src是image_raw或camera0/image_raw(总之这个topic是rosbag中发送图像的topic,把yolo3的接收图像topic设置成同样的)。然后点击ok。
2.3.3 给vision_darknet_yolo3打钩
2.4.1 Image Topic 选择 image_raw
2.4.2 Object Rect Topic 选择 /detection/image_detector/objects
2.4.3 其他两个Topic不重要
2.4.4 在Autoware GUI界面,点击pause,把rosbag启动:这时rviz里应该能看到图像+检测结果了(ImageViwerPlugin往上拉一拉,让图像显示出来)
注意:一定要先play rosbag,不然yolo3的image_src选择中不会出现/camera0/image_raw
debug思路就是,一定要确保:
roslaunch vision_darknet_detect vision_yolo3_detect.launch
autoware@zsw-NG-im610:~/Autoware$ rostopic list
/config/Yolo3 # yolo3的网络参数配置
/detection/image_detector/objects # 输出结果,会发送到rviz
/image_raw # 输入图像
/image_rects # 画了bounding box之后的检测结果可视化图像
[其实以下命令得到的信息都可以从 Autoware GUI – Topics 中看到,注意要点击Refresh才会出现最新的rostopic list]
rostopic list
rosnode list
rostopic echo /image_raw
rostopic info /camera0/image_raw
(其实貌似不需要安装caffe,ssdcaffe会安装caffe的,但我一开始不知道,所以做了这个,先记录着吧)
sudo apt install caffe-cuda
python
import sys
sys.path.append('/usr/lib/python3/dist-packages')
import caffe
https://github.com/Autoware-AI/core_perception/tree/master/vision_ssd_detect
https://blog.csdn.net/u010801994/article/details/81745513
# add proto
cp -r src/caffe/proto distribute/
# add include
cp -r include distribute/
mkdir -p distribute/include/caffe/proto
cp .build_release/src/caffe/proto/caffe.pb.h distribute/include/caffe/proto
# add tool and example binaries
cp .build_release/tools/create_label_map.bin .build_release/tools/caffe.bin .build_release/tools/finetune_net.bin .build_release/tools/extract_features.bin .build_release/tools/device_query.bin .build_release/tools/upgrade_net_proto_text.bin .build_release/tools/train_net.bin .build_release/tools/convert_imageset.bin .build_release/tools/net_speed_benchmark.bin .build_release/tools/compute_image_mean.bin .build_release/tools/upgrade_solver_proto_text.bin .build_release/tools/convert_annoset.bin .build_release/tools/upgrade_net_proto_binary.bin .build_release/tools/test_net.bin .build_release/tools/get_image_size.bin distribute/bin
cp .build_release/examples/ssd/ssd_detect.bin .build_release/examples/cifar10/convert_cifar_data.bin .build_release/examples/cpp_classification/classification.bin .build_release/examples/siamese/convert_mnist_siamese_data.bin .build_release/examples/mnist/convert_mnist_data.bin distribute/bin
# add libraries
cp .build_release/lib/libcaffe.a distribute/lib
install -m 644 .build_release/lib/libcaffe.so.1.0.0-rc3 distribute/lib
cd distribute/lib; rm -f libcaffe.so; ln -s libcaffe.so.1.0.0-rc3 libcaffe.so
# add python - it's not the standard way, indeed...
cp -r python distribute/python
关于SSD模块的内幕:
因此编译前,首先需要做的就是:确认Autoware提供的自动寻找的ssdcaffe的路径是正确的:
到/home/autoware/autoware.ai/src/autoware/core_perception/vision_ssd_detect目录下,打开 CMakeLists.txt,
查看下面这行的路径是否是ssdcaffe的路径(我直接改成了绝对路径):
set(SSD_CAFFE_PATH "/home/autoware/ssdcaffe/distribute")
目的是把vision_ssd_detect topic编译进去!
AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
roslaunch vision_ssd_detect vision_ssd_detect.launch network_definition_file:=/home/autoware/ssdcaffe/models/VGGNet/VOC0712Plus/SSD_300x300/deploy.prototxt pretrained_model_file:=/home/autoware/ssdcaffe/models/VGGNet/VOC0712Plus/SSD_300x300/VGG_VOC0712Plus_SSD_300x300_iter_240000.caffemodel
这条命令好长。。但真的只是一条
/home/autoware/autoware.ai/install/vision_ssd_detect/lib/vision_ssd_detect/vision_ssd_detect: error while loading shared libraries: libcaffe.so.1.0.0-rc3: cannot open shared object file: No such file or directory
解决1. 改 ssd的 CMakeLists.txt(理论上感觉是对的,但是没用,并没有解决。。):
target_link_libraries(vision_ssd_detect
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
${SSD_CAFFE_PATH}/lib/libcaffe.so
${SSD_CAFFE_PATH}/lib/libcaffe.so.1.0.0-rc3
glog
)
解决2: 成功了
把libcaffe.so.1.0.0-rc3 链接到 /usr/lib/x86_64-linux-gnu/ ,因为程序会从这儿找库:
ln -s /home/autoware/ssdcaffe/distribute/lib/libcaffe.so.1.0.0-rc3 /usr/lib/x86_64-linux-gnu/
和yolo3的运行差不多,跳过
解决: 在图形界面选择Computing – vision_detect_ssd的时候, 先点开app, 在image_src 选择 /image_raw (注:这里不要选/camera0/image_raw)。 然后在勾选vision_detect_ssd会弹出一个框,此时选择/camera0。 从而保证只有一个/camera0
roslaunch lidar_point_pillars lidar_point_pillars.launch pfe_onnx_file:=/home/autoware/shared_dir/autoware_data/detect/kitti_pretrained_point_pillars/pfe.onnx rpn_onnx_file:=/home/autoware/shared_dir/autoware_data/detect/kitti_pretrained_point_pillars/rpn.onnx input_topic:=/points_raw
ERROR: ModelImporter.cpp:457 In function importModel:
[4] Assertion failed: !_importer_ctx.network()->hasImplicitBatchDimension() && “This version of the ONNX parser only supports TensorRT INetworkDefinitions with an explicit batch dimension. Please ensure the network was created using the EXPLICIT_BATCH NetworkDefinitionCreationFlag.”
ERROR: failed to parse onnx file
[lidar_point_pillars-1] process has died [pid 27079, exit code 1, cmd /home/autoware/autoware.ai/install/lidar_point_pillars/lib/lidar_point_pillars/lidar_point_pillars /points_raw:=/points_raw __name:=lidar_point_pillars __log:=/home/autoware/.ros/log/55ff3366-b236-11ea-a635-0013eff13975/lidar_point_pillars-1.log].
log file: /home/autoware/.ros/log/55ff3366-b236-11ea-a635-0013eff13975/lidar_point_pillars-1*.log
https://github.com/onnx/onnx-tensorrt/issues/266
https://github.com/Autoware-AI/core_perception/tree/master/lidar_point_pillars
// create the builder
nvinfer1::IBuilder* builder = nvinfer1::createInferBuilder(g_logger_);
const auto explicitBatch = 1U << static_cast(nvinfer1::NetworkDefinitionCreationFlag::kEXPLICIT_BATCH);
// nvinfer1::INetworkDefinition* network = builder->createNetwork();
nvinfer1::INetworkDefinition *network = builder->createNetworkV2(explicitBatch);
编译还是会报一些warning,不过能跑通.
WARNING: Explicit batch network detected and batch size specified, use enqueue without batch size instead.
[ERROR] [1592577952.828638645]: “base_link” passed to lookupTransform argument target_frame does not exist.
解决:所以要使用autoware图形界面运行 lidar_point_pillars
一直提示[sudo] password for autoware: Sorry, try again.
解决:
sudo passwd user(user 是对应的用户名)
https://blog.csdn.net/qq_28959531/article/details/78989635
rosrun rqt_graph rqt_graph
Computing – range_vision_fusion打钩
注意:要把Sensing的Calibration Publisher选中,其中ref选择 相机雷达的标定文件 .yml
topic名称是:range_vision_fusion_01