Apollo自动泊车APA仓库auto_parking运行说明
背景知识
仓库地址:https://github.com/MiyagiRonin/auto_parking
知乎专栏:https://zhuanlan.zhihu.com/p/548096462
仓库说明
下载仓库
git clone https://github.com/MiyagiRonin/auto_parking
How to run
You need to install Bazel and Python to run the code.
- Run the program and save path into text file, you may need to run executable manually in WindowsOS.
$ bazel run main
- Read path and show the animation.
$ python show_animation.py
作者说在WindowsOS运行,还是别了,在Ubuntu运行吧
问题总结
bazel run main出错
log
Command 'bazel' not found, did you mean:
command 'babel' from deb openbabel
Try: sudo apt install <deb name>
解决办法
https://bazel.build/install/ubuntu?hl=zh-cn
第 1 步:将 Bazel 分发 URI 添加为软件包来源
注意:此步骤只需执行一次。
$ sudo apt install apt-transport-https curl gnupg -y
$ curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg
$ sudo mv bazel-archive-keyring.gpg /usr/share/keyrings
$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
第 2 步:安装和更新 Bazel
$ sudo apt update && sudo apt install bazel
进行curl步骤时可能存在如下问题,网络问题请多次尝试
curl: (7) Failed to connect to bazel.build port 443: Connection timed out
安装后可使用如下命令查看是否安装成功
$ bazel --version
bazel 6.2.1
bazel run main仍然出错
log
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Analyzed target //:main (43 packages loaded, 295 targets configured).
INFO: Found 1 target...
ERROR: /home/apadmin/auto_parking/auto_parking/BUILD:35:10: Compiling main.cc failed: (Exit 1): gcc failed: error executing command (from target //:main) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF bazel-out/k8-fastbuild/bin/_objs/main/main.pic.d ... (remaining 25 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
main.cc:9:10: fatal error: absl/strings/str_split.h: No such file or directory
#include <absl/strings/str_split.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Target //:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 34.465s, Critical Path: 0.88s
INFO: 8 processes: 8 internal.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target
主要是 “fatal error: absl/strings/str_split.h: No such file or directory” 这句的问题
解决方法
下载absl库,具体为在根目录
$ git clone https://github.com/abseil/abseil-cpp.git
$ cp -r ./abseil-cpp/absl/ ./absl
无法打开reverse_verticle_1.txt
log
Target //:main up-to-date:
bazel-bin/main
INFO: Elapsed time: 5.882s, Critical Path: 1.96s
INFO: 33 processes: 1 internal, 32 processwrapper-sandbox.
INFO: Build completed successfully, 33 total actions
INFO: Running command line: bazel-bin/main
Can't open ../problems/reverse_verticle_1.txt
解决方法
暴力破解(暂时)
$ grep -r reverse_verticle_1.txt
Binary file .git/index matches
main.cc: std::string file_name = "../problems/reverse_verticle_1.txt";
show_animation.py:env_file = open("problems/reverse_verticle_1.txt", 'r')
找到确认在main.cc文件中,将句柄替换为绝对路径,成功
Target //:main up-to-date:
bazel-bin/main
INFO: Elapsed time: 0.729s, Critical Path: 0.65s
INFO: 3 processes: 1 internal, 2 processwrapper-sandbox.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: bazel-bin/main
Time consuming is 1.34 ms.
Success!
python show_animation.py出错
log
Traceback (most recent call last):
File "show_animation.py", line 14, in <module>
path_file = open("bazel-bin/output_path.txt", 'r')
IOError: [Errno 2] No such file or directory: 'bazel-bin/output_path.txt'
找不到output_path.txt,不知道bazel编译的时候怎么生成的,我们先找到这个文件
解决办法
$ find / -name output_path.txt 2>&1 | grep -v "Permission denied"
此命令可将"Permission denied"词条全部屏蔽
找到后在show_animation.py修改路径即可运行