Files
ParkingRobot/docs/superpowers/prompts/2026-08-05-em-longitudinal-rolling-phase-1.md
T

236 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 新窗口执行提示词:EM 纵向滚动规划阶段一
请在一个新的 Codex 窗口中完整粘贴本文件内容,或明确要求 Codex 读取并执行本文件。
---
你现在要在仓库 `D:\Users\Desktop\项目\prakrobot\ParkingRobot` 中执行 EM 纵向滚动轨迹规划修复的**阶段一:纵向基础与窗口语义**。
这是一项代码实施任务,不是重新讨论方案。设计已经确认。本窗口只能完成阶段一,对应原十任务计划中的 Task 1 和 Task 2;完成阶段验收、交接文件和阶段二提示词后必须停止,不得继续实现 Task 3。
## 必须使用的工作方法
1. 首先使用 `executing-plans` skill 执行现有计划。
2. 实现每个 bugfix/feature 时使用 `test-driven-development`:先写失败测试、运行确认失败原因正确,再做最小实现、重新运行确认通过。
3. 遇到非预期编译错误、测试失败或行为不一致时,先使用 `systematic-debugging` 查明根因,不得盲目放宽阈值。
4. 声称阶段完成前必须使用 `verification-before-completion`,重新运行全部阶段验收命令。
5. 不需要重新 brainstorming;已经批准的设计规格是行为依据。
## 必读文件
开始实施前完整阅读:
- `docs/superpowers/specs/2026-08-05-em-longitudinal-rolling-planning-design.md`
- `docs/superpowers/plans/2026-08-05-em-longitudinal-rolling-planning.md`
- `docs/superpowers/plans/2026-08-05-em-longitudinal-rolling-four-phase-roadmap.md`
在十任务计划中,本窗口只能执行:
- Task 1:完整 jerk 受限停车数学
- Task 2:纵向模式、空间窗口和输入契约
计划中的代码片段是实施基线,但在应用前必须与当前仓库接口核对;若代码已发生变化,应做保持设计语义的最小适配,并在交接文件中记录差异。
## 开始前基线检查
依次执行并记录结果:
```powershell
git branch --show-current
git status --short
git log -8 --oneline
git show --stat --oneline e0ccc0c
git show --stat --oneline e608299
```
预期当前分支为 `trajplanner`,并且至少能找到:
- `e0ccc0c docs: plan EM longitudinal rolling implementation`
- `e608299 docs: require stabilized EM stop terminals`
仓库当前存在大量与本任务无关的用户修改。必须遵守:
- 不运行 `git reset --hard``git checkout -- .``git clean` 或任何等价清理命令。
- 不回退、不格式化、不移动与阶段一无关的文件。
- 不使用 `git add .``git add -A`
- 提交前使用 `git diff --cached --name-only` 核对暂存区。
- 如果阶段一目标文件本身已有未提交修改,先检查并保留用户内容,在其基础上最小集成;不能直接覆盖。
## 不可改变的行为语义
- `DistanceHorizonMeters` 只决定 LS 可以查看的空间长度。
- `TimeHorizonSeconds` 只决定一次 ST 优化的未来时间范围。
- 局部空间窗口末端不是停车点。
- 只有真实 `Goal``GearSwitchApproach` 才是停车边界。
- 纵向模式必须显式区分:
- `RollingContinuation`
- `ApproachStopBoundary`
- `ExactStopAtBoundary`
- 精确停车最终要支持在 QP 内达到 `S=S_end、U=0、A=0`,并至少保留一个完整 `OutputTimeStepSeconds` 的静止稳定区间。
- `ZeroSpeedHoldSeconds` 是 QP 时间范围之后的发布保持段,不能从 `TimeHorizonSeconds` 中扣除。
- 不得通过放宽 jerk、加速度、求解残差或轨迹验证阈值规避问题。
- 保持 `OBSERVE_ONLY`;不得增加任何底盘控制下发。
## Task 1:完整 jerk 受限停车数学
严格按照十任务计划 Task 1 的 TDD 步骤实施。
### 文件范围
- 新建:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/JerkLimitedStoppingMath.cs`
- 修改:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/PathSpeedLimitBuilder.cs`
- 测试:`ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalModelChecks.cs`
### 必须产生的接口
- `JerkLimitedStoppingMath.TryCalculate(double, double, double, double, out JerkLimitedStoppingProfile, out string)`
- `JerkLimitedStoppingMath.MaximumInitialSpeedForDistance(double, double, double, double, double)`
- `JerkLimitedStoppingMath.CalculateMaximumStoppedDistance(double, double, double, double, double, double, double)`
- `JerkLimitedStoppingProfile`,至少表达停车距离、持续时间、末速度和末加速度。
停车数学必须使用与 ST QP 一致的恒 jerk 离散/分段动力学,能够覆盖初始正加速度、初始负加速度、三角形和梯形减速度轮廓,最终同时释放到零速度和零加速度。
### 红灯和绿灯命令
```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-model
```
先证明新增测试因缺少新能力而失败;实现后必须得到 `PASS longitudinal-model`
### Task 1 提交
只暂存 Task 1 文件,核对暂存区后提交:
```powershell
git add -- ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/JerkLimitedStoppingMath.cs ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/PathSpeedLimitBuilder.cs ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalModelChecks.cs
git diff --cached --name-only
git commit -m "feat: add complete jerk-limited stopping math"
```
## Task 2:纵向模式、空间窗口和输入契约
Task 1 提交并通过测试后,严格按照十任务计划 Task 2 的 TDD 步骤实施。
### 文件范围
- 新建:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Contracts/EmLongitudinalMode.cs`
- 新建:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalTerminalSchedule.cs`
- 修改:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Segmentation/PlanningHorizonSelector.cs`
- 修改:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalPlanningInput.cs`
- 修改:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Validation/EmPlanningRequestValidator.cs`
- 修改:`ClumsyPilot/ParkrobTrajplanner/EMPlanner/Facade/EmPlanningService.cs`
- 测试:`ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalModelChecks.cs`
- 测试:`ClumsyPilot/tests/EMPlannerVerificationHost/FoundationChecks.cs`
### 必须产生的接口和行为
- `EmLongitudinalMode` 三种模式。
- `LongitudinalTerminalSchedule.GetStabilizationStartIndex(IReadOnlyList<double>, double)`
- `PlanningHorizonSelection` 显式保存:
- `WindowEndReferenceS`
- `WindowEndBoundaryType`
- `LongitudinalMode`
- `StopBoundaryReferenceS`
- `HasStopBoundary`
- `LongitudinalPlanningInput` 分离路径上界、真实停车边界和纵向模式。
- 选择顺序必须是:
1. 识别当前方向段的真实边界;
2. 用 Task 1 的完整 jerk 模型检查最小停车距离;
3. 只用 `DistanceHorizonMeters` 截取 LS 空间窗口;
4. 真实边界不在窗口内时选择 `RollingContinuation`
5. 边界已在窗口内但本次时间范围无法形成稳定停车时选择 `ApproachStopBoundary`
6. 能在时间范围内停车并留出内部稳定区间时选择 `ExactStopAtBoundary`
- `EmPlanningRequestValidator` 必须检查前视停车余量、时间步、时间范围和内部稳定区间组合,不允许无效配置进入求解器。
### 红灯和绿灯命令
```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-model
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- foundation
```
先证明模式/属性/行为测试失败;实现并更新所有直接构造调用后,必须得到:
```text
PASS foundation
PASS longitudinal-model
```
### Task 2 提交
只暂存 Task 2 文件,核对暂存区后提交:
```powershell
git add -- ClumsyPilot/ParkrobTrajplanner/EMPlanner/Contracts/EmLongitudinalMode.cs ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalTerminalSchedule.cs ClumsyPilot/ParkrobTrajplanner/EMPlanner/Segmentation/PlanningHorizonSelector.cs ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalPlanningInput.cs ClumsyPilot/ParkrobTrajplanner/EMPlanner/Validation/EmPlanningRequestValidator.cs ClumsyPilot/ParkrobTrajplanner/EMPlanner/Facade/EmPlanningService.cs ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalModelChecks.cs ClumsyPilot/tests/EMPlannerVerificationHost/FoundationChecks.cs
git diff --cached --name-only
git commit -m "feat: separate rolling horizons from stop boundaries"
```
若为修复编译必须改动直接调用者,使用明确路径单独加入,并在提交前解释原因;仍然禁止把其他脏文件带入提交。
## 阶段一最终验收
Task 1 和 Task 2 完成后,从当前代码状态重新运行,不得引用之前的测试输出:
```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- foundation
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-model
git diff --check
git log -5 --oneline
git status --short
```
验收时同时人工确认:
- 普通 5 m 局部窗口不会因为 `TimeHorizonSeconds=2s` 而被解释为必须在两秒内走完 5 m。
- Rolling 局部窗口末端不再具有“停车边界”身份。
- Goal/GearSwitch 边界进入窗口但暂时无法稳定停车时是 `ApproachStopBoundary`,不是失败,也不是强制零速。
- 精确停车模式为至少一个 QP 内部静止时间步保留了明确的调度信息。
## 阶段结束交接——必须执行
验收通过后使用 `writing-plans`,根据**实际提交和实际接口**完成以下两份文件:
1. 阶段一交接:
`docs/superpowers/handoffs/2026-08-05-em-longitudinal-rolling-phase-1.md`
2. 阶段二精细提示词:
`docs/superpowers/prompts/2026-08-05-em-longitudinal-rolling-phase-2.md`
阶段一交接必须包含:
- 开始基线提交和结束提交;
- Task 1、Task 2 各自的提交号;
- 实际修改/新增文件;
- 最终接口签名和与原计划不同之处;
- 全部验证命令、退出码和关键 PASS 输出;
- 遗留问题、未验证内容和目标机限制;
- 阶段二可依赖的明确事实。
阶段二提示词必须:
- 引用阶段一真实提交号和交接文件;
- 只覆盖原计划 Task 35
- 明确速度包络、QP 条件终端约束、解验证、初始解和外层迭代的文件范围;
- 要求 TDD,并列出 `longitudinal-model``longitudinal-integration` 验收命令;
- 保留 Task 3、Task 4、Task 5 的独立提交边界;
- 要求阶段二结束后生成阶段二交接和阶段三提示词;
- 重复工作树保护、全局行为语义和 `OBSERVE_ONLY` 限制。
只暂存这两份交接文档,并提交:
```powershell
git add -- docs/superpowers/handoffs/2026-08-05-em-longitudinal-rolling-phase-1.md docs/superpowers/prompts/2026-08-05-em-longitudinal-rolling-phase-2.md
git diff --cached --name-only
git commit -m "docs: hand off EM rolling planning phase one"
```
提交后输出一个简短阶段报告,包含两个功能提交、交接提交和两项验收结果,然后**立即停止**。不要开始 Task 3,也不要在本窗口实施阶段二。
---
以上内容是本窗口的完整授权范围。