introdution:
- 开源软件
- unreal engine 4
- 用户通过Python API 调用, server –client 的形式- REF: https://carla.readthedocs.io/en/latest/python_api/
let’s start:
The API has been significantly changed in the latest versions starting at 0.9.0. We commonly refer to the new API as 0.9.X API as opposed to the previous 0.8.X API
Section 1 API 学习
官 下载软件包,解压, shit+右键,解压路径下打开shell窗口 .CarlaUE4.exe 运行
通过鼠标+ AWSD 控制运行,
打开路径:D:studycodesCARLA_0.9.5PythonAPIexamples
打开另一个shell, 运行官
-
创建(spawn) 场景元素,demo命令
With this script we are adding 80 vehicles to the world driving in “autopilot” mode. Back to the simulator window we should see these vehicles driving around the city. They will keep driving randomly until we stop the script. Let’s leave them there for now
这个命令实现了添加80个车辆,随机的自主运动。 CTR+C 结束演示。 脚本有难度,Lesson2 后,查看API
-
修改天气
- 天气自动变化
-
手动控制车辆
运行窗口如下:第三视角
第一课时结束。下课!:)
Lesson2 :
几个概念:
创建Client 对象:
模拟世界:
actor (模拟器中的演员对象-比如汽车)
blueprints–actor对应的属性(比如颜色,车型 etc),在构造蓝图blueprints中设置。–所有的属性都包含在 一个库中。
The library allows us to find specific blueprints by ID, filter them with wildcards, or just choosing one at random
Some of the attributes of the blueprints can be modified while some other are just read-only. For instance, we cannot modify the number of wheels of a vehicle but we can change its color
Modifiable attributes also come with a list of recommended values
了解了属性设置后,开始创建actor,
Once we have the blueprint set up, spawning an actor is pretty straightforward
shen
The spawn actor function comes in two flavours, and . The former will raise an exception if the actor could not be spawned, the later will return instead. The most typical cause of failure is collision at spawn point, meaning the actor does not fit at the spot we chose; probably another vehicle is in that spot or we tried to spawn into a static object.
To ease the task of finding a spawn location, each map provides a list of recommended transforms
推荐
We’ll add more on the map object later in this tutorial.
Finally, the spawn functions have an optional argument that controls whether the actor is going to be attached to another actor. This is specially useful for sensors. In the next example, the camera remains rigidly attached to our vehicle during the rest of the simulation
Note that in this case, the transform provided is treated relative to the parent actor.
讲了有点多,开始动手练习。直接在 calar解压路径下,创建练习code.(其他地方需要添加环境变量。要不然 下面会 缺少相关文件。
首先打开模拟器(server), 否则会 错
创建一个client. 创建actor, blueprints. 调用生成函数,在世界中生成。
代码在spyder中编译会 错。 “calra 没有 client这个属性!”—TB fix
偶尔发现可以正常运行。
暂时通过shell 命令行来执行。运行OK
参考官方example: spawn_npc.py ,尝试练习
都放到一起! 如下code
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!