CARLA——Art improvements: environment and rendering


Art Improvements: environment and rendering.pptx - Google 云端硬盘

笔者对部分自己关注的内容进行了摘抄以及验证

Lighting & Weather

Environment.py

--altitude X [-90 to 90]  海拔高度

--azimuth X [0 to 360]  方位角;地平经度

--clouds X [0 to 100]    云

--rain X [0 to 100]      雨

--wetness X [0 to 100]    湿度

--puddles X [0 to 100]  水坑

--wind X [0 to 100]     风

--fog X [0 to 100]     雾

--weather X [clear | overcast | rain]  天气 [晴 | 阴 | 雨]

--sun X [day | sunset | night]       太阳 [白天 | 日落 | 夜晚]

--lightgroup X [Builging | Street | Other]    光组 [建筑 | 街 | 其他]

--lights X [on/off | intensity X | color (RGB)]    光 [开/关 | 强度X | 颜色(RGB)]

--cars X [Position | LowBeam | HighBeam | Blinkers | Brake | Fog | Interior | Reverse | Special1 | Special2]  车 [位置 | 近光灯 | 远光灯 | 闪光灯 | 刹车 | 雾 | 车内 | 倒车 | 特殊1 | 特殊2]

Lights

Vehicle lights

  车辆灯光表示为位掩码,其中每个位表示车辆灯光。carla.VehicleLightState是每个位的别名。这些是汽车上可用的灯的设置,但特殊1和2除外,它们是为特定车辆上的特定灯保留的位,例如警笛,并且不是所有的汽车都有它们。

  可以使用carla.Vehicle.get_light_state和carla.Vehicle.set_light_state方法随时检索和更新车辆的灯光。它们使用二值操作来自定义灯光设置。

  它的工作方式是,首先,让你想要打开的灯。在本例中,我们选择位置和近光灯,然后设置新的灯光状态。那些你没有设置的将被关闭。

vehicle_light_state = carla.VehicleLightState(          # Prepare lights to set
      carla.VehicleLightState.Position | carla.VehicleLightState.LowBeam)         
vehicle.set_light_state(vehicle_light_state)            # Set the new light state

  到目前为止,并不是所有车辆都集成了车灯。以下是在撰写本文时可用的列表。

  • 自行车。它们都有前后位置灯。
  • 摩托车。雅马哈和哈雷戴维森车型。
  • 汽车。奥迪TT、雪佛兰、道奇(警车)、埃顿、林肯、野马、特斯拉3S、沃尔克斯瓦根T2和新来CARLA的车型。

  carla.LightManager是负责控制场景中除车辆灯光外所有灯光的类。

  这个类提供了访问carla.Light和carla.LightGroups的权限。首先,carla.Light是为从场景中获取每个灯光而创建的类。每个都有唯一的id和位置。所以我们可以找到一盏灯,然后设置carla.LightState

  对于每个灯光,都有一些特定的变量可以单独设置。然而,carla.LightState总结了所有这些,这是在一次调用中更改所有属性的最佳方式。

  • color (carla.color):灯光的颜色。
  • id (int):灯光的标识符。
  • intensity (float):以流明为单位的光强度。
  • is_on (bool):灯的转换。当灯亮的时候是真的。当夜间模式启动时,设置为True。
  • location (carla.Location):灯的位置。
  • light_group (carla.LightGroup):灯所属的组。
  • light_state (carla.LightState):灯的状态。总结其属性、组以及是否打开/关闭。

  此类将场景中的灯光分类为不同的组。这些可用组作为枚举值提供,可用作标志。

Note. 到目前为止,虽然有一个vehicle组,但车灯还不能作为carla.Light目标提供。这些必须使用carla.Vehicle和carla.VehicleLightState进行管理。

Turn on/off all the lights

lm = client.get_world().get_lightmanager()   # Get the Light Manager
lights = lm.get_all_lights()                 # Get all the lights of the level
lm.turn_on(lights)
# or
lm.turn_off(lights)

Change the color of a specific group of lights

lm = client.get_world().get_lightmanager()             # Get the Light Manager
lights = lm.get_all_lights(carla.LightGroup.Street)    # Get all the lights in the
                                                       # Street Light Group
lm.set_color(lights, carla.Color(160, 100, 50))        # Set the same color to all the lights 

Change the intensity of a specific light

lm = client.get_world().get_lightmanager()           # Get the Light Manager
lights = lm.get_all_lights()                         # Get all the lights of the level
light = [ x for x in lights if x.id == 9946 ][0]   # Look for the desired id
light.set_intensity(1000.0)                          # Set the intensity to a specific light

Change the LightGroup of a specific group of lights

lm = client.get_world().get_lightmanager()                 # Get the Light Manager
lights = lm.get_all_lights()                               # Get all the lights of the level
lights = [ x for x in lights if x.id >= 1000 and x.id <= 2000 ]   # Filter by id
lm.set_light_group(lights, carla.LightGroup.Other)         # Set the group to the lights

Other interesting functions

# Return the lights turned on in a group
lm.get_turned_on_lights(carla.LightGroup.Street)


# Change all the attributes of a light at once
light.set_light_state(carla.LightState(intensity = 1000.0, active = True, color(160, 100, 50)))


# Specify different values of the same attribute for different lights at once
lm.set_intensities([light1, light2, light3], [1000.0, 2000.0, 1500.0])
# Same as
light1.set_intensity(1000.0)
light2.set_intensity(2000.0)
light3.set_intensity(1500.0)

FUTURE WORK

  • 将车灯与LightManager集成
  • 从Python创建自定义LightGroups
  • 新版本Unreal 4.24的天空氛围
  • Unreal 4.26的体积云
  • Unreal 5的动态全局照明
  • 实时光线跟踪(Real time Ray-tracing, RTX)
  • 真实的行人

相关