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