流场规划
概述 / Overview
流场规划(Flow-field planning)是 DPS 之外的另一种调度内核选项。它把仓库 / 工厂的地面预计算为一个 矢量场(每格指向"应该走的方向"),车辆按场行驶。流场对 车辆数极多 / 任务动态高的场景有显著优势 —— 不需要为每辆车单独跑 A*。
Flow-field planning is an alternative scheduling-kernel option to DPS. The warehouse / factory floor is pre-computed as a vector field (each cell points the way to go); vehicles simply follow the field. Flow-field is advantageous for very large fleets / very dynamic tasks — no per-car A* required.
适用场景 / When to use
| 项 / Item | DPS | 流场 / Flow-field |
|---|---|---|
| 车队规模 / Fleet size | ≤ ~30 | 30 – 数千 / 30 – thousands |
| 任务动态性 / Task dynamics | 中等 | 极高(每秒大量任务) |
| 死锁保证 / Deadlock-free | 是 / Yes (algorithmic) | 经验性,需调(empirical) |
| 通道宽度 / Lane width | 单车通过即可 | ≥ 2 车并行 |
| 离线计算 / Offline cost | 低 / Low | 高(重映射地图需要重算流场) |
| 路径最优性 / Path optimality | 全局最优 | 接近最优(流场近似) |
典型用例:电商物流仓(一日万级任务、数百 KIVA 车);不适合:单线性产线(车数 < 10)、复杂场景多车型混跑(建议 DPS)。
Typical use: e-commerce sortation warehouses (tens of thousands of tasks/day, hundreds of KIVAs). Not for: small linear production lines (DPS is simpler), heavily mixed-vehicle complex layouts.
算法原理 / Algorithm overview
离线 / Offline
- 把地面离散为格点(典型 100 × 100 mm)。
- 对每个 目标站点 T,求解到 T 的距离场(Dijkstra / 平面波传播)。
- 每个格的 流向= 距离场负梯度方向。
- 多种 场层可叠加:单车流场、紧急通道流场、双向回路流场。
在线 / Online
- 车收到任务(目标站点 T)→ 选 T 对应的流场层。
- 车每个 tick 查当前位置所在格的 流向 + 速度上限,作为局部目标。
- 实时局部避让在 Clumsy 绕障行走 中处理。
- 当场内多车密集时,启用 拥挤检测: 车队主动减速或绕到旁路流场层。
死锁与无死锁 / Deadlock & no-deadlock
流场本身 不能算法上保证无死锁。MDCS 通过两个补丁来规避:
- 拥挤检测 + 调速: 一个区域车辆密度超过阈值后,进入流量限制。
- DPS 兜底: 在 关键路口 / 工位口仍用 DPS 锁,保证局部无死锁。
The flow field itself does not algorithmically prevent deadlock. MDCS uses two patches:
- Density-triggered congestion detection + rate limiting.
- DPS fallback on critical intersections and station mouths.
数据结构 / Data structures
public class FlowFieldLayer
{
public int Id;
public int TargetSiteId;
public byte[,] FlowDir; // 每格存方向编码 0..7(8 个邻居方向) / 8-way direction encoding
public ushort[,] SpeedCap; // mm/s
public float[,] Distance; // 距离场(用于优先级 / 比较)
public bool[,] Reserved; // 为应急通道保留?
}
存储格式:二进制紧凑布局(每格 ≤ 8 字节);100 m × 100 m 工地约 80 MB / 流场。 Storage: binary-packed (≤ 8 bytes / cell); ~80 MB / flow-field for a 100 × 100 m site.
在 MDCS 中启用 / Enabling in MDCS
- SimpleComposer 配置 → 调度内核 → 切换为"流场"。
- 必须先用 CAD 工具为每个目标站点跑离线流场生成。
- 启用后 DPS 仍在路口 / 工位口生效;车体行驶段交给流场。
与 DPS 的混合 / Hybrid with DPS
推荐配置(大规模仓储):
- 行驶段 = 流场(粗粒度引导)
- 路口段 = DPS(保证无死锁)
- 工位口 = DPS + 可达性状态(确保进出顺序)
Recommended hybrid (large warehouses):
- Traverse segments = flow-field (coarse guidance).
- Intersections = DPS (algorithmic deadlock-free).
- Station mouths = DPS + reachability state (ordering).
限制 / Caveats
- 地图变化(增删站点 / 路径)要 重新生成所有流场;典型 5–30 分钟离线。
- 流场对 朝向是无知的 —— 阿克曼车辆需用流场 + 曲率惩罚搜索局部可行路径。
- 多车型流场:每种车型一套(包络不同)。
- Map changes force a full off-line regeneration of every flow-field (5–30 min).
- Flow-fields are heading-agnostic — Ackermann vehicles need a local pass with curvature penalties.
- Per vehicle-type: one flow-field set each (different envelopes).