Stream tracks
StreamTracks emits the set of currently tracked objects as it updates. By default you receive the
filtered track set (the configured operational filter); set unfiltered to receive the raw fused
set.
Before you begin
You need an authenticated channel — see Authenticate.
stream_tracks.py
from greenroom.perception.v1 import perception_service_pb2, perception_service_pb2_grpc
from greenroom.perception.v1 import classification_pb2
client = perception_service_pb2_grpc.PerceptionServiceStub(channel)
request = perception_service_pb2.StreamTracksRequest(vessel_id="vessel_1")
for response in client.StreamTracks(request):
for obj in response.tracks.objects:
cls = obj.classification[0].classification if obj.classification else None
name = classification_pb2.ObjectClass.Name(cls) if cls is not None else "—"
print(f"{obj.id} {name} range={obj.range:.0f}m bearing={obj.bearing:.0f}°")
Filtering on size and class
Classification and physical extent (obj.shape) let you filter for the objects you care about; the
same criteria are expressed declaratively in ObjectsFilter, used by
object alerts.
Optional fields may be absent
bearing and range are declared optional — check presence (obj.HasField("range")) before
reading them, rather than trusting a 0.
What's next
- Configure object alerts — react to objects appearing or being lost.
- Streaming and reconnection — keep the stream alive.