场景配置
scene 块以声明式方式描述仿真世界的组成——你写明有哪些实体、它们的类型和参数,SceneManager 在运行时负责实例化并将其注入仿真器。
源码:fastsim/configs/scene_cfg.py(SceneConfig)
顶层结构
| 字段 | 类型 | 说明 |
|---|---|---|
name | str | 场景名称 |
position | list[3] | 场景基准位置 [x, y, z] |
rotation | list[4] | 场景基准旋转,四元数 [w, x, y, z](须归一化) |
base_config | BaseConfig | 地基/环境配置(可选) |
object_cfg_dict | dict[str, ObjectConfig] | 物体配置字典,key 为实例名 |
robot_cfg_dict | dict[str, RobotConfig] | 机器人配置字典 |
sensor_cfg_dict | dict[str, SensorConfig] | 传感器配置字典 |
light_cfg_dict | dict[str, LightConfig] | 光源配置字典 |
除 base_config 外,其余四类均为字典,key 就是实体的唯一名称,运行时通过该名称访问实体(如 SceneManager.get_robot("arm"))。
Stereotype 映射
每类实体通过 stereotype 字段绑定到具体的配置类与运行时模型类(源码:fastsim/annotations/stereotype.py):
| 实体类型 | 常用 stereotype |
|---|---|
| Base | ground_plane / usd / empty |
| Object | rigid / articulated / soft |
| Robot | general_robot / single_gripper_arm_robot |
| Sensor | camera |
| Light | general_light |
实体配置详解
Base:地基与环境
每个场景只有一个 Base,定义物理地面或加载复杂环境。
| Stereotype | 关键字段 | 说明 |
|---|---|---|
ground_plane | ground_plane_size | 无限延伸平面地基 |
usd | asset_path | 从 USD 文件加载环境(房间、工厂等) |
empty | — | 无地基,适合自定义物理场景 |
Object:场景物体
| Stereotype | 关键字段 | 说明 |
|---|---|---|
rigid | mass, density, enable_gravity, asset_path | 刚体,支持 primitive 几何体(use_primitive: true) |
articulated | asset_path | 关节体(Articulation) |
soft | soft_body_type, youngs_modulus, poissons_ratio | 柔性体/可变形体(布料、体积柔体、充气体) |
Robot:机器人
所有 robot stereotype 通用字段:
| 字段 | 说明 |
|---|---|
asset_path | 机器人 USD 资产路径 |
ee_link_name | 末端执行器 link 名称 |
ik_joint_names | 参与 IK 计算的关节子集(不设则使用全部关节) |
use_planner | 是否挂载运动规划器(Curobo 等) |
planner_cfg | 规划器详细配置 |
single_gripper_arm_robot 额外字段:
| 字段 | 说明 |
|---|---|
arm_actuator_name | 机械臂 actuator group 名称 |
gripper_actuator_name | 夹爪 actuator group 名称 |
Sensor:传感器
| 字段 | 说明 |
|---|---|
data_types | 采集类型,如 [rgb, depth, semantic_segmentation] |
width / height | 图像分辨率 |
clip_range | 深度裁剪范围 [near, far](米) |
attach_to | 挂载到指定实体(机器人名称或 link 名称) |
look_at | 相机朝向目标点或目标实体 |
convention | 坐标系约定:world / opengl / ros |
Light:光源
| 字段 | 说明 |
|---|---|
light_type | distant(平行光)/ sphere(点光源)/ disk(面光源) |
intensity | 光照强度 |
color | 颜色 [r, g, b],范围 0–1 |
temperature | 色温(K),与 color 互斥 |
配置示例
yaml
scene:
name: pick_and_place_scene
position: [0.0, 0.0, 0.0]
rotation: [1.0, 0.0, 0.0, 0.0]
base_config:
stereotype: ground_plane
name: base
position: [0.0, 0.0, 0.0]
rotation: [1.0, 0.0, 0.0, 0.0]
ground_plane_size: [10.0, 10.0]
robot_cfg_dict:
arm:
stereotype: single_gripper_arm_robot
asset_path: assets://robots/ur5_with_gripper.usd
ee_link_name: tool0
use_planner: true
arm_actuator_name: arm
gripper_actuator_name: gripper
object_cfg_dict:
cube:
stereotype: rigid
asset_path: assets://objects/cube_red.usd
mass: 0.2
enable_gravity: true
sensor_cfg_dict:
wrist_cam:
stereotype: camera
width: 640
height: 480
data_types: [rgb, depth]
attach_to: arm
convention: ros
light_cfg_dict:
main_light:
stereotype: general_light
light_type: distant
intensity: 3000
color: [1.0, 1.0, 1.0]
资产路径
实体配置中的 asset_path 使用 root_key:// 协议,由 general.root_paths 统一解析。详见全局配置 - 资产路径解析。