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='AnnotationStorageWriter', descriptor=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.

Variables:

counter – Counter for generating sequential filenames

class Descriptor

Bases: robokudo.annotators.core.BaseAnnotator.Descriptor

Configuration descriptor for annotation storage writer.

class Parameters

Parameters for configuring annotation storage.

Variables:
  • basic_path – Base directory for storing annotations, defaults to “annotations”

  • suffix – File extension for annotation files, defaults to “json”

basic_path = 'annotations'
suffix = 'json'
parameters
counter = -1
update()

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

Return type:

py_trees.common.Status

class robokudo.annotators.annotation_writer.AnnotationPublisherWriter(name='AnnotationPublisherWriter', descriptor=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.

Variables:

pub – ROS publisher for annotations

class Descriptor

Bases: robokudo.annotators.core.BaseAnnotator.Descriptor

Configuration descriptor for annotation publisher.

class Parameters

Parameters for configuring annotation publishing.

Variables:

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

topic_name = '/annotations'
parameters
pub = None
setup(timeout)

Set up the ROS publisher. Useful for delayed initialization. For example ROS pub/sub, drivers.

Parameters:

timeout (float) – Maximum time to wait for setup completion

Returns:

True if setup was successful

Return type:

bool

update()

Publish current CAS annotations.

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

Returns:

SUCCESS after publishing annotations

Return type:

py_trees.common.Status