5. Carla中Recorder(记录器)的使用

Recorder(记录器)

This feature allows to record and reenact a previous simulation. All the events happened are registered in the recorder file. There are some high-level queries to trace and study those events.
这个特性允许记录和重新执行以前的模拟。所有发生的事件都注册在记录文件中。有一些高级查询可以跟踪和研究这些事件。
• Recording
• Simulation playback
o Setting a time factor
• Recorded file
• Queries
o Collisions
o Blocked actors
• Sample Python scripts


Recording
All the data is written in a binary file on the server side only. However, the recorder is managed using the carla.Client.
所有数据仅在服务器端以二进制文件形式写入。但是,记录器是使用kara . client管理的。

Actors are updated on every frame according to the data contained in the recorded file. Actors in the current simulation that appear in the recording will be either moved or re-spawned to emulate it. Those that do not appear in the recording will continue their way as if nothing happened.

根据记录文件中包含的数据,在每一帧上对参与者进行更新。在当前模拟记录中出现的参与者将被移动或重新生成以模拟它。那些没有出现在记录中的参与者将继续他们的方式,就像什么也没有发生过一样。
Important
By the end of the playback, vehicles will be set to autopilot, but pedestrians will stop.
在回放结束时,车辆将被设置为自动驾驶,但行人将停止。
The recorder file includes information regarding many different elements.

记录器文件中包含很多不同元素的信息
• Actors — creation and destruction, bounding and trigger boxes.
• 演员:创建和毁灭(清除),边界(包围)和触发盒子
• Traffic lights — state changes and time settings.
• 交通灯的状态转换和时间设定
• Vehicles — position and orientation, linear and angular velocity, light state, and physics control.
• 车辆的位置和方向、线速度和角速度、车灯状态和物理位置
• Pedestrians — position and orientation, and linear and angular velocity.
• 行人的位置和方向、线速度和角速度,
• Lights — Light states from buildings, streets, and vehicles.
• 灯光:建筑物、街道和车辆灯光的状态

To start recording there is only need for a file name.
要开始记录,仅需要一个文件名
Using , / or : characters in the file name will define it as an absolute path. If no path is detailed, the file will be saved in CarlaUE4/Saved.
在文件名中使用\、/或:字符将其定义为绝对路径。如果没有详细的路径,文件将保存在CarlaUE4/ saved中。

client.start_recorder("/home/carla/recording01.log")
By default, the recorder is set to store only the necessary information to play the simulation back. In order to save all the information previously mentioned, the argument additional_data has to be configured when starting the recording.
默认情况下,记录器被设置为只存储回放模拟所需的信息。为了保存前面提到的所有信息,必须在开始记录时配置额外的参数additional_data。
client.start_recorder("/home/carla/recording01.log", True)
Note
Additional data includes: linear and angular velocity of vehicles and pedestrians, traffic light time settings, execution time, actors’ trigger and bounding boxes, and physics controls for vehicles.
附加数据包括:车辆和行人的线速度和角速度,交通灯时间设置,执行时间,演员的触发器和边界盒,以及车辆的物理控制。
To stop the recording, the call is also straightforward.
为了停止记录,对应的调用也是非常直接的。
client.stop_recorder()
Note
As an estimate, 1h recording with 50 traffic lights and 100 vehicles takes around 200MB in size.
据估计,50个红绿灯,100辆车记录1h,大约需要200MB大小的存储空间。


Simulation playback(仿真的回放)
A playback can be started at any point during a simulation. Besides the path to the log file, this method needs some parameters.
回放可以在模拟过程中的任何时刻启动。除了日志文件的路径外,该方法还需要一些参数。
client.replay_file(“recording01.log”, start, duration, camera)
Parameter Description Notes
start Recording time in seconds to start the simulation at. If positive, time will be considered from the beginning of the recording. If negative, it will be considered from the end.
duration Seconds to playback. 0 is all the recording. By the end of the playback, vehicles will be set to autopilot and pedestrians will stop.
camera ID of the actor that the camera will focus on. Set it to 0 to let the spectator move freely.

Setting a time factor
设定一个时间因子
The time factor will determine the playback speed. It can be changed any moment without stopping the playback.
播放的速度将由时间因子来决定,可以随时改变时间因子而不停止仿真的回放。
client.set_replayer_time_factor(2.0)
Parameter Default Fast motion Slow motion
time_factor 1.0 >1.0 <1.0

