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 |
|---|---|---|---|
|
| Required | Image callback function; receives an |
|
|
| Camera ID; leave empty to use the default camera. For the available IDs, refer to the camera sensors returned by "list_sensors". |
|
|
| Image type; see "Sensor and State Data / ImageType". |
|
|
| Pending callback queue size; |
|
|
| 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()