ReviewOS

also looking at this

stacks/drone

feat: model VTOL electrical consumption and battery authority

#81
Merged chris wants to merge codex/owned-vtol-electrical-energy into main
15 files +605 -28
docs/vehicles-vtol.mdmodified+70-6
Changes to docs/vehicles-vtol.md
@@ -11,6 +11,7 @@ profiles in the `/missions` workspace.
1111./buddy vtol:hover
1212./buddy vtol:hover --scenario host-loss
1313./buddy vtol:hover --scenario imu-loss
14./buddy vtol:hover --electrical
1415```
1516
1617The native Stacks command defaults to 60 virtual seconds. It accepts `hover`, `imu-loss`,
@@ -25,6 +26,7 @@ The copied standalone CLI registers the same command definition:
2526```sh
2627bun run runtime:cli
2728./storage/runtime-build/cli/drone vtol:hover
29./storage/runtime-build/cli/drone vtol:hover --electrical
2830```
2931
3032## Model and measurements
@@ -50,8 +52,9 @@ RC takeover, kill and sensor loss revoke shared authority. Host death leaves its
5052stale while the independently ticking modeled board expires the output lease.
5153
5254The mission's 50 Wh capacity, 1200 W ceiling and 30% reserve are declared budget inputs for this
53fictional hover experiment. They are not identified electrical power, measured endurance or a
54complete hybrid energy model. Neutral outputs during an airborne fault do not establish a safe
55fictional hover experiment. The default retains a constant declared-ceiling charge. The optional
56electrical model below supplies fictional propulsion/battery dynamics and delayed energy measurements.
57Neither mode identifies hardware power or measured endurance. Neutral outputs during an airborne fault do not establish a safe
5558emergency landing. Physical flight commands remain disabled.
5659
5760## Explicit hover observation in library plans
@@ -96,8 +99,8 @@ requires wrapped heading error within 0.1 rad for the complete 500 ms dwell. Hov
9699therefore have a finite 45-second ceiling; front requests retain 15 seconds. The original 15-second
97100back budget still fails without retry or a claimed landing. This is a virtual task allowance,
98101not a wall-clock test timeout. The complete declared mission budget is 131,520 ms, or 43.84 Wh at its
991200 W ceiling, with 100 Wh capacity and 30% reserve. These remain declared planning values, without
100a complete hybrid electrical-power law or measured battery identification.
1021200 W ceiling, with 100 Wh capacity and 30% reserve. These remain declared planning values. Select
103the optional electrical law below for modeled consumption; measured battery identification remains open.
101104
102105The experiment keeps the 2 m transition-height deviation, 0.6 rad roll, 0.5 rad pitch and 22 m/s
103106speed guards. Its own target range is bounded to 400 m. The quadcopter and hover development kernel's
@@ -196,7 +199,7 @@ airborne. A separately declared 35-second allowance completes after about 26.94
196199the complete 156,520 ms / 52.1733 Wh worst-case plan. A normal 45-second back plus 45-second recovery
197200hover and 35-second landing exceeds the unchanged 180-second graph cap and is rejected. The phase
198201abort/pause/recover campaigns instead declare 40-second recovery hover and 30-second landing, fitting
199176,520 ms / 58.84 Wh. These remain declared 1200 W planning charges, without identified electrical
202176,520 ms / 58.84 Wh. These remain conservative 1200 W planning charges, without identified electrical
200203power or measured battery endurance.
201204
202205Sensor loss, reference/clock guards, RC takeover, kill, fence, reserve and global endurance remain
@@ -204,11 +207,72 @@ authoritative during recovery. Host loss still produces a stale host snapshot an
204207lease expiry. Fault-induced neutral outputs do not become a landing claim. These bounded library
205208campaigns do not qualify arbitrary wind, failed lift rotors, every transition state or physical recovery.
206209
210## Fictional electrical model
211
212Select `--electrical` in the hover command, or pass `{ electrical: true }` to
213`createVtolHoverProfile('hover', options)` or `createVtolTransitionProfile(options)` in TypeScript.
214The default/disabled profiles keep their prior reports and declared-ceiling energy accounting.
215The same hover option runs through Buddy and the copied standalone CLI. Full transition execution
216remains a library feature.
217
218Each session owns its electrical state. The plant uses actual lagged individual rotor and pusher
219thrust, with these declared coefficients:
220
221| Source | Fictional law |
222| --- | --- |
223| Each of four lift motors | `4 * thrustN ** 1.5` W |
224| Independent pusher | `5 * thrustN ** 1.5` W |
225| Avionics and idle auxiliaries | 12 W |
226| Each surface | `3 * abs(deflectionRad) / 0.4` W |
227| Open-circuit voltage | 20 to 24 V, linear in remaining chemical energy fraction |
228| Series resistance | 0.04 ohm |
229
230The low-current solution of `loadW = (openCircuitV - currentA * resistanceOhm) * currentA`
231sets terminal voltage and current. Chemical source power is `openCircuitV * currentA`, including
232series loss. The four motors, full pusher and all surfaces together draw 948.023527 W at the load.
233At the minimum open-circuit voltage their chemical source demand is 1060.486740 W, rounded upward
234to a **1061 W envelope**. This is an analytic bound on this fictional law, not a motor/battery rating.
235The 20 to 24 V open-circuit range is a simulation parameter; the hardware list's 4S pack retains
236its own specification.
237
238Before session allocation, the runtime requires a planning ceiling at least this envelope and
239capacity matching the captured plant declaration. Existing longest-path graph validation charges
240the complete declared ceiling across normal and supported failure/recovery/landing routes. With the
2411200 W planning ceiling, the normal route is 43.84 Wh and the declared back-abort route is 58.84 Wh.
242At 50% reserve of 100 Wh, the former fits and the latter is refused before resources are created.
243The front-failure path is shorter than the normal route, so it does not increase that worst-case budget.
244
245The plant integrates chemical source energy on its independent 4 ms steps. Before remaining energy
246cannot fund one complete worst-case step, propulsion demand is cut and latched. Retained motor response
247may coast down; it cannot rearm from a voltage rebound. Auxiliary draw continues to exhaustion.
248Rejected rigid-body integration commits neither body nor electrical state.
249
250Battery data travels through existing delayed, sequence/reference/capture-qualified measurements.
251Energy use rounds upward to micro-watt-hours; current/voltage/load use declared milli-unit quantization.
252The common qualifier rejects missing, nonfinite, inconsistent, over-envelope or decreasing consumption.
253The authority and mission receive a conservative remaining-energy bound after charging the maximum
254source envelope over the measurement's age. A reported supply cutoff withdraws authority even if
255chemical capacity remains. Source loss never substitutes a full battery.
256
257Reports add `energy.model` and `energy.lastObservation`. `energyUsedWh` belongs to its capture epoch;
258`remainingWhLowerBound` and `remainingPercentLowerBound` include the worst-case age charge at
259`observedAtMs`. Host loss leaves this host observation unchanged while independent plant consumption
260and board expiry continue. Mission-policy replay uses the recorded battery observations; it does not
261reconstruct the electrical plant from a mission trace alone.
262
263Actual model campaigns cover combined front demand, all nominal phases, open-circuit pusher timeout, initial/front/back abort
264landing, held recovery/resume, global endurance during pause, supply cutoff, bad battery observations,
265reserve, host loss and independent sessions. The nominal example's front peak is 347.313 W; its
266last captured use is about 4.62 Wh. Neither value predicts aircraft endurance. Motor/propeller advance
267ratio, voltage-dependent thrust, cell temperature/degradation, current-sensor calibration and measured
268capacity remain unmodeled or unqualified. The open-circuit fixture removes pusher demand and thrust;
269it does not model a seized motor's electrical current.
270
207271## Remaining implementation
208272
209273[Issue #12](https://github.com/stacksjs/drone/issues/12) remains open. The experimental nominal
210274controller and opt-in recovery routes do not establish complete VTOL support. Complete recovery/abort
211envelopes, fresh-process restoration, the complete hybrid power/reserve model, native transition CLI and
275envelopes, fresh-process restoration, identified hybrid power/voltage/cell behavior, native transition CLI and
212276the common mission workspace still require implementation and qualification. Wind campaigns and
213277broader mission/envelope coverage remain necessary. Full TECS/soaring, tiltrotor/tailsitter mechanisms,
214278helicopters and other airframe families remain separate work. Native board control, measured airframe