robokudo.annotators.annotation_writer

Annotation writer classes for RoboKudo.

This module provides annotators for writing and publishing annotations.

Classes

AnnotationStorageWriter

Annotator for writing annotations to storage in JSON format.

AnnotationPublisherWriter

Annotator for publishing annotations via ROS topics.

Module Contents

class robokudo.annotators.annotation_writer.AnnotationStorageWriter(name: str = 'AnnotationStorageWriter', descriptor: AnnotationStorageWriter = Descriptor())

Bases: robokudo.annotators.core.BaseAnnotator

Annotator for writing annotations to storage in JSON format.

This annotator writes the current CAS annotations to files in a specified directory, using JSON serialization.

class Descriptor

Bases: robokudo.annotators.core.BaseAnnotator.Descriptor

Configuration descriptor for annotation storage writer.

class Parameters

Parameters for configuring annotation storage.

basic_path: str = 'annotations'

Base directory for storing annotations, defaults to “annotations

suffix: str = 'json'

File extension for annotation files, defaults to “json

parameters
counter: int = -1

Counter for generating sequential filenames

update() py_trees.common.Status

Write current CAS annotations to storage.

Serializes the current annotations to JSON and writes them to a file in the configured directory. Files are numbered sequentially.

Returns:

SUCCESS after writing annotations

class robokudo.annotators.annotation_writer.AnnotationPublisherWriter(name: str = 'AnnotationPublisherWriter', descriptor: AnnotationPublisherWriter = Descriptor())

Bases: robokudo.annotators.core.BaseAnnotator

Annotator for publishing annotations via ROS topics.

This annotator publishes the current CAS annotations as JSON-encoded strings over a ROS topic.

class Descriptor

Bases: robokudo.annotators.core.BaseAnnotator.Descriptor

Configuration descriptor for annotation publisher.

class Parameters

Parameters for configuring annotation publishing.

topic_name: str = '/annotations'

Name of the ROS topic to publish on, defaults to “/annotations

parameters
pub: typing_extensions.Optional[rclpy.publisher.Publisher] = None

ROS publisher for annotations

setup(timeout: float) None

Set up the ROS2 publisher for annotation messages.

Parameters:

timeout – Maximum time to wait for setup completion

update() py_trees.common.Status

Publish current CAS annotations.

Serializes the current annotations to JSON and publishes them on the configured ROS topic.

Returns:

SUCCESS after publishing annotations