![](/img/trans.png)
[英]XMLSchemaChildrenValidationError in Carla simulator (Python 3.7)
[英]How to establish data communication between Python and the Carla simulator?
我將 Carla 模擬器下載到我的 Windows PC,我正在嘗試將 Carla 真實引擎鏈接到 python,但我不確定如何。 我想使用python定位車輛,我們如何訪問python中的接口? 謝謝!
因此,您需要啟動 CARLA 並連接到客戶端,然后集成 API...
首先,使用(Windows 版本)中的可執行文件通過命令行啟動 CARLA
cd /carla/root
./CarlaUE4.sh
您將轉到文件目錄,然后運行引擎
通過python API使用CARLA,需要將Python客戶端通過一個端口連接到服務器,這樣就可以連接和控制仿真了
import carla
import random
# Connecting to a client and retrieve the world object
client = carla.Client('localhost', 2000)
world = client.get_world()
客戶端object 只是客戶端連接到服務器的實例,您將使用它來加載函數
在您的情況下,如果您想使用world.get_actors()方法關注模擬中的所有車輛,您可以過濾掉車輛並使用set_autopilot()方法將車輛控制給交通管理器
for vehicle in world.get_actors().filter('vehicle'):
vehicle.setUautopilot(true)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.