also looking at this
feat: model VTOL electrical consumption and battery authority
#81
15 files
+605
-28
| @@ -1,11 +1,15 @@ | ||
| 1 | 1 | import type { VehicleProfile } from '../types' |
| 2 | 2 | import { createVtolHoverProfile } from './index' |
| 3 | import { createVtolPlant } from './plant' | |
| 3 | import { createVtolPlant, vtolModel } from './plant' | |
| 4 | 4 | import { createVtolFlightController } from './flight-controller' |
| 5 | import { renderVtolElectricalMeasurement, vtolElectricalMaximumW } from './power' | |
| 5 | 6 | |
| 6 | 7 | /** Declared fictional transition experiment, undergoing controller qualification. No physical IO. */ |
| 7 | export function createVtolTransitionProfile(): VehicleProfile { | |
| 8 | export function createVtolTransitionProfile(options: { electrical?: boolean } = {}): VehicleProfile { | |
| 8 | 9 | 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 | |
| 9 | 13 | return { |
| 10 | 14 | ...base, scenario: 'nominal', scenarios: ['nominal'], name: 'Owned VTOL lift-and-cruise development', |
| 11 | 15 | authorityFence: { radiusM: 400, minDownM: -40, maxDownM: 1 }, |
| @@ -21,15 +25,16 @@ export function createVtolTransitionProfile(): VehicleProfile { | ||
| 21 | 25 | { id: 'land', kind: 'land', positionM: [180, 0, 0], acceptanceM: 0.3, maxArrivalSpeedMps: 0.2, settleMs: 200, timeoutMs: 25000 }, |
| 22 | 26 | ], |
| 23 | 27 | }, |
| 28 | ...(batteryModel ? { batteryModel } : {}), | |
| 24 | 29 | createSession() { |
| 25 | return { createPlant: createVtolPlant, createController: createVtolFlightController, | |
| 30 | return { createPlant: batteryModel ? () => createVtolPlant({ electricalCapacityWh: batteryModel.capacityWh }) : createVtolPlant, createController: createVtolFlightController, | |
| 26 | 31 | renderMeasurement(state, atMs, reference) { |
| 27 | 32 | const rounded = (n: number) => Math.round(n * 1000000) / 1000000 |
| 28 | 33 | return { version: 1, evidence: 'modeled-vehicle-sensors', vehicle: 'vtol', sequence: Math.floor(atMs / 20) + 1, reference, capturedAtMs: atMs, receivedAtMs: atMs + 60, |
| 29 | 34 | values: { onSurface: state.onSurface, stopped: Math.hypot(...state.velocityMps) <= 0.2, |
| 30 | 35 | airspeedMps: rounded(state.details.airspeedMps as number), differentialPressurePa: rounded(state.details.dynamicPressurePa as number), |
| 31 | 36 | 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) } } | |
| 33 | 38 | }, |
| 34 | 39 | } |
| 35 | 40 | }, |