Add prepared urban route guidance to Gaussian simulation planning

Introduce a content-bound scene route provider, advisory runtime graph and plan-preview-launch workflow. Preserve live sensing authority and retire blocked intermediate goals without discarding final-arrival evidence. Bound native visual context losslessly and provide verified cache relocation. Full Maroseyka route qualification remains open.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-08 23:42:26 +03:00
parent 2e85d95c71
commit 31b74e4571
34 changed files with 1451 additions and 83 deletions
@@ -10,8 +10,8 @@ export const prepareEditor = (world: AiWorld, signal?: AbortSignal) => polygonRe
export const fetchEditor = (key: string, signal?: AbortSignal) => polygonRequest<EditorCache>(`/editor-cache/${key}`, { signal });
export const editorAssetUrl = (key: string, name: string) => `/api/v1/ai-polygon/editor-cache/${key}/${name}`;
export const saveLocalPlan = (cache: EditorCache, robot: AiRobot, points: AiWaypoint[], name: string,
draftId: string, sequence: number) => polygonRequest<AiPlan>("/plans", { method: "POST", body: JSON.stringify({
draftId: string, sequence: number, routePreparationKey?:string|null) => polygonRequest<AiPlan>("/plans", { method: "POST", body: JSON.stringify({
cache_key: cache.key, robot_id: robot.robot_id, robot_sha256: robot.sha256,
draft_id: draftId, sequence, points, name,
draft_id: draftId, sequence, points, name, route_preparation_key:routePreparationKey??null,
}) });
export { toEditor, toMission } from "./aiEditorCoordinates";
@@ -1,3 +1,4 @@
import type { PreparedRoute } from "./routePreparation";
import { decodeAIModuleCatalog, type AIModuleCatalog, type AIGroupId } from "../observatory/aiComposition";
import type { RoverMotion } from "./roverMotion";
import type { RoverSettings } from "./roverSettings";
@@ -112,7 +113,7 @@ export interface AiRouteOverlay {
export interface AiPlanningState { sequence: number; view_revision: number; points: AiWaypoint[];
error: string | null; can_undo: boolean; clip_height: number | null;
height_min?: number | null; height_max?: number | null; camera_moving?: boolean }
export interface AiPlan { plan_id: string; name: string; sha256: string; world_id: string;
export interface AiPlan { prepared_route?:PreparedRoute; route_preparation_key?:string; plan_id: string; name: string; sha256: string; world_id: string;
settings?: Pick<AiWorldSettings, "max_speed_mps">;
display_name?: string; removed?: boolean;
editor_cache_key?: string;
@@ -0,0 +1,63 @@
import { useEffect, useRef, useState } from "react";
import { polygonRequest, type AiPlan, type AiRobot, type AiWaypoint } from "./aiPolygon";
import type { EditorCache } from "./aiEditor";
export interface PreparedRoute {
sha256:string; preview_xyz:number[][]; length_m:number;
identity:{world_sha256:string;robot_sha256:string;points:AiWaypoint[]};
}
export interface RoutePreparation {
key:string;status:"queued"|"preparing"|"ready"|"failed";error:string|null;result:PreparedRoute|null;
}
export function routeMatches(route:PreparedRoute|null|undefined, cache:EditorCache|null,
robot:AiRobot|undefined, points:AiWaypoint[]) {
return !!route && !!cache && !!robot && route.identity.world_sha256===cache.world.sha256
&& route.identity.robot_sha256===robot.sha256 && JSON.stringify(route.identity.points)===JSON.stringify(points);
}
export function useRoutePreparation(cache:EditorCache|null, robot:AiRobot|undefined,
points:AiWaypoint[], plan:AiPlan|undefined, onError:(message:string)=>void) {
const [job,setJob]=useState<RoutePreparation|null>(null);
const [submitting,setSubmitting]=useState(false);
const generation=useRef(0);
const signature=JSON.stringify([cache?.key,robot?.sha256,points]);
const current=useRef(signature);current.current=signature;
const error=useRef(onError);error.current=onError;
useEffect(()=>{generation.current++;setJob(null);setSubmitting(false);},[signature]);
useEffect(()=>{
if(!job || !["queued","preparing"].includes(job.status))return;
const key=job.key,stamp=generation.current;
let active=true,timer:ReturnType<typeof setTimeout>;
const controller=new AbortController();
const poll=async()=>{
try {
const next=await polygonRequest<RoutePreparation>(`/route-preparations/${key}`,{signal:controller.signal});
if(active && generation.current===stamp){
setJob(next);
if(next.status==="failed")error.current(next.error??"Маршрут не построен.");
else if(next.status!=="ready")timer=setTimeout(()=>void poll(),1000);
}
} catch(caught) {
if(active){error.current((caught as Error).message);setJob(null);}
}
};
timer=setTimeout(()=>void poll(),500);
return()=>{active=false;clearTimeout(timer);controller.abort();};
},[job?.key,job?.status]);
const generated=routeMatches(job?.result,cache,robot,points)?job?.result:null;
const saved=routeMatches(plan?.prepared_route,cache,robot,points)?plan?.prepared_route:null;
const route=generated??saved??null;
const key=generated?job!.key:saved?plan?.route_preparation_key:null;
const prepare=async()=>{
if(!cache||!robot||points.length<2)return;
const stamp=generation.current,snapshot=signature;
setSubmitting(true);
try {
const next=await polygonRequest<RoutePreparation>("/route-preparations",{method:"POST",body:JSON.stringify({
cache_key:cache.key,robot_id:robot.robot_id,robot_sha256:robot.sha256,points,
})});
if(stamp===generation.current && current.current===snapshot)setJob(next);
} catch(caught) {if(stamp===generation.current)error.current((caught as Error).message);}
finally {if(stamp===generation.current)setSubmitting(false);}
};
return {route,key:key??null,prepare,busy:submitting||!!job&&["queued","preparing"].includes(job.status)};
}