perf(lab): stream sealed spatial playback tracks
This commit is contained in:
@@ -344,6 +344,27 @@ class RecordedGeometryStore:
|
||||
points.setflags(write=False)
|
||||
return points
|
||||
|
||||
def playback_points_map(self) -> FloatArray:
|
||||
"""Expose the sealed contiguous map-point track for binary LAB playback.
|
||||
|
||||
The returned array is the exact source-pack point index space. It is
|
||||
read-only and deliberately excludes any UI projection or resampling so
|
||||
the browser can retain it once and derive the current increment by the
|
||||
verified offsets below.
|
||||
"""
|
||||
|
||||
points = np.asarray(self._source["cloud_points_map"], dtype=np.dtype("<f4"))
|
||||
if not points.flags.c_contiguous:
|
||||
raise GeometryProviderError("source playback point track is not contiguous")
|
||||
points.setflags(write=False)
|
||||
return points
|
||||
|
||||
def playback_point_offsets(self) -> tuple[int, ...]:
|
||||
"""Return immutable offsets into :meth:`playback_points_map`."""
|
||||
|
||||
offsets = np.asarray(self._source["cloud_offsets"], dtype=np.int64)
|
||||
return tuple(int(value) for value in offsets)
|
||||
|
||||
def point_step_candidates_for_frame(self, frame_index: int) -> UInt8Array | None:
|
||||
"""Expose the sealed low-step diagnostic in the source point index space.
|
||||
|
||||
|
||||
@@ -150,14 +150,23 @@ class RecordedThreatTimeline:
|
||||
"access": "read-only-bounded-recorded-replay",
|
||||
}
|
||||
|
||||
def chunk(self, *, start_sequence: int, frame_count: int) -> dict[str, object]:
|
||||
def chunk(
|
||||
self,
|
||||
*,
|
||||
start_sequence: int,
|
||||
frame_count: int,
|
||||
include_points: bool = True,
|
||||
) -> dict[str, object]:
|
||||
if not 0 <= start_sequence < len(self.index.offsets):
|
||||
raise RecordedThreatTimelineError("recorded timeline chunk start is invalid")
|
||||
if not 1 <= frame_count <= RECORDED_SPATIAL_MAX_CHUNK_FRAMES:
|
||||
raise RecordedThreatTimelineError("recorded timeline chunk size is invalid")
|
||||
stop = min(len(self.index.offsets), start_sequence + frame_count)
|
||||
with self._lock:
|
||||
frames = [self._project_frame(sequence) for sequence in range(start_sequence, stop)]
|
||||
frames = [
|
||||
self._project_frame(sequence, include_points=include_points)
|
||||
for sequence in range(start_sequence, stop)
|
||||
]
|
||||
return {
|
||||
"schema_version": RECORDED_SPATIAL_CHUNK_SCHEMA,
|
||||
"result_id": self.result.result_id,
|
||||
@@ -170,7 +179,12 @@ class RecordedThreatTimeline:
|
||||
"access": "read-only-bounded-recorded-replay",
|
||||
}
|
||||
|
||||
def _project_frame(self, sequence: int) -> dict[str, object]:
|
||||
def _project_frame(
|
||||
self,
|
||||
sequence: int,
|
||||
*,
|
||||
include_points: bool,
|
||||
) -> dict[str, object]:
|
||||
row = _read_frame_at(self.frames_path, self.index, sequence)
|
||||
frame_id = row.get("frame_id")
|
||||
if not isinstance(frame_id, str) or not frame_id:
|
||||
@@ -193,11 +207,13 @@ class RecordedThreatTimeline:
|
||||
raise RecordedThreatTimelineError(
|
||||
"recorded timeline current increment binding changed"
|
||||
)
|
||||
point_cloud, point_source_count = sample_points_in_body_frame(
|
||||
points,
|
||||
body_frame,
|
||||
point_limit=RECORDED_SPATIAL_POINT_LIMIT,
|
||||
)
|
||||
point_source_count = int(points.shape[0])
|
||||
if include_points:
|
||||
point_cloud, point_source_count = sample_points_in_body_frame(
|
||||
points,
|
||||
body_frame,
|
||||
point_limit=RECORDED_SPATIAL_POINT_LIMIT,
|
||||
)
|
||||
metric_visuals = project_metric_obstacles_to_body(
|
||||
_mapping_array(row.get("metric_obstacles"), "metric obstacles"),
|
||||
body_frame,
|
||||
@@ -219,13 +235,13 @@ class RecordedThreatTimeline:
|
||||
if body_frame is None
|
||||
else {
|
||||
"origin_map_xyz_m": list(body_frame.origin_map_xyz_m),
|
||||
"basis_map_from_body": [
|
||||
list(row) for row in body_frame.basis_map_from_body
|
||||
],
|
||||
"basis_map_from_body": [list(row) for row in body_frame.basis_map_from_body],
|
||||
},
|
||||
"point_cloud_body_xyz_m": point_cloud,
|
||||
"point_cloud_source_count": point_source_count,
|
||||
"point_cloud_sample_count": len(point_cloud),
|
||||
"point_cloud_sample_count": point_source_count
|
||||
if not include_points
|
||||
else len(point_cloud),
|
||||
"point_cloud_layer": "current-increment",
|
||||
"rolling_map_component_count": sum(
|
||||
item.get("state") == "retained" for item in metric_visuals
|
||||
|
||||
Reference in New Issue
Block a user