#carla的基本概念:world/blueprint/spawn_point/actor
client = carla.Client('localhost', 2000)
#获取所有的地图
maps = client.get_available_maps()
for map in maps:
print(map)
的#获取虚拟世界
world = client.get_world()
map = world.get_map()
#blueprint
blueprint_library = map.get_blueprint_library()
#获取各种bp
model3_bp = blueprint_library.filter('model3')[0]
bwm_bp = random.choice(blueprint_library.filter('bwm*'))
camera_rgb_bp = blueprint_library.find('sensor.camera.rgb')
camera_depth_bp = blueprint_library.find('sensor.camera.depth')
camera_semantic_segmentation_bp = blueprint_library.find('sensor.camera.semantic_segmentation')
lidar_ray_cast_bp = blueprint_library.find('sensor.lidar.ray_cast')
collision_bp = blueprint_library.find('sensor.other.collision')
lane_invasion_bp = blueprint_library.find('sensor.other.lane_invasion')
obstacle_bp = blueprint_library.find('sensor.other.obstacle')
#生成点
spawn_point = random.choice(map.get_spawn_points())
transform = carla.Transform()
#生成演员
model3 = world.spawn_actor(model3_bp, spawn_point)
camera_rgb = world.spawn_actor(camera_rgb_bp, transform, attach_to = model3)
camera_depth = world.spawn_actor(camera_depth_bp, transform, attach_to = model3)
camera_semantic_segmentation = world.spawn_actor(camera_semantic_segmentation_bp, transform, attach_to = model3)
lidar_ray_cast = world.spawn_actor(lidar_ray_cast_bp, transform, attach_to = model3)