【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.

  1. Run the program and save path into text file, you may need to run executable manually in WindowsOS.
$ bazel run main
  1. 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修改路径即可运行

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值