Important
If time_factor>2.0, the actors’ position interpolation is disabled and just updated. Pedestrians’ animations are not affected by the time factor.
如果time_factor>2.0,则禁用actor的位置插值,而只是更新。行人的动画不受时间因素的影响。
When the time factor is around 20x traffic flow is easily appreciated.
当时间因子在20x左右时,交通流易于识别。


Recorded file
The details of a recording can be retrieved using a simple API call. By default, it only retrieves those frames where an event was registered. Setting the parameter show_all would return all the information for every frame. The specifics on how the data is stored are detailed in the recorder’s reference.
可以使用一个简单的API调用检索记录的详细信息。默认情况下,它只提取/回放记录了事件的那些帧。设置参数show_all将返回每一帧的所有信息。关于数据如何存储的细节在记录器的引用( recorder’s reference)中有详细说明。

Show info for relevant frames

print(client.show_recorder_file_info(“recording01.log”))
• Opening information. Map, date and time when the simulation was recorded.(打开的信息:当仿真被记录时的地图,日期和时间)
• Frame information. Any event that could happen such as actors spawning or collisions. It contains the actors’ ID and some additional information.
• 帧的信息:任何可能发生的事件,如演员的产生或碰撞。它包含参与者的ID和一些附加信息。
• Closing information. Number of frames and total time recorded.
• 关闭的信息。帧数和总记录时间。
Version: 1
Map: Town05
Date: 02/21/19 10:46:20
Frame 1 at 0 seconds
Create 2190: spectator (0) at (-260, -200, 382.001)
Create 2191: traffic.traffic_light (3) at (4255, 10020, 0)
Create 2192: traffic.traffic_light (3) at (4025, 7860, 0)

Create 2258: traffic.speed_limit.90 (0) at (21651.7, -1347.59, 15)
Create 2259: traffic.speed_limit.90 (0) at (5357, 21457.1, 15)
Frame 2 at 0.0254253 seconds
Create 2276: vehicle.mini.cooperst (1) at (4347.63, -8409.51, 120)
number_of_wheels = 4
object_type =
color = 255,241,0
role_name = autopilot

Frame 2350 at 60.2805 seconds
Destroy 2276
Frame 2351 at 60.3057 seconds
Destroy 2277

Frames: 2354
Duration: 60.3753 seconds


Queries(查询)
Collisions
Vehicles must have a collision detector attached to record collisions. These can be queried, using arguments to filter the type of the actors involved in the collisions. For example, h identifies actors whose role_name = hero, usually assigned to vehicles managed by the user. There is a specific set of actor types available for the query.
车辆上必须要附加一个碰撞检测器以对碰撞情况进行记录。可以通过使用参数来过滤冲突中涉及的参与者的类型来查询这些内容。例如,h代表role_name = hero,这一角色。通常分配给由用户管理的车辆。查询中有一组特定的参与者类型。
• h = Hero
• v = Vehicle
• w = Walker
• t = Traffic light
• o = Other
• a = Any

Note
The manual_control.py script assigns role_name = hero for the ego vehicle.
manual_control.py脚本中将role_name = hero分配为自主车辆。
The collision query requires two flags to filter the collisions. The following example would show collisions between vehicles, and any other object.
(碰撞)冲突查询需要两个标志来过滤冲突。下面的示例将显示车辆和任何其他对象之间的碰撞。
print(client.show_recorder_collisions(“recording01.log”, “v”, “a”))
The output summarizes time of the collision, and type, ID and description of the actors involved.

Version: 1
Map: Town05
Date: 02/19/19 15:36:08

Time  Types     Id Actor 1                          		       Id Actor 2
  16   v v     122 vehicle.yamaha.yzf                     118 vehicle.dodge_charger.police
  27   v o     122 vehicle.yamaha.yzf                       0

