openpilot在carla中运行(含代码修正---已完结)


版本说明:

ubuntu      20.04

carlasim/carla     0.9.11

openpilot            Version 0.8.9 (2021-08-XX)  下载自github,持续更新

 

今天在浏览文件的时候,看见官网的文件里说:

Testing on PC
------
For simplified development and experimentation, openpilot can be run in the CARLA driving simulator, which allows you to develop openpilot without a car. The whole setup should only take a few minutes.

Steps:
1) Start the CARLA server on first terminal
```
bash -c "$(curl https://raw.githubusercontent.com/commaai/openpilot/master/tools/sim/start_carla.sh)"
```
2) Start openpilot on second terminal
```
bash -c "$(curl https://raw.githubusercontent.com/commaai/openpilot/master/tools/sim/start_openpilot_docker.sh)"
```
3) Press 1 to engage openpilot

See the full [README](tools/sim/README.md)

于是我找到了tools/sim/README.md,查看了里面的内容,如下:

openpilot in simulator
=====================


## Running the simulator

First, start the CARLA server.
```
./start_carla.sh
```

Then start bridge and openpilot.
```
./start_openpilot_docker.sh
```

To engage openpilot press 1 a few times while focused on bridge.py to increase the cruise speed.

## Controls

You can control openpilot driving in the simulation with the following keys

|  key  |   functionality   |
| :---: | :---------------: |
|   1   |  Cruise up 5 mph  |
|   2   | Cruise down 5 mph |
|   3   |   Cruise cancel   |
|   q   |     Exit all      |

To see the options for changing the environment, such as the town, spawn point or precipitation, you can run `./start_openpilot_docker.sh --help`.
This will print the help output inside the docker container. You need to exit the docker container before running `./start_openpilot_docker.sh` again.

## System Requirements

openpilot doesn't have any extreme hardware requirements, however CARLA is very resource-intensive and may not run smoothly on your system. For this case, we have a low quality mode you can activate by running:
```
./start_openpilot_docker.sh --low_quality
```
NOTE: [CARLA requires](https://carla.readthedocs.io/en/latest/build_docker/) an NVIDIA graphics card.

You can also check out the [CARLA python documentation](https://carla.readthedocs.io/en/latest/python_api/) to find more parameters to tune that might increase performance on your system

## Further Reading
The following resources contain more details and troubleshooting tips.
* [CARLA on the openpilot wiki](https://github.com/commaai/openpilot/wiki/CARLA) 
里面描述了,如何在docker的容器中运行openpilot。

进入文件夹,运行如下命令:

./start_carla.sh

然后他提示:

Nvidia docker is required. Re-run with INSTALL=1 to automatically install.

所以,加入参数后运行:

INSTALL=1 ./start_carla.sh

然后,又提示缺少docker。docker的安装步骤参考下文:

https://blog.csdn.net/BigData_Mining/article/details/104991349

安装之后,如果出现Permession deneyed的报错还需要进行如下配置:

sudo chmod a+rw /var/run/docker.sock

完成后,输入docker version,如果输出如下就说明docker可以用了:

再次运行start_carla.sh,会下载carla的image,用于在docker中启动虚拟驾驶,耐心等待。

 下在完成后,报错:

docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].

重启docker:

sudo systemctl restart docker

再次运行start_carla.sh:

./start_carla.sh

显示以下信息:

4.24.3-0+++UE4+Release-4.24 518 0
Disabling core dumps.
sh: 1: xdg-user-dir: not found

此时,打开新终端,进入openpilot/tools/sim输入以下命令:

./start_openpilot_docker.sh

如果你是第一次运行,会下载openpilot的image,完成后,会出现一个ui界面,此时,在刚刚运行./start_openpilot_docker.sh的终端中持续按1,会进入自动驾驶的虚拟环境中。

但是,仅仅这样还是不够的。依照官方的说明,在终端2中按“1”建会开启自动驾驶并且增加自动驾驶的速度,然而,如果你尝试去按1,ui界面屏幕中会出现"openpilot not available ..."的错误。因此,我们还需要对openpilot的代码进行修改,具体步骤如下:

1.首先关闭刚刚打开的两个终端,结束docker在运行的容器。

2.找到openpilot/selfdrive/manager/manager.py

3.进行如下修改:

将红色的部分修改为绿色,补充判定的逻辑。

4.中心运行start_carla.sh和start_openpilot_docker.sh

至此,openpilot在虚拟环境中便可以正常运行。

对于该问题的详细内容,请参考我的github:Torch-HXM

 

2021年8月31日09:58:53


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM