perf(lab): stream sealed spatial playback tracks
This commit is contained in:
@@ -6,6 +6,7 @@ import { createServer } from "vite";
|
||||
|
||||
let server;
|
||||
let fetchM49TgsFullShadowSpatialChunk;
|
||||
let parseM49TgsNpyTrack;
|
||||
|
||||
const resultId = `m49-tgs-full-shadow-${"a".repeat(64)}`;
|
||||
|
||||
@@ -15,7 +16,7 @@ before(async () => {
|
||||
logLevel: "silent",
|
||||
server: { middlewareMode: true },
|
||||
});
|
||||
({ fetchM49TgsFullShadowSpatialChunk } = await server.ssrLoadModule(
|
||||
({ fetchM49TgsFullShadowSpatialChunk, parseM49TgsNpyTrack } = await server.ssrLoadModule(
|
||||
"/src/core/laboratory/m49TgsFullShadow.ts",
|
||||
));
|
||||
});
|
||||
@@ -73,7 +74,7 @@ test("M4.9T5 chunk keeps every missing-LiDAR cell explicitly UNOBSERVED", async
|
||||
assert.deepEqual(new Set(chunk.frames[0].costmap.states), new Set([0]));
|
||||
});
|
||||
|
||||
test("M4.9T5 viewer prefetches 24-frame immutable chunks", async () => {
|
||||
test("M4.9T5 viewer preloads one immutable binary playback pack", async () => {
|
||||
const [source, contract] = await Promise.all([
|
||||
readFile(
|
||||
new URL("../src/workspaces/laboratory/M49TgsFullShadowEvidence.tsx", import.meta.url),
|
||||
@@ -84,12 +85,37 @@ test("M4.9T5 viewer prefetches 24-frame immutable chunks", async () => {
|
||||
"utf8",
|
||||
),
|
||||
]);
|
||||
assert.match(source, /const CHUNK_FRAMES = 24/);
|
||||
assert.match(source, /activeChunkStart \+ CHUNK_FRAMES/);
|
||||
assert.match(source, /fetchM49TgsFullShadowSpatialChunk/);
|
||||
assert.match(source, /fetchM49TgsFullShadowPlaybackPack/);
|
||||
assert.match(source, /playbackProgress/);
|
||||
assert.doesNotMatch(source, /fetchM49TgsFullShadowSpatialChunk/);
|
||||
assert.match(source, /sampleAvailable: spatial\.sampleAvailable/);
|
||||
assert.match(source, /fetchE47SemanticSlamResult/);
|
||||
assert.match(source, /next\.baseM4ResultId !== result\.source\.linkedVisualResultId/);
|
||||
assert.match(source, /semantic=\{semantic \? \{/);
|
||||
assert.match(contract, /linked_semantic_result_id/);
|
||||
assert.match(contract, /missioncore\.m49-tgs-full-shadow-playback\/v1/);
|
||||
});
|
||||
|
||||
function npyFloat32(values, shape) {
|
||||
const shapeText = shape.length === 1 ? `${shape[0]},` : shape.join(", ");
|
||||
const prefixLength = 10;
|
||||
let header = `{'descr': '<f4', 'fortran_order': False, 'shape': (${shapeText}), }`;
|
||||
const padding = (16 - ((prefixLength + header.length + 1) % 16)) % 16;
|
||||
header += " ".repeat(padding) + "\n";
|
||||
const buffer = new ArrayBuffer(prefixLength + header.length + values.length * 4);
|
||||
const bytes = new Uint8Array(buffer);
|
||||
bytes.set([0x93, 0x4e, 0x55, 0x4d, 0x50, 0x59, 1, 0]);
|
||||
new DataView(buffer).setUint16(8, header.length, true);
|
||||
bytes.set(new TextEncoder().encode(header), prefixLength);
|
||||
new Float32Array(buffer, prefixLength + header.length, values.length).set(values);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
test("M4.9T5 parses sealed NPY tracks without JSON point arrays", () => {
|
||||
const parsed = parseM49TgsNpyTrack(
|
||||
npyFloat32([1.25, -2.5, 3.75, 4.5], [2, 2]),
|
||||
"<f4",
|
||||
[2, 2],
|
||||
);
|
||||
assert.deepEqual([...parsed], [1.25, -2.5, 3.75, 4.5]);
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@ let fetchM4ThreatVisual;
|
||||
let fetchM4ThreatTimeline;
|
||||
let fetchM4ThreatTimelineChunk;
|
||||
let fetchM4ThreatCameraPointOverlay;
|
||||
let hydrateM4ThreatTimelineFrame;
|
||||
let selectM4ThreatTimelineFrame;
|
||||
let selectM4ThreatTimelineSequence;
|
||||
let advanceRecordedEvidencePlayback;
|
||||
@@ -33,6 +34,7 @@ before(async () => {
|
||||
fetchM4ThreatTimeline,
|
||||
fetchM4ThreatTimelineChunk,
|
||||
fetchM4ThreatCameraPointOverlay,
|
||||
hydrateM4ThreatTimelineFrame,
|
||||
selectM4ThreatTimelineFrame,
|
||||
selectM4ThreatTimelineSequence,
|
||||
} = await server.ssrLoadModule("/src/core/laboratory/m4ReplayThreat.ts"));
|
||||
@@ -332,6 +334,45 @@ test("M4.6 timeline keeps only a compact index and decodes bounded spatial chunk
|
||||
assert.equal(selectM4ThreatTimelineFrame(chunk.frames, 35.50).sequence, 1);
|
||||
});
|
||||
|
||||
test("M4.6 hydrates a lightweight timeline frame from one retained binary point track", async () => {
|
||||
const raw = timelineFrame(0, 35.421857292, {
|
||||
body_frame: {
|
||||
origin_map_xyz_m: [10, 20, 30],
|
||||
basis_map_from_body: [[1, 0, 0], [0, 1, 0], [0, 0, 1]],
|
||||
},
|
||||
point_cloud_body_xyz_m: [],
|
||||
point_cloud_source_count: 2,
|
||||
point_cloud_sample_count: 2,
|
||||
});
|
||||
const parsed = await fetchM4ThreatTimelineChunk(resultId, 0, 1, {
|
||||
playbackPointPack: {
|
||||
resultId,
|
||||
frameCount: 4489,
|
||||
pointCount: 2,
|
||||
pointOffsets: new Uint32Array([0, 2, ...Array(4488).fill(2)]),
|
||||
pointsMapXyzM: new Float32Array([11, 20, 30.25, 12, 19.5, 30]),
|
||||
},
|
||||
fetcher: async (input) => {
|
||||
assert.match(String(input), /include_points=false/);
|
||||
return new Response(JSON.stringify({
|
||||
schema_version: "missioncore.recorded-spatial-evidence-chunk/v1",
|
||||
result_id: resultId,
|
||||
start_sequence: 0,
|
||||
frame_count: 1,
|
||||
next_sequence: 1,
|
||||
frames: [raw],
|
||||
authority: "replay-simulated",
|
||||
}), { status: 200 });
|
||||
},
|
||||
});
|
||||
assert.deepEqual(parsed.frames[0].pointCloudBodyXyzM, [
|
||||
[1, 0, 0.25],
|
||||
[2, -0.5, 0],
|
||||
]);
|
||||
assert.equal(parsed.frames[0].pointCloudSampleCount, 2);
|
||||
assert.equal(typeof hydrateM4ThreatTimelineFrame, "function");
|
||||
});
|
||||
|
||||
test("M4.8S timeline binds factory-KB4 camera points through its exact endpoint", async () => {
|
||||
const replayResultId = `m48s-fixed-class-detector-lab-${"b".repeat(64)}`;
|
||||
const endpointRoot = "/api/v1/laboratory/m48s/fixed-class-detector";
|
||||
|
||||
Reference in New Issue
Block a user