GETTING-STARTED

介绍

核心模块

Traffic manager:用于控制车辆的内置系统,它作为 CARLA 的指挥者,来创建真实城市般的虚拟环境

Sensors:车辆依靠它们来传播周围的信息。在 CARLA 中,它们是附加在车辆上的特定的角色(传感器),它们接收的数据可以被检索和存储,以简化过程。目前,该项目支持不同类型的 sensor 从相机到雷达,激光雷达等等

Recorder:这个特性用于为 world 的每一个 actor 进行一步一步的模拟。它允许访问时间轴上的任何时刻,以及世界(world)上的任何地方

ROS bridge and Autoware implementation:这个模块可以让 CARLA 与 ROS 还有 Autoware 交互,正是这个模块的存在使得在仿真里测试自动驾驶系统变得更加容易

Open assets:CARLA 通过对天气条件的控制,为城市设置提供了不同的地图。同时,它也提供了一个具有许多 actors 数据集的 blueprint library。但是,这些元素可以根据简单的指导原则进行定制或者生成新的元素

Scenario runner:为了简化车辆的学习过程,CARLA 提供了一系列描述不同情况的路线,每个人都可以使用这些路线测试自己的解决方案

配置 CARLA 的前提

  • System requirements:Linux or Windows
  • An adequate GPU:至少 6GB 的 GPU,通常推荐 8GB
  • Disk space:CARLA 将占据约 20GB 的空间
  • Python:Python 是 CARLA 使用的主要语言,在 Linux 上支持 2.7 和 3.x,但在 Windows 只支持 3.x(直接使用 Github 上编译好的版本似乎只支持 3.7?)
  • Pip:根据 Python 的版本而定
  • Two TCP ports and good internet connection:默认是 2000 和 2001 端口,必须确保这两者没有被墙
  • Other requirements:使用 CARLA 前需要安装 pygame 和 numpy 这两个依赖

安装 CARLA

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1AF1527DE64CB8D9
sudo add-apt-repository "deb [arch=amd64] http://dist.carla.org/carla $(lsb_release -sc) main"
sudo apt-get update # Update the Debian package index
sudo apt-get install carla-simulator # Install the latest CARLA version, or update the current installation
cd /opt/carla-simulator # Open the folder where CARLA is installed
apt-cache madison carla-simulator # List the available versions of Carla
sudo apt-get install carla-simulator=0.9.10-1 # In this case, "0.9.10" refers to a CARLA version, and "1" to the Debian revision

注1:上述第一种方法官方支持 Ubuntu 18.04,而不支持 Ubuntu 20.04

注2:第二种方法仅需下载并解压缩文件。该文件包含了模拟器的预编译版本、Python API模块和一些用作示例的脚本

导入额外资源

每个发行版都有自己的额外资源和地图包,包括地图 Town06, Town07 和 Town10。它们是分开存储的,所以它们只能在主包安装后导入

  • 下载与当前 CARLA 版本相应的地图资源包

  • 解压

    • Linux:将该包移动到 Import 文件夹下,并执行以下命令
    cd path/to/carla/root
    ./ImportAssets.sh
    
    • Windows:直接在根文件夹中解压该包

安装 client library

CARLA 0.9.12+ 有几个选项可用于安装和使用 CARLA client library

  • .egg 文件:该文件位于 PythonAPI/carla/dist/ 中,如果已经用 pip 安装了 client library,那么优先选择 .egg 文件,但需要将之前的版本删除
  • .whl 文件:该文件位于 PythonAPI/carla/dist/ 中,需要安装 .whl 文件,而且不同版本的 python 会有不同。安装时根据 python 版本运行下述命令
pip3 install <wheel-file-name>.whl   # Python 3
pip install <wheel-file-name>.whl    # Python 2
  • 下载 python 包:PyPi 下载只适合与 CARLA 包一起使用(如:不是从源代码构建的版本)。当与远程 CARLA 服务器通信,而不需要下载完整的 CARLA 包时是最有用的
pip3 install carla   # Python 3
pip install carla    # Python 2

注:不同方式的安装方法会导致不兼容,因此,尽可能使用虚拟环境,或者在使用新库之前卸载之前安装的库

  • 通过 conda 创建虚拟环境
conda env list                     # 查看有哪些虚拟环境
conda create -n test python=3.7    # 创建名称为 test,python 版本为 3.7 的虚拟环境
conda activate test                # 激活虚拟环境 test
pip install carla                  # 安装 carla 包
conda deactivate                   # 退出当前虚拟环境

运行 CARLA

  • Debian installation
cd /opt/carla-simulator/bin/
./CarlaUE4.sh
  • Linux package installation
cd path/to/carla/root
./CarlaUE4.sh
  • Windows package installation
cd path/to/carla/root
CarlaUE4.exe

注1:Windows 可能出现 Microsoft Visual C++ Runtime 提示,这是由于电脑安装 VC++ 运行环境,导致报错。一般下载 VC++ 安装后重启即可

在这里插入图片描述
注2:出现 DirectX Runtime 时需要安装 DirectX,通过 “win+R 输入 dxdiag”可查看本机需要的 DirectX 版本。安装后若出现 xxx.dll 缺失,则去下载相应的 dll 文件。下载后将 dll 文件放到 C:\windows\system32 中,然后在“ win+R,输入 regsvr32 xxx.dll

  • 运行预先提供的脚本文件为城市生成一些生命(汽车、人物等)并通过键盘操控一辆车
# Terminal A 
cd PythonAPI\examples
python3 -m pip install -r requirements.txt # Support for Python2 is provided in the CARLA release packages
python3 generate_traffic.py  

# Terminal B
cd PythonAPI\examples
python3 manual_control.py 
  • 命令行选项

    • 启动 CARLA 前可以按照以下形式使用一些设置选项
    ./CarlaUE4.sh -carla-rpc-port=3000
    
    • PythonAPI/util/config.py 中提供了更多的配置选项,为了使这些选项生效,需要在服务器启动前运行 config.py 文件
    ./config.py --no-rendering      # Disable rendering
    ./config.py --map Town05        # Change map
    ./config.py --weather ClearNoon # Change weather
    
    ./config.py --help              # Check all the available configuration options
    

更新 CARLA

​ 没有办法更新 CARLA 的打包版本(There is no way to update the packaged version of CARLA)。当发布新版本时,存储库将更新,需要删除以前的版本并安装新版本。如果使用 pip/pip3 安装 client library,可运行以下命令删除 CARLA。

pip3 uninstall carla  # Python 3
pip uninstall carla   # Python 2

Supongo que te gusta

Origin blog.csdn.net/steven_ysh/article/details/121964891
Recomendado
Clasificación