ReviewOS

also looking at this

stacks/drone

feat: expose owned VTOL transition simulation through native CLI

#82
Merged chris wants to merge codex/owned-vtol-transition-cli into main
20 files +743 -36
resources/functions/drone/vehicles/vtol/transition-profile.tsmodified+9-4
Changes to resources/functions/drone/vehicles/vtol/transition-profile.ts
@@ -1,11 +1,15 @@
11import type { VehicleProfile } from '../types'
22import { createVtolHoverProfile } from './index'
3import { createVtolPlant } from './plant'
3import { createVtolPlant, vtolModel } from './plant'
44import { createVtolFlightController } from './flight-controller'
5import { renderVtolElectricalMeasurement, vtolElectricalMaximumW } from './power'
56
67/** Declared fictional transition experiment, undergoing controller qualification. No physical IO. */
7export function createVtolTransitionProfile(): VehicleProfile {
8export function createVtolTransitionProfile(options: { electrical?: boolean } = {}): VehicleProfile {
89 const base = createVtolHoverProfile()
10 const electrical = options.electrical
11 if (electrical !== undefined && typeof electrical !== 'boolean') throw new TypeError('Invalid VTOL electrical model selection')
12 const batteryModel = electrical ? Object.freeze({ evidence: 'modeled-vehicle-battery-v1' as const, capacityWh: 100, maximumSourceW: vtolElectricalMaximumW(vtolModel.maxRotorThrustN, vtolModel.maxPusherThrustN) }) : undefined
913 return {
1014 ...base, scenario: 'nominal', scenarios: ['nominal'], name: 'Owned VTOL lift-and-cruise development',
1115 authorityFence: { radiusM: 400, minDownM: -40, maxDownM: 1 },
@@ -21,15 +25,16 @@ export function createVtolTransitionProfile(): VehicleProfile {
2125 { id: 'land', kind: 'land', positionM: [180, 0, 0], acceptanceM: 0.3, maxArrivalSpeedMps: 0.2, settleMs: 200, timeoutMs: 25000 },
2226 ],
2327 },
28 ...(batteryModel ? { batteryModel } : {}),
2429 createSession() {
25 return { createPlant: createVtolPlant, createController: createVtolFlightController,
30 return { createPlant: batteryModel ? () => createVtolPlant({ electricalCapacityWh: batteryModel.capacityWh }) : createVtolPlant, createController: createVtolFlightController,
2631 renderMeasurement(state, atMs, reference) {
2732 const rounded = (n: number) => Math.round(n * 1000000) / 1000000
2833 return { version: 1, evidence: 'modeled-vehicle-sensors', vehicle: 'vtol', sequence: Math.floor(atMs / 20) + 1, reference, capturedAtMs: atMs, receivedAtMs: atMs + 60,
2934 values: { onSurface: state.onSurface, stopped: Math.hypot(...state.velocityMps) <= 0.2,
3035 airspeedMps: rounded(state.details.airspeedMps as number), differentialPressurePa: rounded(state.details.dynamicPressurePa as number),
3136 alphaRad: rounded(state.details.alphaRad as number), betaRad: rounded(state.details.betaRad as number),
32 rotorThrustN: rounded(state.details.rotorThrustN as number), pusherThrustN: rounded(state.details.pusherThrustN as number) } }
37 rotorThrustN: rounded(state.details.rotorThrustN as number), pusherThrustN: rounded(state.details.pusherThrustN as number), ...renderVtolElectricalMeasurement(state) } }
3338 },
3439 }
3540 },