任务配置
task 块以声明式方式定义一段完整的任务流程——由一系列 动作(action) 顺序执行,最终由一组 目标条件(goal) 验收。TaskManager 在运行时将配置转换为可执行的 Task 实例。
源码:fastsim/task/task_cfg.py(TaskConfig)、fastsim/task/task.py(Task)
执行语义
text
Task.run()
│
├─ for action in actions:
│ action.act() ← 执行动作
│ [可选] action.goal.is_satisfied() ← 动作后检查内置目标
│
└─ for goal in goals:
goal.is_satisfied() ← 最终验收
所有 actions 按列表顺序依次执行。每个 action 可选地携带一个 goal_config,在该 action 执行后立即校验;task.goals 是在所有 actions 完成后执行的最终验收条件。
TaskConfig 字段
| 字段 | 类型 | 说明 |
|---|---|---|
name | str | 任务名称 |
description | str | 任务描述 |
actions | list[ActionConfig] | 动作列表,顺序执行 |
goals | list[GoalConfig] | 最终目标列表,全部满足才算任务成功 |
ActionConfig 字段
每个 action 通过 stereotype 确定具体的行为类型(如 pick、place、move),由 ActionController.execute_action() 实例化并执行。
源码:fastsim/extensions/common/action/action.py
| 字段 | 类型 | 说明 |
|---|---|---|
stereotype | str | 动作类型(如 pick / place / move / grasp) |
name | str | 动作名称 |
description | str | 动作描述 |
robot_name | str | 执行该动作的机器人实例名 |
goal_config | GoalConfig | 动作执行后的即时校验目标(可选) |
visualization_config | VisualizationConfig | 可视化开关(规划路径、末端位姿等) |
wait_robot_stopped | bool | 执行前是否等待机器人静止 |
wait_robot_stopped_timeout | float | 等待超时时间(秒) |
extra_parameters | dict | 具体 stereotype 的扩展参数(由各 Action 子类解释) |
GoalConfig 字段
GoalConfig 同样通过 stereotype 确定条件类型,例如 pose(末端位姿到达)、on_top(物体叠放)、inside(物体在容器内)。
源码:fastsim/extensions/common/goal/goal.py
| 字段 | 类型 | 说明 |
|---|---|---|
stereotype | str | 目标条件类型(如 pose / on_top / inside) |
name | str | 目标名称 |
description | str | 目标描述 |
extra_parameters | dict | 具体 stereotype 的扩展参数 |
配置示例
yaml
task:
name: pick_and_place
description: Pick the red cube and place it on the tray
actions:
- stereotype: pick
name: pick_cube
description: Pick up the red cube
robot_name: arm
wait_robot_stopped: true
wait_robot_stopped_timeout: 5.0
extra_parameters:
object_name: cube
goal_config:
stereotype: grasp_success
name: grasp_check
description: Verify cube is grasped
extra_parameters: {}
visualization_config:
enable_ee_pose_visualization: false
enable_planner_robot_representation_visualization: true
enable_planner_world_representation_visualization: true
enable_target_bounding_box_visualization: true
ee_pose_type: coordinate
- stereotype: place
name: place_cube_on_tray
description: Place the cube onto the tray
robot_name: arm
wait_robot_stopped: false
wait_robot_stopped_timeout: 3.0
extra_parameters:
target_name: tray
visualization_config:
enable_ee_pose_visualization: false
enable_planner_robot_representation_visualization: false
enable_planner_world_representation_visualization: false
enable_target_bounding_box_visualization: false
ee_pose_type: coordinate
goals:
- stereotype: on_top
name: cube_on_tray
description: The cube is placed on the tray
extra_parameters:
object_name: cube
target_name: tray
tolerance: 0.02