当前位置: 代码迷 >> 综合 >> carla学习笔记2 传感器和数据
  详细解决方案

carla学习笔记2 传感器和数据

热度:40   发布时间:2024-02-05 03:58:49.0

第四。传感器和数据

传感器是从周围环境中检索数据的参与者。它们对于为驾驶人创造学习环境至关重要。

本页总结了开始处理传感器所需的一切。它介绍了可用的类型及其生命周期的逐步指南。有关每个传感器的详细信息,请参阅传感器参考 .

  • 传感器逐步
    • 设置
    • 产卵
    • 听
    • 数据
  • 传感器类型
    • 摄像机
    • 探测器
    • 其他

传感器逐步

类 carla.Sensor定义一种能够测量和流式传输数据的特殊类型的参与者。

  • 这是什么数据?根据传感器的类型,其变化很大。所有类型的数据都继承自carla.SensorData .
  • 他们什么时候检索数据?在每个模拟步骤上,或者在注册某个事件时。取决于传感器的类型。
  • 他们如何检索数据?每个传感器都有听()方法来接收和管理数据。

尽管存在差异,但所有传感器的使用方式都是相似的。

设置

与其他参与者一样,找到蓝图并设置特定属性。这在处理传感器时至关重要。它们的属性将决定所获得的结果。这些在传感器参考 .

以下示例设置仪表板高清摄像头。

# Find the blueprint of the sensor.
blueprint = world.get_blueprint_library().find('sensor.camera.rgb')
# Modify the attributes of the blueprint to set image resolution and field of view.
blueprint.set_attribute('image_size_x', '1920')
blueprint.set_attribute('image_size_y', '1080')
blueprint.set_attribute('fov', '110')
# Set the time in seconds between sensor captures
blueprint.set_attribute('sensor_tick', '1.0')

产卵

附件和附件类型,是至关重要的。传感器应该连接到一个父参与者,通常是一个交通工具,跟踪它周围并收集信息。附件类型将决定其位置如何与所述车辆相关。

  • 刚性连接移动对于其父位置是严格的。这是从模拟中检索数据的正确附件。
  • 弹簧臂附件只需很少的加速和减速,运动就变得轻松了。此附件仅推荐用于录制模拟视频。移动是平滑的,并且在更新相机位置时避免了“跳跃”。
transform = carla.Transform(carla.Location(x= zero point eight, z= one point seven))sensor = world.spawn_actor(blueprint, transform, attach_to=my_vehicle)

重要的

使用附件生成时,位置必须相对于父参与者。

听

每个传感器都有listen()方法。每次传感器检索数据时都会调用此函数。

参数callback是一个lambda函数. 它描述了在检索数据时传感器应该做什么。这必须将数据作为参数检索。

# do_something() will be called each time a new image is generated by the camera.
sensor.listen(lambda data: do_something(data))...# This collision sensor would print everytime a collision is detected. 
def callback(event):for actor_id in event:vehicle = world_ref().get_actor(actor_id)print('Vehicle too close: %s' % vehicle.type_id)sensor02.listen(callback)

数据

大多数传感器数据对象都具有将信息保存到磁盘的功能。这将允许它在其他环境中使用。

传感器数据在传感器类型之间有很大的不同。看看传感器参考得到详细的解释。但是,所有这些都带有一些基本信息。

Sensor data attribute Type Description
frame int Frame number when the measurement took place.
timestamp double Timestamp of the measurement in simulation seconds since the beginning of the episode.
transform carla.Transform World reference of the sensor at the time of the measurement.

注意:

is_listening is a sensor attribute that enables/disables data listening at will.
sensor_tick is a blueprint attribute that sets the simulation time between data received.


传感器类型

摄像机

从他们的角度看世界。helper类卡拉彩色转换器将修改所述图像以表示不同的信息。

  • 检索数据每个模拟步骤
Sensor Output Overview
Depth carla.Image Renders the depth of the elements in the field of view in a gray-scale map.
RGB carla.Image Provides clear vision of the surroundings. Looks like a normal photo of the scene.
Semantic segmentation carla.Image Renders elements in the field of view with a specific color according to their tags.

探测器

当数据附加到的对象注册特定事件时检索数据。

  • 检索数据触发时
Sensor Output Overview
Collision carla.CollisionEvent Retrieves collisions between its parent and other actors.
Lane invasion carla.LaneInvasionEvent Registers when its parent crosses a lane marking.
Obstacle carla.ObstacleDetectionEvent Detects possible obstacles ahead of its parent.

其他

不同的功能,如导航、物理特性测量和场景的二维/三维点地图。

  • 检索数据每个模拟步骤
Sensor Output Overview
GNSS carla.GNSSMeasurement Retrieves the geolocation of the sensor.
IMU carla.IMUMeasurement Comprises an accelerometer, a gyroscope, and a compass.
LIDAR carla.LidarMeasurement A rotating LIDAR. Generates a 4D point cloud with coordinates and intensity per point to model the surroundings.
Radar carla.RadarMeasurement 2D point map modelling elements in sight and their movement regarding the sensor.
RSS carla.RssResponse Modifies the controller applied to a vehicle according to safety checks. This sensor works in a different manner than the rest, and there is specific RSS documentation for it.
Semantic LIDAR carla.SemanticLidarMeasurement A rotating LIDAR. Generates a 3D point cloud with extra information regarding instance and semantic segmentation.

这是一个传感器和如何检索模拟数据。

对卡拉的介绍到此结束。然而,还有很多东西要学。

 

 

  相关解决方案