also looking at this
feat: add bounded VTOL wind braking
#88
13 files
+447
-25
| @@ -176,7 +176,12 @@ test('an early resume and repeated recovery cannot skip observed hover or extend | ||
| 176 | 176 | expect(new Set(requests.map(request => request.eventId)).size).toBe(1) |
| 177 | 177 | expect(requests.every(request => request.issuedAtMs === 13000 && request.expiresAtMs === 58000)).toBe(true) |
| 178 | 178 | expect(report.path.find(row => row.atMs === 13200)!.mission.state).toBe('running') |
| 179 | expect(report.path.find(row => row.atMs === 20000)!.mission.state).toBe('paused') | |
| 179 | const observedHover = report.trace.rows.find(row => row.observation.transition?.taskId === 'recover-hover' && row.observation.transition.outcome === 'confirmed') | |
| 180 | expect(observedHover).toBeDefined() | |
| 181 | expect(observedHover!.observation.nowMs).toBeGreaterThan(13400) | |
| 182 | expect(observedHover!.observation.nowMs).toBeLessThan(40000) | |
| 183 | expect(observedHover!.result.state).toBe('paused') | |
| 184 | expect(report.path.filter(row => row.atMs >= 13200 && row.atMs < observedHover!.observation.nowMs).every(row => row.mission.state === 'running' && row.mission.taskId === 'recover-hover')).toBe(true) | |
| 180 | 185 | expect(report.path.find(row => row.atMs === 39980)!.mission.state).toBe('paused') |
| 181 | 186 | expect(report.mission.reason).toBe('vtol-recovery-landed') |
| 182 | 187 | expect(replayVehicleMission(report.trace).snapshot()).toEqual(report.mission) |
| @@ -193,7 +198,11 @@ for (const abortAtMs of [15000, 20000]) test(`an abort at ${abortAtMs} upgrades | ||
| 193 | 198 | expect(replayVehicleMission(report.trace).snapshot()).toEqual(report.mission) |
| 194 | 199 | }) |
| 195 | 200 | |
| 196 | for (const [sourceTask, atMs] of [['initial-hover', 620], ['front', 11320], ['back', 27400]] as const) test(`a ${sourceTask} abort before its first command dispatch does not invent a cancelled event`, () => { | |
| 201 | for (const sourceTask of ['initial-hover', 'front', 'back'] as const) test(`a ${sourceTask} abort before its first command dispatch does not invent a cancelled event`, () => { | |
| 202 | const baseline = runVehicleSimulation(declaredRecovery(sourceTask), { seconds: 160 }) | |
| 203 | const firstRequest = baseline.path.find(row => row.mission.transition?.taskId === sourceTask) | |
| 204 | expect(firstRequest).toBeDefined() | |
| 205 | const atMs = firstRequest!.atMs | |
| 197 | 206 | const report = runVehicleSimulation(declaredRecovery(sourceTask), { seconds: 180, missionActions: [{ atMs, action: 'abort' }] }) |
| 198 | 207 | expect(report.mission.reason).toBe('vtol-abort-landed') |
| 199 | 208 | expect(report.mission.recovery?.failedEventId).toBeNull() |
| @@ -235,7 +244,7 @@ test('a declared front-transition failure route cancels failed wing support, obs | ||
| 235 | 244 | expect(replayVehicleMission(report.trace).snapshot()).toEqual(report.mission) |
| 236 | 245 | }) |
| 237 | 246 | |
| 238 | for (const landingTimeoutMs of [25000, 35000]) test(`back-transition recovery retains the declared ${landingTimeoutMs} ms approach and landing budget`, () => { | |
| 247 | for (const [landingTimeoutMs, worstCaseMs, requiredWh] of [[20000, 141520, 47.17333333333333], [25000, 146520, 48.84], [35000, 156520, 52.17333333333333]] as const) test(`back-transition recovery retains the declared ${landingTimeoutMs} ms approach and landing budget`, () => { | |
| 239 | 248 | const profile = declaredRecovery('back'), back = profile.mission.tasks.find(task => task.id === 'back')! |
| 240 | 249 | if (back.kind !== 'vtol-mode') throw new Error('Expected a VTOL mode task') |
| 241 | 250 | back.timeoutMs = 15000 |
| @@ -244,18 +253,22 @@ for (const landingTimeoutMs of [25000, 35000]) test(`back-transition recovery re | ||
| 244 | 253 | hover.timeoutMs = 45000; land.timeoutMs = landingTimeoutMs |
| 245 | 254 | const report = runVehicleSimulation(profile, { seconds: 160 }) |
| 246 | 255 | console.log('VTOL_BACK_TIMEOUT_RECOVERY', JSON.stringify({ landingTimeoutMs, status: report.status, fault: report.fault, mission: report.mission, budget: report.budget, finalPositionM: report.finalTruthPositionM, transitions: report.transitions })) |
| 247 | if (landingTimeoutMs === 25000) { | |
| 256 | expect(report.budget.worstCaseMs).toBe(worstCaseMs) | |
| 257 | expect(report.budget.requiredWh).toBeCloseTo(requiredWh, 8) | |
| 258 | const landingStart = report.transitions.find(row => row.taskId === 'recover-land' && row.state === 'running')!.atMs | |
| 259 | if (landingTimeoutMs === 20000) { | |
| 248 | 260 | expect(report.status).toBe('blocked') |
| 249 | 261 | expect(report.mission.reason).toBe('task-timeout') |
| 250 | 262 | expect(report.path.at(-1)!.measurement!.values.onSurface).toBe(false) |
| 251 | 263 | expect(report.finalTruthPositionM[2]).toBeLessThan(-1) |
| 252 | 264 | expect(report.board.actuators).toEqual([0, 0, 0, 0, 0, 0, 0, 0]) |
| 265 | expect(report.board.expiresAtMs).toBeNull() | |
| 266 | expect(report.path.at(-1)!.atMs - landingStart).toBe(landingTimeoutMs) | |
| 253 | 267 | expect(replayVehicleMission(report.trace).snapshot()).toEqual(report.mission) |
| 254 | 268 | return |
| 255 | 269 | } |
| 256 | 270 | expect(report.status).toBe('completed') |
| 257 | expect(report.budget.worstCaseMs).toBe(156520) | |
| 258 | expect(report.budget.requiredWh).toBeCloseTo(52.17333333333333, 8) | |
| 271 | expect(report.path.at(-1)!.atMs - landingStart).toBeLessThan(landingTimeoutMs) | |
| 259 | 272 | expect(report.mission.reason).toBe('vtol-recovery-landed') |
| 260 | 273 | expect(report.mission.recovery).toMatchObject({ failedTaskId: 'back', hoverTaskId: 'recover-hover', cause: 'timeout' }) |
| 261 | 274 | const original = report.path.find(row => row.mission.taskId === 'back' && row.mission.transition)!.mission.transition! |