feat(planning): consolidate recorded-route localization and spatial scene
Preserve the completed teach-and-repeat laboratory stage: reference preparation, cascaded acquisition, local tracking and recovery, recording lifecycle, replay qualification, and persistent Rerun scene controls. Document the open grid-picking regression and Rerun upgrade contract. No autonomous driving or loop-closure optimization is claimed.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
"""Repeat the frozen negative controls with exactly the new entry search policy."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
|
||||
from k1link.artifacts import utc_now_iso
|
||||
from k1link.missions.causal_replay import digest
|
||||
from k1link.missions.entry_acquisition_worker import run_entry_acquisition
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument("--controls", type=Path, required=True)
|
||||
p.add_argument("--replay", type=Path, required=True)
|
||||
p.add_argument("--output", type=Path, required=True)
|
||||
args = p.parse_args()
|
||||
prior = json.loads((args.controls / "report.json").read_text())
|
||||
replay = json.loads((args.replay / "report.json").read_text())
|
||||
path_file = args.replay / "step-003/query-path.npy"
|
||||
files = {path_file: replay["artifacts"]["step-003/query-path.npy"]}
|
||||
for name in ["wrong-region", "far-seed"]:
|
||||
relative = name + "/registration-input.npz"
|
||||
files[args.controls / relative] = prior["artifacts"][relative]
|
||||
for file, expected in files.items():
|
||||
if digest(file) != expected:
|
||||
raise ValueError("Control input changed.")
|
||||
query_path = np.load(path_file, allow_pickle=False)
|
||||
direction = next(
|
||||
p - query_path[0] for p in query_path[1:] if np.linalg.norm((p - query_path[0])[:2]) >= 3
|
||||
)
|
||||
args.output.mkdir(parents=True, exist_ok=False)
|
||||
report = dict(
|
||||
schema_version="missioncore.entry-controls/v1",
|
||||
created_at_utc=utc_now_iso(),
|
||||
source_step="step-003",
|
||||
results={},
|
||||
vehicle_control=False,
|
||||
localization_confirmed=False,
|
||||
input_digests={str(k): v for k, v in files.items()},
|
||||
)
|
||||
for name in ["wrong-region", "far-seed"]:
|
||||
with np.load(args.controls / name / "registration-input.npz", allow_pickle=False) as data:
|
||||
reference, query, initial = data["reference"], data["query"], data["initial"]
|
||||
directory = args.output / name
|
||||
directory.mkdir()
|
||||
result = run_entry_acquisition(
|
||||
directory, reference, query, initial, query_path[0], initial[:3, :3] @ direction
|
||||
)
|
||||
report["results"][name] = {k: v for k, v in result.items() if k != "matched_query_indices"}
|
||||
print(
|
||||
json.dumps(
|
||||
dict(
|
||||
control=name,
|
||||
status=result["status"],
|
||||
reasons=result["reasons"],
|
||||
hypotheses=len(result["initialization"]["attempts"]),
|
||||
clusters=result["initialization"]["clusters"],
|
||||
elapsed_s=result["initialization"]["elapsed_s"],
|
||||
)
|
||||
),
|
||||
flush=True,
|
||||
)
|
||||
report["source_integrity_verified"] = all(digest(k) == v for k, v in files.items())
|
||||
report["artifacts"] = {
|
||||
str(x.relative_to(args.output)): digest(x) for x in args.output.rglob("*") if x.is_file()
|
||||
}
|
||||
report["finished_at_utc"] = utc_now_iso()
|
||||
(args.output / "report.json").write_text(json.dumps(report, allow_nan=False))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user