Skip to main content

subscribe_image

Signature:

BoosterRobot.subscribe_image(
callback: Callable[[AnyImage], None],
*,
camera_id: str = "",
img_type: ImageType = "rgb",
queue_size: int = 0,
overflow: OverflowPolicy = "drop_oldest",
) -> SensorSubscription

Description:

Subscribe to RGB or depth image updates. When data arrives, the callback receives an AnyImage object.

Parameters:

Parameter

Type

Default

Description

callback

Callable[[AnyImage], None]

Required

Image callback function; receives an AnyImage argument.

camera_id

str

""

Camera ID; leave empty to use the default camera. For the available IDs, refer to the camera sensors returned by "list_sensors".

img_type

ImageType

"rgb"

Image type; see "Sensor and State Data / ImageType".

queue_size

int

0

Pending callback queue size; 0 means unlimited.

overflow

OverflowPolicy

"drop_oldest"

Policy when the queue is full; see "Tasks and Subscriptions / OverflowPolicy".

Returns:

SensorSubscription, see "Tasks and Subscriptions / SensorSubscription"

Raises:

ValueError: img_type is not a supported image type.

Example:

import time
from boosteros.robots.booster import BoosterRobot
from boosteros.types import AnyImage

robot = BoosterRobot()

def on_image(image: AnyImage) -> None:
print(image.width, image.height)
# Example output: 320 240

sub = robot.subscribe_image(on_image)
try:
time.sleep(2.0)
finally:
sub.unsubscribe()