koenig-planner
v0.7.0
Published
WebAssembly bindings for the Koenig-D'Amico fuel-optimal impulsive maneuver planner
Maintainers
Readme
koenig-planner
WebAssembly bindings (npm package koenig-planner, Rust crate
koenig-damico-planner-wasm) for the Koenig-D'Amico fuel-optimal impulsive
maneuver planner, plus a client-side browser demo in the repo. The solver runs
entirely in the browser — nothing leaves the machine.
Install (npm)
Published to npm as koenig-planner,
built with wasm-pack --target bundler — your bundler (Vite / webpack / rollup /
Next) wires up the .wasm automatically:
npm install koenig-plannerimport { solve, version } from "koenig-planner";
// Chief orbit (deg / m), target relative orbital elements, and a cost model.
const request = {
chief: { a: 25_000e3, e: 0.7, i: 40, raan: 358, argp: 0, mean_anom: 180 },
t_i: 0,
t_f: 117_990,
dt: 30,
w_meters: [50, 5000, 100, 100, 0, 400], // [δa, δλ, δeₓ, δe_y, δiₓ, δi_y]·a
cost: { type: "piecewise" }, // or { type: "norm2" } / { type: "facemax" }
};
const outcome = solve(request); // typed SolveOutcome — never throws for a valid SolveRequest
if (outcome.status === "ok") {
const { maneuvers, total_dv } = outcome.value;
console.log(`${maneuvers.length} burns, Δv cost ${total_dv} m/s`);
} else {
console.error(outcome.error.kind, outcome.error.message);
}
console.log(version());This is a pure-compute solver with no DOM dependency. The --target web build in
the Build section below is for running the bundled demo locally.
Interface
solve(req: SolveRequest): SolveOutcome— typed; never throws for a validSolveRequest(errors are a{ status: "err", error: { kind, message } }value). Untyped JS passing a malformed object throws at the deserialization boundary before the solver runs; unknown keys are ignored on this path (unlikesolve_json, which rejects them).solve_json(json: string): string— string-in/string-out escape hatch; returns the response JSON, or throws the serialized{ kind, message }JSON on failure.version(): string— the crate version (used by the demo footer).
Types are generated by tsify and shipped
in the pkg/*.d.ts produced by wasm-pack.
Build
wasm-pack build crates/wasm --target web # → crates/wasm/pkg/
cd crates/wasm/www && npm install && npm run devcrates/wasm/pkg/ is a generated wasm-pack artifact (gitignored) that the demo
consumes via its file:../pkg dependency. npm run dev and npm run build
rebuild it first (the predev/prebuild hooks), so the standalone wasm-pack
build line is only needed once before the initial npm install, which must
resolve file:../pkg.
Demo
crates/wasm/www is a React + React-Three-Fiber app (built with Vite) — the
"Koenig-D'Amico Impulsive Control Solver" console. It takes a chief orbit, target
ROEs, and a cost model and renders the plan entirely client-side: two interactive
3D scenes (the chief orbit in ECI, and the deputy's relative orbit in the RTN
frame — both with per-maneuver Δv arrows and a swept primer arrow), a Δv timeline,
per-maneuver RTN Δv components, primer-magnitude and primer-component charts, and a
playback scrubber.
Test
This crate targets wasm32 only (it is never built for the host), so all tests
run on the wasm target via wasm-pack:
wasm-pack test --node crates/wasm # unit + boundary tests, in Node