温度网格#

TemperatureGrid 传感器在一个刚体连杆上叠加三维体素网格,并以摄氏度报告每个单元的温度。Genesis World 把连杆的局部包围盒离散为 (nx, ny, nz) 网格,并根据接触传导、辐射、对流以及可选的逐单元生热来演化每个单元的温度。可以用它观察表面在被其他物体接触时如何升温或降温。

完整脚本见 examples/sensors/temperature_grid.py,这是一个交互式场景:一个高温推杆和被投放的物体共同加热一块装有传感器的平台。

最小示例#

温度传感器挂载到刚体 实体 的一个连杆上。entity_idx 选择实体,link_idx_local 选择其中的连杆;grid_size 以 (nx, ny, nz) 设置分辨率。

temperature_sensor = scene.add_sensor(
    gs.sensors.TemperatureGrid(
        entity_idx=platform.idx,
        link_idx_local=0,
        grid_size=(10, 10, 1),  # (nx, ny, nz) voxels over the link's local bounding box
        properties_dict=properties_dict,
        ambient_temperature=22.0,  # degC
        convection_coefficient=0.0,  # W/(m2*K); 0.0 disables surface cooling
        draw_debug=True,
        debug_temperature_range=(0.0, 80.0),  # degC mapped to the blue->red debug colors
    )
)

scene.build()

场景构建完成后,read() 返回当前温度场:

data = temperature_sensor.read()  # shape ([n_envs,] nx, ny, nz), in degC
t_min, t_max = float(data.min()), float(data.max())

只有当场景在构建时包含多个 环境 才会出现 [n_envs,] 轴;单环境场景返回普通的 (nx, ny, nz) 张量。

材质属性#

热量只在带有热学属性的连杆之间流动。通过 properties_dict 提供这些属性,它把全局刚体连杆索引映射到 TemperatureProperties 条目。键 -1 是应用于所有未显式列出连杆的默认值;若省略它,与未列出连杆之间的接触就完全不传热。

properties_dict = {
    -1: gs.sensors.TemperatureProperties(  # default for unlisted links
        base_temperature=-40.0,
        conductivity=200.0,
        density=2000.0,
        specific_heat=1.0,
        emissivity=0.85,
    ),
    platform.base_link_idx: gs.sensors.TemperatureProperties(
        base_temperature=22.0,  # room temperature
        conductivity=100.0,
        density=1000.0,
        specific_heat=0.2,
        emissivity=0.4,
    ),
    pusher.base_link_idx: gs.sensors.TemperatureProperties(
        base_temperature=200.0,  # hot
        conductivity=1000.0,
        density=2000.0,
        specific_heat=1.0,
        emissivity=0.8,
    ),
}

每个字段都有固定的单位:

字段

含义

单位

base_temperature

材质的基准温度

°C

conductivity

导热系数

W/(m·K)

density

质量密度

kg/m³

specific_heat

比热容

J/(kg·K)

emissivity

辐射发射率,0–1

—

properties_dict、ambient_temperature 和 convection_coefficient 在场景中所有温度传感器之间共享:Genesis World 会合并这些字典,最后设置的环境温度和对流值生效。

行为与保证#

  • 坐标系与布局。 网格位于连杆的局部坐标系中并覆盖其包围盒,因此随连杆一起平移和旋转。单元 (0, 0, 0) 是包围盒的一个角;grid_size=(10, 10, 1) 是单层 10×10 的薄片,适合像上面平台那样的平面表面。

  • 单位。 所有温度在输入(base_temperature、ambient_temperature)和输出(read())时均使用摄氏度。ambient_temperature 默认为 21 °C。

  • 对流。 convection_coefficient 是表面冷却系数 h,单位为 W/(m²·K),默认为 1.0。将其设为 0.0 可关闭对流冷却,示例即如此。

  • 未列出的连杆。 当 simulate_all_link_temperatures=False(默认值)时,除传感器自身连杆外的每个连杆都保持绝热,停留在其 base_temperature,不交换热量。将其设为 True 可演化所有具备热学属性的连杆温度;此时逐连杆的数值可在 link_temperatures 属性上获取。

  • 生热。 传入 heat_generation(与 grid_size 匹配的逐单元数组,单位 W/m²)可向特定单元注入热量,例如为模拟嵌入连杆中的加热元件。

Tip

draw_debug=True 会在查看器中按 debug_temperature_range(°C)的映射把每个单元从蓝色(冷)着色到红色(热)。它只是可视化辅助手段,不影响 read() 返回的数值。

另见#

  • 传感器:传感器流水线、批量读取和历史。

  • 记录数据:在仿真过程中一并保存传感器数据。