scene_service.state

scene_service.state — object registry and data association. All shared mutable state lives here behind a single asyncio.Lock owned by ObjectRegistry. Geometric relations moved to scene_graph/geometry.py (judgment) + scene_graph/geometric_loop.py (runtime), which feed the Pilot-facing scene-graph store.

class scene_service.state.BBox3D(size_x: float = 0.1, size_y: float = 0.1, size_z: float = 0.1, yaw: float = 0.0, frame_id: str = '')[source]

Bases: object

Axis-aligned bounding box in frame_id, centered on the object pose.

frame_id: str = ''
property half_x: float
property half_y: float
size_x: float = 0.1
size_y: float = 0.1
size_z: float = 0.1
yaw: float = 0.0
class scene_service.state.Detection(label: str, pose: Pose3D, bbox: BBox3D, confidence: float, source: str = 'perception')[source]

Bases: object

One per-frame perception output; pose and bbox share one frame.

bbox: BBox3D
confidence: float
label: str
pose: Pose3D
source: str = 'perception'
class scene_service.state.ObjectRegistry(*, grace_period_s: float = 5.0)[source]

Bases: object

Async-safe object store.

all_objects() → Iterable[SceneObject][source]
clear_derived_objects() → int[source]

Delete non-robot objects.

clear_object_label_override(object_id: str) → SceneObject[source]

Restore the model-owned label state captured before operator edit.

clear_objects() → int[source]

Drop every object.

delete_derived_object(object_id: str) → SceneObject[source]

Delete one non-robot object or raise a precise lookup error.

find_rebindable(label: str, pose: Pose3D, max_d: float, *, only_missing: bool = False, exclude_oids: Iterable[str] | None = None) → SceneObject | None[source]

Nearest non-robot, non-restored record of class label whose centroid is within max_d of pose, else None.

get_object(oid: str) → SceneObject | None[source]
insert_object(label: str, pose: Pose3D, bbox: BBox3D, confidence: float, now: float, *, is_robot: bool = False, source: str = 'perception') → SceneObject[source]

Allocate a new SceneObject. Caller must hold self._lock.

lock() → Lock[source]
mark_stale(now: float) → int[source]

Set missing=True on objects past the grace period.

merge_duplicates(now: float, *, xy_m: float = 0.35, z_m: float = 1.2, max_merges: int = 64) → list[tuple[str, str]][source]

Fold same-class records that describe one object into one record.

prune_expired(now: float, ttl_s: float, *, merge_dist_m: float = 0.0) → list[str][source]

Hard-delete missing perception records whose last_seen is older than ttl_s; returns the deleted object_ids.

resolve_id(object_id: str, *, follow_inferred: bool = True) → tuple[str | None, dict | None][source]

Map a possibly-stale id to the live id that now stands for it.

restore_object(obj: SceneObject) → None[source]

Re-insert a persisted object verbatim under its existing object_id (warm restore at boot).

set_object_caption(object_id: str, caption: str, *, source: str, now: float) → SceneObject[source]

Describe one object, or clear the description with an empty string.

async snapshot() → dict[str, SceneObject][source]

Atomic shallow copy.

soft_evict(obj: SceneObject) → None[source]

Mark a perception record missing and release its concept-graphs uuid binding instead of deleting it, so a later re-detection can re-bind the same id (and accumulated observation_count) via find_rebindable.

stats() → dict[str, int][source]
update_object_geometry(object_id: str, pose: Pose3D, bbox: BBox3D) → SceneObject[source]

Install a provenance-marked, deliberately non-nav operator bbox.

update_object_label(object_id: str, label: str) → SceneObject[source]

Apply a sticky operator-owned semantic label correction.

update_object_pose(obj: SceneObject, new_pose: Pose3D, new_confidence: float, now: float, *, ema_pose: float = 0.3, ema_conf: float = 0.3) → None[source]

EMA-blend new observation into the existing record.

class scene_service.state.Pose3D(x: 'float', y: 'float', z: 'float', yaw: 'float' = 0.0, frame_id: 'str' = '')[source]

Bases: object

frame_id: str = ''
x: float
y: float
yaw: float = 0.0
z: float
class scene_service.state.SceneObject(object_id: str, label: str, pose: Pose3D, bbox: BBox3D, confidence: float, first_seen: float, last_seen: float, observation_count: int = 1, missing: bool = False, caption: str = '', caption_updated_at: float = 0.0, caption_source: str = '', attributes: dict[str, object]=<factory>)[source]

Bases: object

Stable object record.

attributes: dict[str, object]
bbox: BBox3D
caption: str = ''
caption_source: str = ''
caption_updated_at: float = 0.0
property cls: str

the class is label.

Type:

Deprecated

confidence: float
property display_name: str

class plus this object’s number.

Type:

The short heading for one row

first_seen: float
label: str
last_seen: float
missing: bool = False
object_id: str
observation_count: int = 1
pose: Pose3D
property settled: bool

not the robot and not a provisional label. A remembered object counts though it is out of view (a loaded map’s objects all are). What the map pages and the captioner show; the rest is the registry’s working state, for the debug view.

Type:

Part of the semantic map

scene_service.state.associate(registry: ObjectRegistry, detections: list[Detection], *, now: float | None = None) → tuple[list[str], list[str]][source]

Match detections to registry objects in place; returns (matched_ids, new_ids). Caller holds registry.lock(). Unmatched objects are left to mark_stale.

Modules

data_assoc

Associate per-frame detections with registry objects: same-class, gated Hungarian matching; matches EMA-update the object, the rest become new objects.

object_registry

SceneObject registry — the canonical store for everything system/scene tracks about the world.