1. 程式人生 > 其它 >ubuntu openpilot初次見面--在ubuntu上執行

ubuntu openpilot初次見面--在ubuntu上執行

上一篇文章講述了openpilot在ubuntu上的構建:https://www.cnblogs.com/torch-hxm/p/15143407.html

然而,並不知道這樣做下來有什麼用....(oxo)........

算了,一點點試吧,今天在瀏覽檔案的時候,看見官網的檔案裡說:

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)

好傢伙,這難道就是openpilot在PC端的測試方法?於是我找到了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) 
裡面描述了,如何在虛擬裝置上執行openpilot,也不知道是不是我想要的,索性試一試。

進入資料夾,執行如下命令:

./start_carla.sh

然後他提示:

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

我嘗試在./start_carla.sh後面加上INSTALL=1可惜失敗了,所以,我直接改了start_carla.sh,改動後如下:

 1 #!/bin/bash
 2 
 3 #Requires nvidia docker - https://github.com/NVIDIA/nvidia-docker
4 if ! $(apt list --installed | grep -q nvidia-container-toolkit); then 5 #if [ -z "$INSTALL" ]; then 6 # echo "Nvidia docker is required. Re-run with INSTALL=1 to automatically install." 7 # exit 0 8 #else 9 distribution=$(. /etc/os-release;echo $ID$VERSION_ID) 10 echo $distribution 11 curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - 12 curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list 13 sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit 14 sudo systemctl restart docker 15 #fi 16 fi 17 18 docker pull carlasim/carla:0.9.11 19 20 echo "#################pull finish##############" 21 22 docker run \ 23 --rm \ 24 --net=host \ 25 -e DISPLAY= \ 26 -e SDL_VIDEODRIVER=offscreen \ 27 -it \ 28 --gpus all \ 29 carlasim/carla:0.9.11 \ 30 ./CarlaUE4.sh -opengl -nosound -quality-level=Epic 31 32 echo "##################run finish##############"
View Code

然後再次執行這個.sh檔案,自動安裝所缺的元件,然後,又提示缺少docker,依照提示進行安裝。安裝之後,這個docker並不能直接使用,回報粗,還需要進行如下配置:

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

完成後,輸入docker version,如果輸出如下就說明docker可以用了:

再次執行start_carla.sh,會下載很多東西,耐心等待。

未完待續.....

2021年8月16日14:36:17