资讯详情

Carla学习笔记-高级传感器设置

本笔记翻译于Carla官方文档

设置高级传感器

脚本tutorial_replay.py包含了更多传感器的定义。它们的工作原理和基本的一样,但理解起来可能有点难。

深度相机

深度相机生成场景的图片在灰度深度图中映射每个像素。然而,输出并不简单。使用相机的深度缓冲器RGB色彩空间映射。为了便于理解,必须将其转化为灰度。为此,简单地保存图像和RGB相机,但应用carla.ColorConverter。深度相机有两种转换: Carla.ColorConverter.Depth 以毫米精度转换原始深度 Carla.ColorConverter.LogarithmicDepth 它也是毫米粒度,可以在近距离提供更好的结果,但在长距离内表现不如上述好 深度相机的属性度相机的属性RGB相机中声明的元素:fov, image_size_x, image_size_y和sensor_tick。脚本将传感器设置为以前使用的传感器RGB相机匹配。

depth_cam = None depth_bp = world.get_blueprint_library().find(‘sensor.camera.depth’) depth_location = carla.Location(2,0,1) depth_rotation = carla.Rotation(0,180,0) depth_transform = carla.Transform(depth_location,depth_rotation) depth_cam = world.spawn_actor(depth_bp,depth_transform,attach_to=ego_vehicle, attachment_type=carla.AttachmentType.Rigid) depth_cam.listen(lambda image: image.save_to_disk(‘tutorial/new_depth_output/%.6d.jpg’ % image.frame,carla.ColorConverter.LogarithmicDepth))

语义分割相机

语义分割摄像头以不同的颜色渲染场景中的元素,以标记这些元素。标签是由模拟器根据生成资源的路径创建的。例如,在Unreal/CarlaUE4/ content /Static/标记为行人的网格生成在行人中。 输出是像任何相机一样的图像,但每个像素都包含在红色通道中编码的标签中。必须使用这个原始图像ColorConverter.CityScapesPalette转换。可以创建新标签,更多信息请参考文档。 该相机的属性与深度相机完全相同。脚本还将其设置为与原始相匹配RGB摄像机。 sem_cam = None sem_bp = world.get_blueprint_library().find(‘sensor.camera.semantic_segmentation’) sem_bp.set_attribute(“image_size_x”,str(1920)) sem_bp.set_attribute(“image_size_y”,str(1080)) sem_bp.set_attribute(“fov”,str(105)) sem_location = carla.Location(2,0,1) sem_rotation = carla.Rotation(0,180,0) sem_transform = carla.Transform(sem_location,sem_rotation) sem_cam = world.spawn_actor(sem_bp,sem_transform,attach_to=ego_vehicle, attachment_type=carla.AttachmentType.Rigid) sem_cam.listen(lambda image: image.save_to_disk(‘tutorial/new_sem_output/%.6d.jpg’ % image.frame,)

激光雷达

激光雷达传感器模拟旋转激光雷达。D中映场景。激光雷达包含一组以特定频率旋转的激光器。激光投射冲击距离,并将每个投影存储在一个点。 不同的传感器属性可以设置激光阵列的布置。 Upper_fov和lower_fov激光角度最高、最低 channels设置激光器的使用量。它们遵循所需的要求fov分布。 这一点的计算方法是由其他属性设置的。它们决定每个激光每一步计算的点数:points_per_second / (FPS *channels)。 range能捕获的最大距离 points_per_second是每秒获得的点数。除以通道的数量。 Rotation_frequency激光雷达每秒旋转的次数 可被保存为.ply标准文件格式 lidar_cam = None lidar_bp = world.get_blueprint_library().find(‘sensor.lidar.ray_cast’) lidar_bp.set_attribute(‘channels’,str(32)) lidar_bp.set_attribute(‘points_per_second’,str(90000)) lidar_bp.set_attribute(‘rotation_frequency’,str(40)) lidar_bp.set_attribute(‘range’,str(20)) lidar_location = carla.Location(0,0,2) lidar_rotation = carla.Rotation(0,0,0) lidar_transform = carla.Transform(lidar_location,lidar_rotation) lidar_sen = world.spawn_actor(lidar_bp,lidar_transform,attach_to=ego_vehicle) lidar_sen.listen(lambda point_cloud: point_cloud.save_to_disk(‘tutorial/new_lidar_output/%.6d.ply’ % point_cloud.frame) .ply文件可用MESHLAB查看 安装MESHLAB sudo apt-get update -y sudo apt-get install -y meshlab 打开Meshlab Meshlab

雷达

雷达传感器类似于激光雷达。它创建了一个圆锥形视图,并在内部发射激光来投射它们的影响。carla雷达测量。里面有carla.RadarDetection。由激光检索的雷达探测。这些不是空间中的点,而是与传感器有关的数据:方位、高度、传感器和速度。 传感器的属性主要取决于激光的定位。 Horizontal_fov、vertical_fov确定圆锥视图的振幅 Channels 设置激光器的使用量。它们遵循所需的要求fov分布 range 雷达照射的最大距离。 Points_per_second 在指定通道之间设置要捕获的点的数量。 脚本将传感器放置在汽车引擎盖上,并稍微向上旋转。这样,输出将映射汽车的前视图。horizontal_fov增加,vertical_fov减少。感兴趣的区域是车辆和行人通常移动的高度。射程也从100米改为10米,以便只在车辆正前方检索数据。 这个回调有点复杂,显示出更多的功能。它会在飞行中画出雷达捕捉到的点。这些点的颜色将取决于它们的相对性ego车速。 蓝色表示靠近车辆的点 红色代表远离车辆的点 白色代表静止点 rad_cam = None rad_bp = world.get_blueprint_library().find(‘sensor.other.radar’) rad_bp.set_attribute(‘horizontal_fov’, str(35)) rad_bp.set_attribute(‘vertical_fov’, str(20)) rad_bp.set_attribute(‘range’, str(20)) rad_location = carla.Location(x=2.0, z=1.0) rad_rotation = carla.Rotation(pitch=5) rad_transform = carla.Transform(rad_location,rad_rotation) rad_ego = world.spawn_actor(rad_bp,rad_transform,attach_to=ego_vehicle, attachment_type=carla.AttachmentType.Rigid) def rad_callback(radar_data): velocity_range = 7.5 # m/s current_rot = radar_data.transform.rotation for detect in radar_data: azi = math.degrees(detect.azimuth) alt = math.degrees(detect.altitude) # The 0.25 adjusts a bit the distance so the dots can # be properly seen fw_vec = carla.Vector3D(x=detect.depth - 0.25) carla.Transform( carla.Location(), carla.Rotation( pitch=current_rot.pitch alt, yaw=current_rot.aw + azi, roll=current_rot.roll)).transform(fw_vec)

    def clamp(min_v, max_v, value):
        return max(min_v, min(value, max_v))

    norm_velocity = detect.velocity / velocity_range # range [-1, 1]
    r = int(clamp(0.0, 1.0, 1.0 - norm_velocity) * 255.0)
    g = int(clamp(0.0, 1.0, 1.0 - abs(norm_velocity)) * 255.0)
    b = int(abs(clamp(- 1.0, 0.0, - 1.0 - norm_velocity)) * 255.0)
    world.debug.draw_point(
        radar_data.transform.location + fw_vec,
        size=0.075,
        life_time=0.06,
        persistent_lines=False,
        color=carla.Color(r, g, b))

rad_ego.listen(lambda radar_data: rad_callback(radar_data))

标签: g37前abs传感器fps00传感器

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台