also looking at this
feat: add VTOL scenario playback to the mission workspace
#84
26 files
+1336
-66
| @@ -0,0 +1,22 @@ | ||
| 1 | import { defineCommand } from '@stacksjs/cli' | |
| 2 | import { print, printError } from '@stacksjs/cli/output' | |
| 3 | import { runVtolSimulation, vtolSimulationPhases, vtolSimulationScenarios } from '../../resources/functions/drone/vehicles/vtol/simulation' | |
| 4 | ||
| 5 | export default defineCommand({ | |
| 6 | name: 'vtol:simulate', | |
| 7 | description: 'Exercise the fictional owned front/cruise/back/landing route; no physical control', | |
| 8 | options: { | |
| 9 | '--scenario <name>': { description: vtolSimulationScenarios.join(', '), default: 'nominal' }, | |
| 10 | '--phase <name>': { description: `Fault injection phase: ${vtolSimulationPhases.join(', ')}; default front` }, | |
| 11 | '--seconds <n>': { description: 'Maximum virtual duration, 2..180 seconds; default 160, or 180 for recovery hold' }, | |
| 12 | '--electrical': { description: 'Use fictional electrical load and delayed battery measurements', default: false }, | |
| 13 | }, | |
| 14 | handle(options) { | |
| 15 | try { | |
| 16 | const report = runVtolSimulation(options.scenario, { seconds: options.seconds === undefined ? undefined : Number(options.seconds), electrical: options.electrical, phase: options.phase }) | |
| 17 | print(JSON.stringify(report, (_key, value) => typeof value === 'bigint' ? String(value) : value, 2)) | |
| 18 | if (!report.demonstrationMatched) process.exitCode = 1 | |
| 19 | } | |
| 20 | catch (error) { printError(error instanceof Error ? error.message : String(error)); process.exitCode = 1 } | |
| 21 | }, | |
| 22 | }) | |