Frames: 790
Duration: 46 seconds
Important
As it is the hero or ego vehicle who registers the collision, this will always be Actor 1.
因为记录碰撞的是英雄或自主车辆,所以这将永远是演员1。
The collision can be reenacted by using the recorder and setting it seconds before the event.
通过使用记录器并在事件发生前几秒设置它,可以重现碰撞发生的过程。
client.replay_file(“col2.log”, 13, 0, 122)
In this case, the playback showed this.
在这里插入图片描述Blocked actors(被堵塞的演员)
Detects vehicles that where stucked during the recording. An actor is considered blocked if it does not move a minimum distance in a certain time. This definition is made by the user during the query.
检测车辆在哪里停留在记录期间。如果actor在一定时间内没有移动最小距离,则认为它被阻塞了。这个定义是由用户在查询期间做出的。(默认为30s,10厘米)
print(client.show_recorder_actors_blocked(“recording01.log”, min_time, min_distance))
Parameter Description Default
min_time Minimum seconds to move min_distance. 30secs.
min_distance Minimum centimeters to move to not be considered blocked. 10cm.

Note
Sometimes vehicles are stopped at traffic lights for longer than expected.
有时车辆停在红绿灯前的时间比预期的要长。
下面的例子认为车辆在60秒内移动不到1米时将被认定为阻塞。
The following example considers that vehicles are blocked when moving less than 1 meter during 60 seconds.
client.show_recorder_actors_blocked(“col3.log”, 60, 100)
The output is sorted by duration, which states how long it took to stop being “blocked” and move the min_distance.
输出按持续时间排序,它表示停止“阻塞”和移动min_distance所需的时间。
Version: 1
Map: Town05
Date: 02/19/19 15:45:01
Time Id Actor Duration
36 173 vehicle.nissan.patrol 336
75 214 vehicle.chevrolet.impala 295
302 143 vehicle.bmw.grandtourer 67
Frames: 6985
Duration: 374 seconds
The vehicle 173 was stopped for 336 seconds at time 36 seconds. Reenact the simulation a few seconds before the second 36 to check it out.
client.replay_file(“col3.log”, 34, 0, 173)
在这里插入图片描述


Sample python scripts(简单的Python脚本)
Some of the provided scripts in PythonAPI/examples facilitate the use of the recorder.
在PythonAPI/examples中提供的一些脚本有助于使用记录器。
• start_recording.py starts the recording. The duration of the recording can be set, and actors can be spawned at the beginning of it.
• start_record .py开始记录。可以设置记录的持续时间,并且可以在开始时生成参与者。

Parameter Description
-f Filename.
-n (optional) Vehicles to spawn. Default is 10.
-t (optional) Duration of the recording.

• start_replaying.py starts the playback of a recording. Starting time, duration, and actor to follow can be set.
• start_replaying.py开始记录的回放。可以设置启动时间、持续时间和要跟随的演员。

Parameter Description
-f Filename.
-s (optional) Starting time. Default is 10.
-d (optional) Duration. Default is all.
-c (optional) IDof the actor to follow.

• show_recorder_file_info.py shows all the information in the recording file. By default, it only shows frames where an event is recorded. However, all of them can be shown.
• show_recorder_file_info.py显示记录文件中的所有信息。默认情况下,它只显示记录事件的帧。然而,所有这些都可以显示出来。

Parameter Description
-f Filename.
-s (optional) Flag to show all details.

• show_recorder_collisions.py shows recorded collisions between two flags of actors of types A and B. -t = vv would show all collisions between vehicles.
• show_recorder_collision .py显示A类和b类演员的两个标志之间记录的碰撞 -t = vv 显示所有车辆之间的碰撞。

Parameter Description
-f Filename.
-t Flags of the actors involved.
h = hero
v = vehicle
w = walker
t = traffic light
o = other
a = any

• show_recorder_actors_blocked.py lists vehicles considered blocked. Actors are considered blocked when not moving a minimum distance in a certain time.
• show_recorder_actors_block .py列出被阻塞的车辆。当演员在一段时间内移动不到最小距离时,就会被认为是被挡住了。

Parameter Description
-f Filename.
-t (optional) Time to move -d before being considered blocked.
-d (optional) Distance to move to not be considered blocked.


Now it is time to experiment for a while. Use the recorder to playback a simulation, trace back events, make changes to see new outcomes.
现在是试验一段时间的时候了。使用记录器回放模拟、追溯事件、进行更改以查看新的结果。

参考链接:https://carla.readthedocs.io/en/0.9.9/adv_recorder/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值