@horizon36596/zenith-core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +18 -0
- package/README.md +16 -0
- package/dist/canonicalize.d.ts +25 -0
- package/dist/canonicalize.d.ts.map +1 -0
- package/dist/canonicalize.js +199 -0
- package/dist/canonicalize.js.map +1 -0
- package/dist/check.d.ts +26 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +231 -0
- package/dist/check.js.map +1 -0
- package/dist/checks/heading.d.ts +17 -0
- package/dist/checks/heading.d.ts.map +1 -0
- package/dist/checks/heading.js +78 -0
- package/dist/checks/heading.js.map +1 -0
- package/dist/checks/intake.d.ts +28 -0
- package/dist/checks/intake.d.ts.map +1 -0
- package/dist/checks/intake.js +131 -0
- package/dist/checks/intake.js.map +1 -0
- package/dist/checks/motion.d.ts +28 -0
- package/dist/checks/motion.d.ts.map +1 -0
- package/dist/checks/motion.js +252 -0
- package/dist/checks/motion.js.map +1 -0
- package/dist/checks/schedule.d.ts +29 -0
- package/dist/checks/schedule.d.ts.map +1 -0
- package/dist/checks/schedule.js +166 -0
- package/dist/checks/schedule.js.map +1 -0
- package/dist/checks/season.d.ts +6 -0
- package/dist/checks/season.d.ts.map +1 -0
- package/dist/checks/season.js +126 -0
- package/dist/checks/season.js.map +1 -0
- package/dist/continuity.d.ts +38 -0
- package/dist/continuity.d.ts.map +1 -0
- package/dist/continuity.js +69 -0
- package/dist/continuity.js.map +1 -0
- package/dist/diff.d.ts +37 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +258 -0
- package/dist/diff.js.map +1 -0
- package/dist/edit/command.d.ts +4 -0
- package/dist/edit/command.d.ts.map +1 -0
- package/dist/edit/command.js +16 -0
- package/dist/edit/command.js.map +1 -0
- package/dist/edit/errors.d.ts +9 -0
- package/dist/edit/errors.d.ts.map +1 -0
- package/dist/edit/errors.js +12 -0
- package/dist/edit/errors.js.map +1 -0
- package/dist/edit/fields.d.ts +40 -0
- package/dist/edit/fields.d.ts.map +1 -0
- package/dist/edit/fields.js +150 -0
- package/dist/edit/fields.js.map +1 -0
- package/dist/edit/finish.d.ts +15 -0
- package/dist/edit/finish.d.ts.map +1 -0
- package/dist/edit/finish.js +36 -0
- package/dist/edit/finish.js.map +1 -0
- package/dist/edit/groups.d.ts +66 -0
- package/dist/edit/groups.d.ts.map +1 -0
- package/dist/edit/groups.js +277 -0
- package/dist/edit/groups.js.map +1 -0
- package/dist/edit/ids.d.ts +39 -0
- package/dist/edit/ids.d.ts.map +1 -0
- package/dist/edit/ids.js +76 -0
- package/dist/edit/ids.js.map +1 -0
- package/dist/edit/index.d.ts +22 -0
- package/dist/edit/index.d.ts.map +1 -0
- package/dist/edit/index.js +22 -0
- package/dist/edit/index.js.map +1 -0
- package/dist/edit/meta.d.ts +15 -0
- package/dist/edit/meta.d.ts.map +1 -0
- package/dist/edit/meta.js +13 -0
- package/dist/edit/meta.js.map +1 -0
- package/dist/edit/path.d.ts +36 -0
- package/dist/edit/path.d.ts.map +1 -0
- package/dist/edit/path.js +135 -0
- package/dist/edit/path.js.map +1 -0
- package/dist/edit/steps.d.ts +53 -0
- package/dist/edit/steps.d.ts.map +1 -0
- package/dist/edit/steps.js +0 -0
- package/dist/edit/steps.js.map +1 -0
- package/dist/edit/template.d.ts +18 -0
- package/dist/edit/template.d.ts.map +1 -0
- package/dist/edit/template.js +30 -0
- package/dist/edit/template.js.map +1 -0
- package/dist/edit/timing.d.ts +11 -0
- package/dist/edit/timing.d.ts.map +1 -0
- package/dist/edit/timing.js +23 -0
- package/dist/edit/timing.js.map +1 -0
- package/dist/edit/tree.d.ts +32 -0
- package/dist/edit/tree.d.ts.map +1 -0
- package/dist/edit/tree.js +90 -0
- package/dist/edit/tree.js.map +1 -0
- package/dist/estimate.d.ts +48 -0
- package/dist/estimate.d.ts.map +1 -0
- package/dist/estimate.js +443 -0
- package/dist/estimate.js.map +1 -0
- package/dist/findingHelp.d.ts +18 -0
- package/dist/findingHelp.d.ts.map +1 -0
- package/dist/findingHelp.js +114 -0
- package/dist/findingHelp.js.map +1 -0
- package/dist/fix.d.ts +21 -0
- package/dist/fix.d.ts.map +1 -0
- package/dist/fix.js +180 -0
- package/dist/fix.js.map +1 -0
- package/dist/footprint.d.ts +33 -0
- package/dist/footprint.d.ts.map +1 -0
- package/dist/footprint.js +71 -0
- package/dist/footprint.js.map +1 -0
- package/dist/geometry/angle.d.ts +13 -0
- package/dist/geometry/angle.d.ts.map +1 -0
- package/dist/geometry/angle.js +21 -0
- package/dist/geometry/angle.js.map +1 -0
- package/dist/geometry/curve.d.ts +24 -0
- package/dist/geometry/curve.d.ts.map +1 -0
- package/dist/geometry/curve.js +78 -0
- package/dist/geometry/curve.js.map +1 -0
- package/dist/geometry/path.d.ts +29 -0
- package/dist/geometry/path.d.ts.map +1 -0
- package/dist/geometry/path.js +61 -0
- package/dist/geometry/path.js.map +1 -0
- package/dist/geometry/quadrature.d.ts +13 -0
- package/dist/geometry/quadrature.d.ts.map +1 -0
- package/dist/geometry/quadrature.js +57 -0
- package/dist/geometry/quadrature.js.map +1 -0
- package/dist/geometry/sat.d.ts +40 -0
- package/dist/geometry/sat.d.ts.map +1 -0
- package/dist/geometry/sat.js +86 -0
- package/dist/geometry/sat.js.map +1 -0
- package/dist/geometry/vec.d.ts +27 -0
- package/dist/geometry/vec.d.ts.map +1 -0
- package/dist/geometry/vec.js +30 -0
- package/dist/geometry/vec.js.map +1 -0
- package/dist/heading.d.ts +77 -0
- package/dist/heading.d.ts.map +1 -0
- package/dist/heading.js +164 -0
- package/dist/heading.js.map +1 -0
- package/dist/headingRanges.d.ts +48 -0
- package/dist/headingRanges.d.ts.map +1 -0
- package/dist/headingRanges.js +132 -0
- package/dist/headingRanges.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/kinematics.d.ts +63 -0
- package/dist/kinematics.d.ts.map +1 -0
- package/dist/kinematics.js +71 -0
- package/dist/kinematics.js.map +1 -0
- package/dist/ledger.d.ts +49 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +136 -0
- package/dist/ledger.js.map +1 -0
- package/dist/load.d.ts +12 -0
- package/dist/load.d.ts.map +1 -0
- package/dist/load.js +12 -0
- package/dist/load.js.map +1 -0
- package/dist/mirror.d.ts +81 -0
- package/dist/mirror.d.ts.map +1 -0
- package/dist/mirror.js +282 -0
- package/dist/mirror.js.map +1 -0
- package/dist/plan.d.ts +29 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +159 -0
- package/dist/plan.js.map +1 -0
- package/dist/prBody.d.ts +24 -0
- package/dist/prBody.d.ts.map +1 -0
- package/dist/prBody.js +112 -0
- package/dist/prBody.js.map +1 -0
- package/dist/provenance.d.ts +21 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +46 -0
- package/dist/provenance.js.map +1 -0
- package/dist/render.d.ts +18 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +464 -0
- package/dist/render.js.map +1 -0
- package/dist/resolve.d.ts +39 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +172 -0
- package/dist/resolve.js.map +1 -0
- package/dist/season.d.ts +65 -0
- package/dist/season.d.ts.map +1 -0
- package/dist/season.js +16 -0
- package/dist/season.js.map +1 -0
- package/dist/sim/commands.d.ts +97 -0
- package/dist/sim/commands.d.ts.map +1 -0
- package/dist/sim/commands.js +185 -0
- package/dist/sim/commands.js.map +1 -0
- package/dist/sim/curves.d.ts +37 -0
- package/dist/sim/curves.d.ts.map +1 -0
- package/dist/sim/curves.js +187 -0
- package/dist/sim/curves.js.map +1 -0
- package/dist/sim/follower.d.ts +124 -0
- package/dist/sim/follower.d.ts.map +1 -0
- package/dist/sim/follower.js +472 -0
- package/dist/sim/follower.js.map +1 -0
- package/dist/sim/ideal.d.ts +103 -0
- package/dist/sim/ideal.d.ts.map +1 -0
- package/dist/sim/ideal.js +393 -0
- package/dist/sim/ideal.js.map +1 -0
- package/dist/sim/index.d.ts +11 -0
- package/dist/sim/index.d.ts.map +1 -0
- package/dist/sim/index.js +10 -0
- package/dist/sim/index.js.map +1 -0
- package/dist/sim/params.d.ts +91 -0
- package/dist/sim/params.d.ts.map +1 -0
- package/dist/sim/params.js +195 -0
- package/dist/sim/params.js.map +1 -0
- package/dist/sim/pedroPath.d.ts +41 -0
- package/dist/sim/pedroPath.d.ts.map +1 -0
- package/dist/sim/pedroPath.js +191 -0
- package/dist/sim/pedroPath.js.map +1 -0
- package/dist/sim/plant.d.ts +59 -0
- package/dist/sim/plant.d.ts.map +1 -0
- package/dist/sim/plant.js +128 -0
- package/dist/sim/plant.js.map +1 -0
- package/dist/sim/residuals.d.ts +36 -0
- package/dist/sim/residuals.d.ts.map +1 -0
- package/dist/sim/residuals.js +86 -0
- package/dist/sim/residuals.js.map +1 -0
- package/dist/sim/simulate.d.ts +27 -0
- package/dist/sim/simulate.d.ts.map +1 -0
- package/dist/sim/simulate.js +924 -0
- package/dist/sim/simulate.js.map +1 -0
- package/dist/sim/types.d.ts +209 -0
- package/dist/sim/types.d.ts.map +1 -0
- package/dist/sim/types.js +2 -0
- package/dist/sim/types.js.map +1 -0
- package/dist/tokens.d.ts +93 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +93 -0
- package/dist/tokens.js.map +1 -0
- package/dist/trace.d.ts +89 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +187 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +219 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/unimplemented.d.ts +8 -0
- package/dist/unimplemented.d.ts.map +1 -0
- package/dist/unimplemented.js +11 -0
- package/dist/unimplemented.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { EditError } from "./errors.js";
|
|
2
|
+
import { finish } from "./finish.js";
|
|
3
|
+
import { updateStep } from "./tree.js";
|
|
4
|
+
function asPathStep(step, stepId) {
|
|
5
|
+
if (step.kind !== "path") {
|
|
6
|
+
throw new EditError(`Step ${JSON.stringify(stepId)} is a ${step.kind} step, not a path.`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Sets one point of one segment of a path step to a literal pose: a segment endpoint (`from` or
|
|
11
|
+
* `to`, replacing whatever pose source — inline pose, waypoint ref or `"current"` — was there) or
|
|
12
|
+
* one Bezier control point.
|
|
13
|
+
*/
|
|
14
|
+
export function setPose(auto, stepId, target, pose) {
|
|
15
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
16
|
+
asPathStep(step, stepId);
|
|
17
|
+
const segment = step.segments[target.segmentIndex];
|
|
18
|
+
if (segment === undefined) {
|
|
19
|
+
throw new EditError(`Step ${JSON.stringify(stepId)} has no segment at index ${String(target.segmentIndex)}.`);
|
|
20
|
+
}
|
|
21
|
+
const segments = [...step.segments];
|
|
22
|
+
if (target.pointKind === "control") {
|
|
23
|
+
if (segment.kind !== "bezier") {
|
|
24
|
+
throw new EditError(`Segment ${String(target.segmentIndex)} of step ${JSON.stringify(stepId)} is a line; it has no control points.`);
|
|
25
|
+
}
|
|
26
|
+
if (target.controlIndex === undefined) {
|
|
27
|
+
throw new EditError('A "control" pose target needs controlIndex.');
|
|
28
|
+
}
|
|
29
|
+
const control = [...segment.control];
|
|
30
|
+
if (control[target.controlIndex] === undefined) {
|
|
31
|
+
throw new EditError(`Segment ${String(target.segmentIndex)} of step ${JSON.stringify(stepId)} has no control point at index ${String(target.controlIndex)}.`);
|
|
32
|
+
}
|
|
33
|
+
control[target.controlIndex] = { ...pose };
|
|
34
|
+
segments[target.segmentIndex] = { ...segment, control };
|
|
35
|
+
}
|
|
36
|
+
else if (target.pointKind === "from") {
|
|
37
|
+
segments[target.segmentIndex] = { ...segment, from: { ...pose } };
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
segments[target.segmentIndex] = { ...segment, to: { ...pose } };
|
|
41
|
+
}
|
|
42
|
+
return { ...step, segments };
|
|
43
|
+
});
|
|
44
|
+
if (!result.found)
|
|
45
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
46
|
+
return finish({ ...auto, steps: result.steps });
|
|
47
|
+
}
|
|
48
|
+
/** Replaces a path step's heading mode outright. */
|
|
49
|
+
export function setHeadingMode(auto, stepId, heading) {
|
|
50
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
51
|
+
asPathStep(step, stepId);
|
|
52
|
+
return { ...step, heading };
|
|
53
|
+
});
|
|
54
|
+
if (!result.found)
|
|
55
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
56
|
+
return finish({ ...auto, steps: result.steps });
|
|
57
|
+
}
|
|
58
|
+
/** Sets a path step's `speedFraction` (0 exclusive, 1 inclusive; the schema enforces the range). */
|
|
59
|
+
export function setSpeed(auto, stepId, fraction) {
|
|
60
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
61
|
+
asPathStep(step, stepId);
|
|
62
|
+
return { ...step, speedFraction: fraction };
|
|
63
|
+
});
|
|
64
|
+
if (!result.found)
|
|
65
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
66
|
+
return finish({ ...auto, steps: result.steps });
|
|
67
|
+
}
|
|
68
|
+
/** Appends a segment to a path step. A path's segments must stay continuous; `validate` checks that. */
|
|
69
|
+
export function addSegment(auto, stepId, segment) {
|
|
70
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
71
|
+
asPathStep(step, stepId);
|
|
72
|
+
return { ...step, segments: [...step.segments, segment] };
|
|
73
|
+
});
|
|
74
|
+
if (!result.found)
|
|
75
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
76
|
+
return finish({ ...auto, steps: result.steps });
|
|
77
|
+
}
|
|
78
|
+
/** Removes the segment at `segmentIndex`. A path step needs at least one segment. */
|
|
79
|
+
export function removeSegment(auto, stepId, segmentIndex) {
|
|
80
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
81
|
+
asPathStep(step, stepId);
|
|
82
|
+
if (step.segments[segmentIndex] === undefined) {
|
|
83
|
+
throw new EditError(`Step ${JSON.stringify(stepId)} has no segment at index ${String(segmentIndex)}.`);
|
|
84
|
+
}
|
|
85
|
+
if (step.segments.length <= 1) {
|
|
86
|
+
throw new EditError(`Step ${JSON.stringify(stepId)} has only one segment; a path step needs at least one.`);
|
|
87
|
+
}
|
|
88
|
+
return { ...step, segments: step.segments.filter((_, index) => index !== segmentIndex) };
|
|
89
|
+
});
|
|
90
|
+
if (!result.found)
|
|
91
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
92
|
+
return finish({ ...auto, steps: result.steps });
|
|
93
|
+
}
|
|
94
|
+
/** Adds a marker to a path step. */
|
|
95
|
+
export function addMarker(auto, stepId, marker) {
|
|
96
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
97
|
+
asPathStep(step, stepId);
|
|
98
|
+
return { ...step, markers: [...(step.markers ?? []), marker] };
|
|
99
|
+
});
|
|
100
|
+
if (!result.found)
|
|
101
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
102
|
+
return finish({ ...auto, steps: result.steps });
|
|
103
|
+
}
|
|
104
|
+
/** Removes the marker at `markerIndex` from a path step. */
|
|
105
|
+
export function removeMarker(auto, stepId, markerIndex) {
|
|
106
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
107
|
+
asPathStep(step, stepId);
|
|
108
|
+
const markers = step.markers ?? [];
|
|
109
|
+
if (markers[markerIndex] === undefined) {
|
|
110
|
+
throw new EditError(`Step ${JSON.stringify(stepId)} has no marker at index ${String(markerIndex)}.`);
|
|
111
|
+
}
|
|
112
|
+
return { ...step, markers: markers.filter((_, index) => index !== markerIndex) };
|
|
113
|
+
});
|
|
114
|
+
if (!result.found)
|
|
115
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
116
|
+
return finish({ ...auto, steps: result.steps });
|
|
117
|
+
}
|
|
118
|
+
/** Moves a marker to a new `at` (path parameter, distance, or distance from the end). */
|
|
119
|
+
export function setMarkerAt(auto, stepId, markerIndex, at) {
|
|
120
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
121
|
+
asPathStep(step, stepId);
|
|
122
|
+
const markers = step.markers ?? [];
|
|
123
|
+
if (markers[markerIndex] === undefined) {
|
|
124
|
+
throw new EditError(`Step ${JSON.stringify(stepId)} has no marker at index ${String(markerIndex)}.`);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
...step,
|
|
128
|
+
markers: markers.map((marker, index) => (index === markerIndex ? { ...marker, at } : marker)),
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
if (!result.found)
|
|
132
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
133
|
+
return finish({ ...auto, steps: result.steps });
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/edit/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAkBvC,SAAS,UAAU,CAAC,IAAsB,EAAE,MAAc;IACxD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,SAAS,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,IAAI,oBAAoB,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAED;;;;GAIG;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,0 +1,53 @@
|
|
|
1
|
+
import { type Auto, type Step } from "@horizon36596/zenith-schema";
|
|
2
|
+
/**
|
|
3
|
+
* Adds `step` to the auto: after the step named `afterId`, wherever it is in the tree (top level,
|
|
4
|
+
* inside a `parallel` group, or inside a `branch` arm), or at the end of the top-level list when
|
|
5
|
+
* `afterId` is omitted.
|
|
6
|
+
*
|
|
7
|
+
* A step with no explicit `id` is given one here (its kind, disambiguated with `-2`, `-3`, ... if
|
|
8
|
+
* that is taken): a newly added step should always have a stable id an agent can refer to next,
|
|
9
|
+
* not a positional one that shifts under later edits.
|
|
10
|
+
*
|
|
11
|
+
* Uniqueness is decided against the ids the document has *after* the insertion, not before it.
|
|
12
|
+
* Inserting shifts every positional id below the insertion point by one, so three unnamed steps
|
|
13
|
+
* (`step1`, `step2`, `step3`) plus a new `step4` is a collision the before-picture cannot see.
|
|
14
|
+
*/
|
|
15
|
+
export declare function addStep(auto: Auto, step: Step, afterId?: string | IntoGroup): Auto;
|
|
16
|
+
/**
|
|
17
|
+
* A place inside a group rather than after a step: `index` (0-based, clamped; the end when
|
|
18
|
+
* absent) in the group's own list, or in the `then` or `else` arm of a branch (`then` when
|
|
19
|
+
* absent). This is how a step goes into a group that is empty of the place it should go, such as
|
|
20
|
+
* the front of a sequence; "after this member" is the plain id form.
|
|
21
|
+
*/
|
|
22
|
+
export interface IntoGroup {
|
|
23
|
+
into: string;
|
|
24
|
+
index?: number;
|
|
25
|
+
arm?: "then" | "else";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Removes the step named `id`, wherever it is in the tree.
|
|
29
|
+
*
|
|
30
|
+
* A `parallel` group left naming the removed step as its `deadline` has the reference dropped
|
|
31
|
+
* rather than repointed: no other member is the step whose end was meant to end the group, and a
|
|
32
|
+
* silent substitution would change what the routine does. The group is then a `deadline` group with
|
|
33
|
+
* no deadline, which `check` reports as a SCHEMA error for a human to resolve.
|
|
34
|
+
*/
|
|
35
|
+
export declare function removeStep(auto: Auto, id: string): Auto;
|
|
36
|
+
/**
|
|
37
|
+
* Moves the step named `id` to a new position: immediately after another step's id (searched
|
|
38
|
+
* for in whatever list currently holds it, top level or nested), or to a numbered index
|
|
39
|
+
* (0-based, clamped) in the top-level `steps` list. A numbered target always lands the step at
|
|
40
|
+
* the top level, even if it started inside a `parallel` or `branch` group, because an index only
|
|
41
|
+
* means something within one flat list and the top level is the only one every caller can name
|
|
42
|
+
* without also knowing the tree's shape. An `IntoGroup` target puts it at an index inside a
|
|
43
|
+
* sequence, parallel group or branch arm, which is how a step moves into a group (or to the front
|
|
44
|
+
* of one); moving it after a top-level step, or to a number, moves it out again.
|
|
45
|
+
*/
|
|
46
|
+
export declare function moveStep(auto: Auto, id: string, target: string | number | IntoGroup): Auto;
|
|
47
|
+
/**
|
|
48
|
+
* Gives the step named `id` a new explicit id. When the step is a child of a `parallel` group
|
|
49
|
+
* whose `deadline` names the old id, the parent's `deadline` is updated too, so the rename does
|
|
50
|
+
* not silently orphan the deadline reference.
|
|
51
|
+
*/
|
|
52
|
+
export declare function renameStep(auto: Auto, id: string, newId: string): Auto;
|
|
53
|
+
//# sourceMappingURL=steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../src/edit/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAM/F;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAiBlF;AAQD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AA0CD;;;;;;;GAOG;A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,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAsB,EAAE,KAAa,EAAE,KAAa;IACjF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,OAAO,GAAG,cAAc,CAC5B,IAAI,EACJ,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAC/D,CAAC;QACF,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK;YAAE,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxF,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Auto } from "@horizon36596/zenith-schema";
|
|
2
|
+
export interface AutoTemplate {
|
|
3
|
+
alliance: "RED" | "BLUE";
|
|
4
|
+
/** The same shape as `Auto["start"]`: a pose (or a waypoint ref) and optionally what it holds. */
|
|
5
|
+
start: Auto["start"];
|
|
6
|
+
/** Overrides the project's `zenith.json` robot file, the way `auto.robot` does. */
|
|
7
|
+
robotPath?: string;
|
|
8
|
+
/** Overrides the project's `zenith.json` field file, the way `auto.field` does. */
|
|
9
|
+
fieldPath?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds a new auto from scratch: `name`, the template's alliance and start, and one placeholder
|
|
13
|
+
* leg so the file is valid immediately (the schema requires at least one step). The leg starts
|
|
14
|
+
* from `"current"`, which resolves against `start` the same way the first step of any auto does
|
|
15
|
+
* (`packages/core/src/resolve.ts`), so there is nothing to fill in before this validates.
|
|
16
|
+
*/
|
|
17
|
+
export declare function newAutoFromTemplate(name: string, template: AutoTemplate): Auto;
|
|
18
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/edit/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGnF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,KAAK,GAAG,MAAM,CAAC;IACzB,kGAAkG;IAClG,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,CAoB9E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FORMAT_VERSION, SCHEMA_ID } from "@horizon36596/zenith-schema";
|
|
2
|
+
import { finish } from "./finish.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a new auto from scratch: `name`, the template's alliance and start, and one placeholder
|
|
5
|
+
* leg so the file is valid immediately (the schema requires at least one step). The leg starts
|
|
6
|
+
* from `"current"`, which resolves against `start` the same way the first step of any auto does
|
|
7
|
+
* (`packages/core/src/resolve.ts`), so there is nothing to fill in before this validates.
|
|
8
|
+
*/
|
|
9
|
+
export function newAutoFromTemplate(name, template) {
|
|
10
|
+
return finish({
|
|
11
|
+
$schema: SCHEMA_ID.auto,
|
|
12
|
+
formatVersion: FORMAT_VERSION,
|
|
13
|
+
name,
|
|
14
|
+
title: name,
|
|
15
|
+
robot: template.robotPath,
|
|
16
|
+
field: template.fieldPath,
|
|
17
|
+
alliance: template.alliance,
|
|
18
|
+
start: template.start,
|
|
19
|
+
steps: [
|
|
20
|
+
{
|
|
21
|
+
id: "leg1",
|
|
22
|
+
kind: "path",
|
|
23
|
+
segments: [{ kind: "line", from: "current", to: { xIn: 0, yIn: 24 } }],
|
|
24
|
+
heading: { mode: "tangent" },
|
|
25
|
+
notes: "Replace this leg with the real opening move.",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/edit/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAa,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAYrC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,QAAsB;IACtE,OAAO,MAAM,CAAC;QACZ,OAAO,EAAE,SAAS,CAAC,IAAI;QACvB,aAAa,EAAE,cAAc;QAC7B,IAAI;QACJ,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,QAAQ,CAAC,SAAS;QACzB,KAAK,EAAE,QAAQ,CAAC,SAAS;QACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC;gBACtE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC5B,KAAK,EAAE,8CAA8C;aACtD;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Auto } from "@horizon36596/zenith-schema";
|
|
2
|
+
/**
|
|
3
|
+
* Sets or clears a step's `timeoutS`. Only `path`, `command` and `wait` steps carry one; a
|
|
4
|
+
* `parallel` or `branch` step has no timeout of its own (site/docs/file-format.md, step kinds).
|
|
5
|
+
*
|
|
6
|
+
* Named to match the other edit primitives; it shadows the global
|
|
7
|
+
* `setTimeout` only within this module, and this package never schedules a timer (CLAUDE.md
|
|
8
|
+
* rule 1: no clock in `packages/core`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function setTimeout(auto: Auto, stepId: string, timeoutS: number | undefined): Auto;
|
|
11
|
+
//# sourceMappingURL=timing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../src/edit/timing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAKxD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAWzF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EditError } from "./errors.js";
|
|
2
|
+
import { finish } from "./finish.js";
|
|
3
|
+
import { updateStep } from "./tree.js";
|
|
4
|
+
/**
|
|
5
|
+
* Sets or clears a step's `timeoutS`. Only `path`, `command` and `wait` steps carry one; a
|
|
6
|
+
* `parallel` or `branch` step has no timeout of its own (site/docs/file-format.md, step kinds).
|
|
7
|
+
*
|
|
8
|
+
* Named to match the other edit primitives; it shadows the global
|
|
9
|
+
* `setTimeout` only within this module, and this package never schedules a timer (CLAUDE.md
|
|
10
|
+
* rule 1: no clock in `packages/core`).
|
|
11
|
+
*/
|
|
12
|
+
export function setTimeout(auto, stepId, timeoutS) {
|
|
13
|
+
const result = updateStep(auto.steps, "step", stepId, (step) => {
|
|
14
|
+
if (step.kind !== "path" && step.kind !== "command" && step.kind !== "wait") {
|
|
15
|
+
throw new EditError(`Step ${JSON.stringify(stepId)} is a ${step.kind} step, which has no timeoutS.`);
|
|
16
|
+
}
|
|
17
|
+
return { ...step, timeoutS };
|
|
18
|
+
});
|
|
19
|
+
if (!result.found)
|
|
20
|
+
throw new EditError(`No step with id ${JSON.stringify(stepId)}.`);
|
|
21
|
+
return finish({ ...auto, steps: result.steps });
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=timing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/edit/timing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU,EAAE,MAAc,EAAE,QAA4B;IACjF,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC5E,MAAM,IAAI,SAAS,CACjB,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,IAAI,+BAA+B,CAChF,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,KAAK;QAAE,MAAM,IAAI,SAAS,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACrF,OAAO,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Step } from "@horizon36596/zenith-schema";
|
|
2
|
+
/**
|
|
3
|
+
* What `updateStep`'s callback returns for the step it found: a replacement, `"remove"` to drop
|
|
4
|
+
* the step from its containing list, or `undefined` to leave it exactly as it was.
|
|
5
|
+
*/
|
|
6
|
+
export type StepUpdate = Step | "remove" | undefined;
|
|
7
|
+
export interface UpdateResult {
|
|
8
|
+
steps: Step[];
|
|
9
|
+
found: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Walks a step forest — the top-level list plus every `sequence.steps`, `parallel.steps` and
|
|
13
|
+
* `branch.then`/`else` nested inside it — looking for the one step whose effective id
|
|
14
|
+
* (`effectiveId`) is `targetId`, and rebuilds the forest with `update` applied to it. Every list on the path back to the root is
|
|
15
|
+
* a new array; every step not on that path is the same object it was, so this never mutates the
|
|
16
|
+
* auto it is given.
|
|
17
|
+
*
|
|
18
|
+
* Ids are unique by construction: `finish` refuses any edit that would repeat one and `check`
|
|
19
|
+
* raises a SCHEMA error for a hand-written file that does, so the walk stops looking as soon as it
|
|
20
|
+
* finds a match. On a document that has slipped through anyway, the first match in document order
|
|
21
|
+
* is the one every caller acts on, which is also the one whose finding is reported first.
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateStep(steps: readonly Step[], prefix: string, targetId: string, update: (step: Step, id: string) => StepUpdate): UpdateResult;
|
|
24
|
+
/** `updateStep`, but only to read the matching step out without changing the forest. */
|
|
25
|
+
export declare function findStep(steps: readonly Step[], prefix: string, targetId: string): Step | null;
|
|
26
|
+
/**
|
|
27
|
+
* Inserts `newStep` immediately after the step whose effective id is `afterId`, in whichever list
|
|
28
|
+
* — top level, a sequence's or parallel group's `steps`, or a branch's `then`/`else` — actually
|
|
29
|
+
* contains it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function insertAfter(steps: readonly Step[], prefix: string, afterId: string, newStep: Step): UpdateResult;
|
|
32
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/edit/tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGpF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,UAAU,GAC7C,YAAY,CA0Bd;AAuBD,wFAAwF;AACxF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAO9F;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,IAAI,GACZ,YAAY,CAyBd"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { childLists, withChildLists } from "@horizon36596/zenith-schema";
|
|
2
|
+
import { childPrefix, effectiveId } from "./ids.js";
|
|
3
|
+
/**
|
|
4
|
+
* Walks a step forest — the top-level list plus every `sequence.steps`, `parallel.steps` and
|
|
5
|
+
* `branch.then`/`else` nested inside it — looking for the one step whose effective id
|
|
6
|
+
* (`effectiveId`) is `targetId`, and rebuilds the forest with `update` applied to it. Every list on the path back to the root is
|
|
7
|
+
* a new array; every step not on that path is the same object it was, so this never mutates the
|
|
8
|
+
* auto it is given.
|
|
9
|
+
*
|
|
10
|
+
* Ids are unique by construction: `finish` refuses any edit that would repeat one and `check`
|
|
11
|
+
* raises a SCHEMA error for a hand-written file that does, so the walk stops looking as soon as it
|
|
12
|
+
* finds a match. On a document that has slipped through anyway, the first match in document order
|
|
13
|
+
* is the one every caller acts on, which is also the one whose finding is reported first.
|
|
14
|
+
*/
|
|
15
|
+
export function updateStep(steps, prefix, targetId, update) {
|
|
16
|
+
let found = false;
|
|
17
|
+
const result = [];
|
|
18
|
+
for (const [index, step] of steps.entries()) {
|
|
19
|
+
if (found) {
|
|
20
|
+
result.push(step);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const id = effectiveId(step, index, prefix);
|
|
24
|
+
if (id === targetId) {
|
|
25
|
+
found = true;
|
|
26
|
+
const outcome = update(step, id);
|
|
27
|
+
if (outcome !== "remove")
|
|
28
|
+
result.push(outcome === undefined ? step : outcome);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const nested = inChildren(step, id, (list, childPrefixed) => updateStep(list, childPrefixed, targetId, update));
|
|
32
|
+
if (nested !== null)
|
|
33
|
+
found = true;
|
|
34
|
+
result.push(nested ?? step);
|
|
35
|
+
}
|
|
36
|
+
return { steps: result, found };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tries `visit` on each child list of a group step in turn and stops at the first that finds its
|
|
40
|
+
* target, returning the group rebuilt around the changed list; null when no list held the target
|
|
41
|
+
* (or the step is a leaf). Every walker in this file recurses through here, so sequence, parallel
|
|
42
|
+
* and branch steps are all searched alike.
|
|
43
|
+
*/
|
|
44
|
+
function inChildren(step, id, visit) {
|
|
45
|
+
const lists = childLists(step);
|
|
46
|
+
for (const [listIndex, list] of lists.entries()) {
|
|
47
|
+
const child = visit(list, childPrefix(id, lists.length, listIndex));
|
|
48
|
+
if (!child.found)
|
|
49
|
+
continue;
|
|
50
|
+
const rebuilt = lists.map((original, i) => (i === listIndex ? child.steps : original));
|
|
51
|
+
return withChildLists(step, rebuilt);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
/** `updateStep`, but only to read the matching step out without changing the forest. */
|
|
56
|
+
export function findStep(steps, prefix, targetId) {
|
|
57
|
+
let found = null;
|
|
58
|
+
updateStep(steps, prefix, targetId, (step) => {
|
|
59
|
+
found = step;
|
|
60
|
+
return undefined;
|
|
61
|
+
});
|
|
62
|
+
return found;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Inserts `newStep` immediately after the step whose effective id is `afterId`, in whichever list
|
|
66
|
+
* — top level, a sequence's or parallel group's `steps`, or a branch's `then`/`else` — actually
|
|
67
|
+
* contains it.
|
|
68
|
+
*/
|
|
69
|
+
export function insertAfter(steps, prefix, afterId, newStep) {
|
|
70
|
+
let found = false;
|
|
71
|
+
const result = [];
|
|
72
|
+
for (const [index, step] of steps.entries()) {
|
|
73
|
+
if (found) {
|
|
74
|
+
result.push(step);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const id = effectiveId(step, index, prefix);
|
|
78
|
+
if (id === afterId) {
|
|
79
|
+
found = true;
|
|
80
|
+
result.push(step, newStep);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const nested = inChildren(step, id, (list, childPrefixed) => insertAfter(list, childPrefixed, afterId, newStep));
|
|
84
|
+
if (nested !== null)
|
|
85
|
+
found = true;
|
|
86
|
+
result.push(nested ?? step);
|
|
87
|
+
}
|
|
88
|
+
return { steps: result, found };
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/edit/tree.ts"],"names":[],"mappings":"AAAA,OAA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,CAAC;QAC5C,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,SAAS;QACX,CAAC;QAED,MAAM,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5C,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;YACnB,KAAK,GAAG,IAAI,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,CAC1D,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CACnD,CAAC;QACF,IAAI,MAAM,KAAK,IAAI;YAAE,KAAK,GAAG,IAAI,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type CommandSpec, type Robot } from "@horizon36596/zenith-schema";
|
|
2
|
+
import { type RobotLimits } from "./kinematics.js";
|
|
3
|
+
import type { Estimate, Plan } from "./types.js";
|
|
4
|
+
/** One sample of the velocity profile along a path step. */
|
|
5
|
+
interface ProfileSample {
|
|
6
|
+
sIn: number;
|
|
7
|
+
/** The direction of travel minus the robot's heading: 0 is nose-first, pi/2 is a left strafe. */
|
|
8
|
+
phiRad: number;
|
|
9
|
+
/** The cap from the velocity ellipse, the heading rate and the curvature, all applied. */
|
|
10
|
+
capInPerS: number;
|
|
11
|
+
/** The coasting deceleration available in this travel direction. */
|
|
12
|
+
decelInPerS2: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PathTiming {
|
|
15
|
+
seconds: number;
|
|
16
|
+
strafeFraction: number;
|
|
17
|
+
exitVelocityInPerS: number;
|
|
18
|
+
/** Cumulative seconds at each plan sample, so a caller can turn a time into a place on the path. */
|
|
19
|
+
timeAtSampleS: number[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The two-pass profile of `03` section 3 step 6: take the minimum of the caps, raise it forwards
|
|
23
|
+
* under `accel` from the entry velocity, lower it backwards under the direction's deceleration into
|
|
24
|
+
* the exit velocity, then integrate `ds / v`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function integrateProfile(samples: readonly ProfileSample[], limits: RobotLimits, entryVelocityInPerS: number, exitVelocityInPerS: number): PathTiming;
|
|
27
|
+
/** The numbers a command's `estimateS` expression may name: its arguments, resolved to seconds. */
|
|
28
|
+
export declare function commandScope(spec: CommandSpec | undefined, args: Readonly<Record<string, string | number | boolean>> | undefined, robot: Robot): Record<string, number>;
|
|
29
|
+
/** The seconds a command step takes, or null when its registry entry says `"unknown"`. */
|
|
30
|
+
export declare function commandSeconds(name: string, args: Readonly<Record<string, string | number | boolean>> | undefined, robot: Robot): number | null;
|
|
31
|
+
/** True when the registry marks this command as one the robot stands still for. */
|
|
32
|
+
export declare const isStationary: (robot: Robot, name: string) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Per-step `{nominalS, lowS, highS, strafeFraction, strafeCostS, unknown}` and the total with its
|
|
35
|
+
* band, from the model of `03` section 3. Deterministic and pure.
|
|
36
|
+
*/
|
|
37
|
+
export declare function estimate(plan: Plan, robot: Robot): Estimate;
|
|
38
|
+
/**
|
|
39
|
+
* Which way an estimate's total is a bound, when it is one. A step with no predictable duration
|
|
40
|
+
* counts as zero seconds, so the routine takes at least the total ("lower"). A step that ends on a
|
|
41
|
+
* condition is timed as if it drove its whole path, so the routine takes at most the total
|
|
42
|
+
* ("upper"). When both kinds are present the total is only a lower bound on the known part, and
|
|
43
|
+
* "lower" is reported because it is the claim that stays true. The renderer, the editor and the
|
|
44
|
+
* pull-request body all read this one rule.
|
|
45
|
+
*/
|
|
46
|
+
export declare function totalBound(estimateResult: Estimate): "lower" | "upper" | null;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=estimate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../src/estimate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,KAAK,EAEX,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAA0B,MAAM,YAAY,CAAC;AAgBzE,4DAA4D;AAC5D,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,iGAAiG;IACjG,MAAM,EAAE,MAAM,CAAC;IACf,0FAA0F;IAC1F,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oGAAoG;IACpG,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAiDD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,MAAM,EAAE,WAAW,EACnB,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,MAAM,GACzB,UAAU,CAmEZ;AAED,mGAAmG;AACnG,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,EACrE,KAAK,EAAE,KAAK,GACX,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAw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