Skip to content

blueye.sdk.guestport

guestport

Classes:

  • GenericServo –

    Represents a Blueye generic servo connected to a guest port on the Blueye drone.

  • Gripper –

    Represents a gripper connected to a guest port on the Blueye drone.

  • GuestPort –

    State of one guest port connector on the drone.

  • GuestPortCamera –

    Represents a camera connected to a guest port on the Blueye drone.

  • GuestPortLight –

    Represents a light connected to a guest port on the Blueye drone.

  • Laser –

    Represents a scaling laser connected to a guest port on the Blueye drone.

  • Peripheral –

    Represents a peripheral device connected to a guest port on the Blueye drone.

  • SkidServo –

    Represents the tilt servo for a multibeam sonar.

Functions:

GenericServo

GenericServo(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
)

Represents a Blueye generic servo connected to a guest port on the Blueye drone.

The servo takes a position between 0 and 1, where 0 and 1 are the end stops. What that is in degrees depends on the servo. The drone drives generic servos on guest ports 1 to 3 and reports each one in its own GenericServoTel, which the SDK keeps per port.

Parameters:

Methods:

  • get_angle –

    Get the current position of the servo as an angle in degrees.

  • get_detach_status –

    Get the current attach state of a detachable device.

  • get_position –

    Get the current position of the servo.

  • get_set_point –

    Get the position the servo is moving towards.

  • set_angle –

    Set the position of the servo from an angle in degrees.

  • set_position –

    Set the position of the servo.

Attributes:

Source code in blueye/sdk/guestport.py
463
464
465
466
467
468
469
470
471
472
473
474
475
476
def __init__(
    self, parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
):
    """Initialize the Servo class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.
    """

    self.max_angle = 90
    self.min_angle = -90
    Peripheral.__init__(self, parent_drone, port_number, device)

compatible_guest_ports instance-attribute

compatible_guest_ports: List[GuestPortNumber] = list(
    compatible_guest_ports
)

Ports on this drone where the device is fully supported.

Computed by the drone from the port capabilities and the device requirements.

required_capabilities instance-attribute

required_capabilities: List[GuestPortCapability] = list(
    required_capabilities
)

Interfaces the device requires from the port it is connected to.

get_angle

get_angle() -> Optional[float]

Get the current position of the servo as an angle in degrees.

Deprecated, the servo reports a position and not an angle. Use get_position. Position 0 maps to -90, 0.5 to 0 and 1 to 90.

Returns:

  • Optional[float] –

    The angle (-90..90), or None if the drone has not reported the position.

Source code in blueye/sdk/guestport.py
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
def get_angle(self) -> Optional[float]:
    """Get the current position of the servo as an angle in degrees.

    Deprecated, the servo reports a position and not an angle. Use
    [`get_position`][blueye.sdk.guestport.GenericServo.get_position]. Position 0 maps to
    -90, 0.5 to 0 and 1 to 90.

    Returns:
        The angle (-90..90), or None if the drone has not reported the position.
    """
    warnings.warn(
        "`GenericServo.get_angle` is deprecated and will be removed in the next major "
        "version. Use `GenericServo.get_position()`, which returns the 0..1 position.",
        DeprecationWarning,
        stacklevel=2,
    )
    position = self.get_position()
    if position is None:
        return None
    return self.min_angle + position * (self.max_angle - self.min_angle)

get_detach_status

get_detach_status() -> GuestPortDetachStatus

Get the current attach state of a detachable device.

The state is read from the latest drone info telemetry so it follows the device being attached or detached during a session. If no newer telemetry is available, the state reported when the peripheral was discovered is returned.

Returns:

  • GuestPortDetachStatus –

    The detach status. GUEST_PORT_DETACH_STATUS_UNSPECIFIED for devices that cannot be detached.

Source code in blueye/sdk/guestport.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def get_detach_status(self) -> bp.GuestPortDetachStatus:
    """Get the current attach state of a detachable device.

    The state is read from the latest drone info telemetry so it follows the device being
    attached or detached during a session. If no newer telemetry is available, the state
    reported when the peripheral was discovered is returned.

    Returns:
        The detach status. `GUEST_PORT_DETACH_STATUS_UNSPECIFIED` for devices that cannot be
        detached.
    """
    drone_info_tel = self.parent_drone.telemetry.get(bp.DroneInfoTel)
    if drone_info_tel is not None:
        device = _find_device(drone_info_tel.drone_info.gp, self)
        if device is not None:
            return device.detach_status
    return self._detach_status

get_position

get_position() -> Optional[float]

Get the current position of the servo.

Returns:

  • Optional[float] –

    The position (0..1), or None if the drone has not reported it.

Source code in blueye/sdk/guestport.py
506
507
508
509
510
511
512
513
514
515
def get_position(self) -> Optional[float]:
    """Get the current position of the servo.

    Returns:
        The position (0..1), or None if the drone has not reported it.
    """
    telemetry_msg = self._get_telemetry()
    if telemetry_msg is None:
        return None
    return telemetry_msg.servo.value

get_set_point

get_set_point() -> Optional[float]

Get the position the servo is moving towards.

Returns:

  • Optional[float] –

    The commanded position (0..1), or None if the drone has not reported it.

Source code in blueye/sdk/guestport.py
517
518
519
520
521
522
523
524
525
526
def get_set_point(self) -> Optional[float]:
    """Get the position the servo is moving towards.

    Returns:
        The commanded position (0..1), or None if the drone has not reported it.
    """
    telemetry_msg = self._get_telemetry()
    if telemetry_msg is None:
        return None
    return telemetry_msg.set_point

set_angle

set_angle(angle: float) -> None

Set the position of the servo from an angle in degrees.

Deprecated, the servo takes a position and not an angle. Use set_position. -90 maps to 0, 0 to 0.5 and 90 to 1, which is what the old degree calls drove the servo to.

Parameters:

  • angle (float) –

    The angle (-90..90), mapped linearly onto the 0..1 position.

Raises:

  • ValueError –

    If the angle is not within the allowed range.

Source code in blueye/sdk/guestport.py
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
def set_angle(self, angle: float) -> None:
    """Set the position of the servo from an angle in degrees.

    Deprecated, the servo takes a position and not an angle. Use
    [`set_position`][blueye.sdk.guestport.GenericServo.set_position]. -90 maps to 0, 0 to
    0.5 and 90 to 1, which is what the old degree calls drove the servo to.

    Args:
        angle (float): The angle (-90..90), mapped linearly onto the 0..1 position.

    Raises:
        ValueError: If the angle is not within the allowed range.
    """
    warnings.warn(
        "`GenericServo.set_angle` is deprecated and will be removed in the next major "
        "version. Use `GenericServo.set_position()` with a 0..1 position instead.",
        DeprecationWarning,
        stacklevel=2,
    )
    if not self.min_angle <= angle <= self.max_angle:
        raise ValueError(
            f"Angle must be between {self.min_angle} and {self.max_angle} degrees."
        )
    self.set_position((angle - self.min_angle) / (self.max_angle - self.min_angle))

set_position

set_position(position: float) -> None

Set the position of the servo.

Parameters:

  • position (float) –

    The position (0..1), where 0 and 1 are the end stops.

Raises:

  • ValueError –

    If the position is not between 0 and 1.

Source code in blueye/sdk/guestport.py
478
479
480
481
482
483
484
485
486
487
488
489
def set_position(self, position: float) -> None:
    """Set the position of the servo.

    Args:
        position (float): The position (0..1), where 0 and 1 are the end stops.

    Raises:
        ValueError: If the position is not between 0 and 1.
    """
    if not 0 <= position <= 1:
        raise ValueError(f"Position must be between 0 and 1, got {position}")
    self.parent_drone._ctrl_client.set_generic_servo_position(position, self.port_number)

Gripper

Gripper(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
)

Represents a gripper connected to a guest port on the Blueye drone.

Parameters:

Methods:

Attributes:

Source code in blueye/sdk/guestport.py
221
222
223
224
225
226
227
228
229
230
231
232
233
def __init__(
    self, parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
):
    """Initialize the Gripper class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.
    """
    Peripheral.__init__(self, parent_drone, port_number, device)
    self._grip_velocity = 0
    self._rotation_velocity = 0

compatible_guest_ports instance-attribute

compatible_guest_ports: List[GuestPortNumber] = list(
    compatible_guest_ports
)

Ports on this drone where the device is fully supported.

Computed by the drone from the port capabilities and the device requirements.

required_capabilities instance-attribute

required_capabilities: List[GuestPortCapability] = list(
    required_capabilities
)

Interfaces the device requires from the port it is connected to.

get_detach_status

get_detach_status() -> GuestPortDetachStatus

Get the current attach state of a detachable device.

The state is read from the latest drone info telemetry so it follows the device being attached or detached during a session. If no newer telemetry is available, the state reported when the peripheral was discovered is returned.

Returns:

  • GuestPortDetachStatus –

    The detach status. GUEST_PORT_DETACH_STATUS_UNSPECIFIED for devices that cannot be detached.

Source code in blueye/sdk/guestport.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def get_detach_status(self) -> bp.GuestPortDetachStatus:
    """Get the current attach state of a detachable device.

    The state is read from the latest drone info telemetry so it follows the device being
    attached or detached during a session. If no newer telemetry is available, the state
    reported when the peripheral was discovered is returned.

    Returns:
        The detach status. `GUEST_PORT_DETACH_STATUS_UNSPECIFIED` for devices that cannot be
        detached.
    """
    drone_info_tel = self.parent_drone.telemetry.get(bp.DroneInfoTel)
    if drone_info_tel is not None:
        device = _find_device(drone_info_tel.drone_info.gp, self)
        if device is not None:
            return device.detach_status
    return self._detach_status

get_grip_velocity

get_grip_velocity() -> float

Get the current grip velocity of the Gripper.

Returns:

  • float –

    The current grip velocity of the Gripper.

Source code in blueye/sdk/guestport.py
235
236
237
238
239
240
241
def get_grip_velocity(self) -> float:
    """Get the current grip velocity of the Gripper.

    Returns:
        The current grip velocity of the Gripper.
    """
    return self._grip_velocity

get_rotation_velocity

get_rotation_velocity() -> float

Get the current rotation velocity of the Gripper.

Returns:

  • float –

    The current rotation velocity of the Gripper.

Source code in blueye/sdk/guestport.py
261
262
263
264
265
266
267
def get_rotation_velocity(self) -> float:
    """Get the current rotation velocity of the Gripper.

    Returns:
        The current rotation velocity of the Gripper.
    """
    return self._rotation_velocity

set_grip_velocity

set_grip_velocity(value: float)

Set the current grip velocity of the Gripper.

Parameters:

  • value (float) –

    The new grip velocity to set. Must be a float between -1.0 and 1.0.

Raises:

  • ValueError –

    If the grip velocity is not between -1.0 and 1.0.

Source code in blueye/sdk/guestport.py
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
def set_grip_velocity(self, value: float):
    """Set the current grip velocity of the Gripper.

    Args:
        value (float): The new grip velocity to set. Must be a float between -1.0 and 1.0.

    Raises:
        ValueError: If the grip velocity is not between -1.0 and 1.0.
    """
    if value < -1.0 or value > 1.0:
        raise ValueError("Grip velocity must be between -1.0 and 1.0.")
    self._grip_velocity = value
    self.parent_drone._ctrl_client.set_gripper_velocities(
        self._grip_velocity, self._rotation_velocity
    )

set_rotation_velocity

set_rotation_velocity(value: float)

Set the current rotation velocity of the Gripper.

Parameters:

  • value (float) –

    The new rotation velocity to set. Must be a float between -1.0 and 1.0.

Raises:

  • ValueError –

    If the rotation velocity is not between -1.0 and 1.0.

Source code in blueye/sdk/guestport.py
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
def set_rotation_velocity(self, value: float):
    """Set the current rotation velocity of the Gripper.

    Args:
        value (float): The new rotation velocity to set. Must be a float between -1.0 and 1.0.

    Raises:
        ValueError: If the rotation velocity is not between -1.0 and 1.0.
    """
    if value < -1.0 or value > 1.0:
        raise ValueError("Rotation velocity must be between -1.0 and 1.0.")
    self._rotation_velocity = value
    self.parent_drone._ctrl_client.set_gripper_velocities(
        self._grip_velocity, self._rotation_velocity
    )

GuestPort dataclass

GuestPort(
    number: GuestPortNumber,
    capabilities: List[GuestPortCapability] = list(),
    error: Optional[GuestPortError] = None,
    devices: List[Peripheral] = list(),
)

State of one guest port connector on the drone.

A port either carries a list of devices or reports a connector error, never both. A port with nothing plugged in reports GUEST_PORT_ERROR_NOT_CONNECTED.

Attributes:

capabilities class-attribute instance-attribute

capabilities: List[GuestPortCapability] = field(
    default_factory=list
)

Interfaces this port provides.

devices class-attribute instance-attribute

devices: List[Peripheral] = field(default_factory=list)

Peripherals discovered on this port. Empty when the port reports an error.

error class-attribute instance-attribute

error: Optional[GuestPortError] = None

Connector error reported by the drone, or None when the port carries a device list.

number instance-attribute

Which guest port this is.

GuestPortCamera

GuestPortCamera(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
)

Represents a camera connected to a guest port on the Blueye drone.

Parameters:

Methods:

Attributes:

Source code in blueye/sdk/guestport.py
155
156
157
158
159
160
161
162
163
164
165
166
def __init__(
    self, parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
):
    """Initialize the GuestPortCamera class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.
    """
    Camera.__init__(self, parent_drone, is_guestport_camera=True)
    Peripheral.__init__(self, parent_drone, port_number, device)

compatible_guest_ports instance-attribute

compatible_guest_ports: List[GuestPortNumber] = list(
    compatible_guest_ports
)

Ports on this drone where the device is fully supported.

Computed by the drone from the port capabilities and the device requirements.

required_capabilities instance-attribute

required_capabilities: List[GuestPortCapability] = list(
    required_capabilities
)

Interfaces the device requires from the port it is connected to.

configure

configure(timeout: float = 0.5) -> _ParamsBatch

Return a context manager for batching camera parameter changes.

All attribute assignments on the returned object are accumulated and sent as a single set_camera_parameters request when the with block exits. If an exception is raised inside the block the changes are discarded.

Parameters take the same names and values as the corresponding setters; the protobuf field names and enums are accepted as well.

Parameters:

  • timeout (float, default: 0.5 ) –

    Timeout in seconds for the request. Increase when changing parameters that trigger pipeline restarts (e.g. codec, resolution).

Raises:

  • ValueError –

    If a value is not valid for the parameter being set.

  • RuntimeError –

    If a parameter requires a newer Blunux version than the drone runs.

Usage::

with drone.camera.configure() as params:
    params.recording_codec = bp.RecordingCodec.RECORDING_CODEC_H265
    params.recording_bitrate = 20_000_000
# sent here
Source code in blueye/sdk/camera.py
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
def configure(self, timeout: float = 0.5) -> _ParamsBatch:
    """Return a context manager for batching camera parameter changes.

    All attribute assignments on the returned object are accumulated and sent as a single
    ``set_camera_parameters`` request when the ``with`` block exits.  If an exception is
    raised inside the block the changes are discarded.

    Parameters take the same names and values as the corresponding setters; the protobuf
    field names and enums are accepted as well.

    Args:
        timeout (float, optional): Timeout in seconds for the request. Increase when changing
            parameters that trigger pipeline restarts (e.g. codec, resolution).

    Raises:
        ValueError: If a value is not valid for the parameter being set.
        RuntimeError: If a parameter requires a newer Blunux version than the drone runs.

    Usage::

        with drone.camera.configure() as params:
            params.recording_codec = bp.RecordingCodec.RECORDING_CODEC_H265
            params.recording_bitrate = 20_000_000
        # sent here
    """
    return self._ParamsBatch(self, timeout=timeout)

enable_ehdr

enable_ehdr(enable_ehdr: bool)

Enable or disable the eHDR mode.

Only available on the X3 Ultra and X7.

Parameters:

  • enable_ehdr (bool) –

    True to enable eHDR mode, False to disable it. Enabled by default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
def enable_ehdr(self, enable_ehdr: bool):
    """Enable or disable the eHDR mode.

    Only available on the X3 Ultra and X7.

    Args:
        enable_ehdr (bool): True to enable eHDR mode, False to disable it. Enabled by default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.ehdr_enabled = enable_ehdr
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

get_backlight_compensation

get_backlight_compensation() -> int

Get the camera backlight compensation.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The camera backlight compensation.

Source code in blueye/sdk/camera.py
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
def get_backlight_compensation(self) -> int:
    """Get the camera backlight compensation.

    Only available on the X3 Ultra and X7.

    Returns:
        The camera backlight compensation.
    """
    self._update_camera_parameters()
    return self._camera_parameters.backlight_compensation

get_bitrate

get_bitrate() -> int

Get the video stream bitrate.

Returns:

  • int –

    The H264 video stream bitrate.

Source code in blueye/sdk/camera.py
1124
1125
1126
1127
1128
1129
1130
1131
def get_bitrate(self) -> int:
    """Get the video stream bitrate.

    Returns:
        The H264 video stream bitrate.
    """
    self._update_camera_parameters()
    return self._camera_parameters.h264_bitrate

get_bitrate_still_picture

get_bitrate_still_picture() -> int

Get the bitrate for the still picture stream.

Returns:

  • int –

    The still picture stream bitrate.

Source code in blueye/sdk/camera.py
1147
1148
1149
1150
1151
1152
1153
1154
def get_bitrate_still_picture(self) -> int:
    """Get the bitrate for the still picture stream.

    Returns:
        The still picture stream bitrate.
    """
    self._update_camera_parameters()
    return self._camera_parameters.mjpg_bitrate

get_brightness

get_brightness() -> int

Get the camera brightness.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The camera brightness.

Source code in blueye/sdk/camera.py
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
def get_brightness(self) -> int:
    """Get the camera brightness.

    Only available on the X3 Ultra and X7.

    Returns:
        The camera brightness.
    """
    self._update_camera_parameters()
    return self._camera_parameters.brightness

get_calibration

get_calibration() -> Optional[CameraCalibration]

Get the intrinsic calibration of the camera.

The X3 Ultra and X7 publish the main camera calibration (pinhole model with OpenCV distortion coefficients) in the DroneInfoTel telemetry message. The values are in pixels at the resolution the calibration was computed at, see get_scaled_calibration for a version matching the video resolution. is_default is set when the drone reports the model's built-in calibration rather than one measured for this particular drone.

Older models and the guestport camera do not publish a calibration.

Returns:

  • Optional[CameraCalibration] –

    The camera calibration, or None if the drone has not published one.

Source code in blueye/sdk/camera.py
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
def get_calibration(self) -> Optional[blueye.protocol.CameraCalibration]:
    """Get the intrinsic calibration of the camera.

    The X3 Ultra and X7 publish the main camera calibration (pinhole model with OpenCV
    distortion coefficients) in the `DroneInfoTel` telemetry message. The values are in
    pixels at the resolution the calibration was computed at, see
    [`get_scaled_calibration`][blueye.sdk.camera.Camera.get_scaled_calibration] for a version
    matching the video resolution. `is_default` is set when the drone reports the model's
    built-in calibration rather than one measured for this particular drone.

    Older models and the guestport camera do not publish a calibration.

    Returns:
        The camera calibration, or None if the drone has not published one.
    """
    if self._is_guestport_camera:
        return None
    drone_info = self._parent_drone.get_drone_info()
    if drone_info is None or drone_info.main_camera_calibration._pb.ByteSize() == 0:
        return None
    return drone_info.main_camera_calibration

get_color_correction

get_color_correction() -> Optional[FilterMessage]

Get the color correction filter settings of the main camera.

The color correction filter restores the red and blue balance that water absorbs with depth, driven by the depth and the scene. Only available on the X3 Ultra and X7.

The drone publishes ColorCorrectionTel when the settings change rather than at a fixed rate. The value is the last change seen since connecting, and the drone is asked for its current settings if there has been none.

Returns:

  • Optional[FilterMessage] –

    The filter settings with enabled and intensity (0..1), or None if the drone has not reported any, as is the case for older models and the guestport camera.

Source code in blueye/sdk/camera.py
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
def get_color_correction(self) -> Optional[blueye.protocol.FilterMessage]:
    """Get the color correction filter settings of the main camera.

    The color correction filter restores the red and blue balance that water absorbs with
    depth, driven by the depth and the scene. Only available on the X3 Ultra and X7.

    The drone publishes `ColorCorrectionTel` when the settings change rather than at a fixed
    rate. The value is the last change seen since connecting, and the drone is asked for its
    current settings if there has been none.

    Returns:
        The filter settings with `enabled` and `intensity` (0..1), or None if the drone has
        not reported any, as is the case for older models and the guestport camera.
    """
    if self._is_guestport_camera:
        return None
    tel = self._parent_drone.telemetry.get(blueye.protocol.ColorCorrectionTel)
    if tel is None:
        return None
    return tel.color_correction_filter

get_contrast

get_contrast() -> int

Get the camera contrast.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The camera contrast.

Source code in blueye/sdk/camera.py
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
def get_contrast(self) -> int:
    """Get the camera contrast.

    Only available on the X3 Ultra and X7.

    Returns:
        The camera contrast.
    """
    self._update_camera_parameters()
    return self._camera_parameters.contrast

get_denoise

get_denoise() -> int

Get the camera noise reduction.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The camera noise reduction.

Source code in blueye/sdk/camera.py
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
def get_denoise(self) -> int:
    """Get the camera noise reduction.

    Only available on the X3 Ultra and X7.

    Returns:
        The camera noise reduction.
    """
    self._update_camera_parameters()
    return self._camera_parameters.denoise

get_detach_status

get_detach_status() -> GuestPortDetachStatus

Get the current attach state of a detachable device.

The state is read from the latest drone info telemetry so it follows the device being attached or detached during a session. If no newer telemetry is available, the state reported when the peripheral was discovered is returned.

Returns:

  • GuestPortDetachStatus –

    The detach status. GUEST_PORT_DETACH_STATUS_UNSPECIFIED for devices that cannot be detached.

Source code in blueye/sdk/guestport.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def get_detach_status(self) -> bp.GuestPortDetachStatus:
    """Get the current attach state of a detachable device.

    The state is read from the latest drone info telemetry so it follows the device being
    attached or detached during a session. If no newer telemetry is available, the state
    reported when the peripheral was discovered is returned.

    Returns:
        The detach status. `GUEST_PORT_DETACH_STATUS_UNSPECIFIED` for devices that cannot be
        detached.
    """
    drone_info_tel = self.parent_drone.telemetry.get(bp.DroneInfoTel)
    if drone_info_tel is not None:
        device = _find_device(drone_info_tel.drone_info.gp, self)
        if device is not None:
            return device.detach_status
    return self._detach_status

get_ehdr_exposure_max_number

get_ehdr_exposure_max_number() -> int

Get the maximum number of eHDR frames.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The maximum number of eHDR frames.

Source code in blueye/sdk/camera.py
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
def get_ehdr_exposure_max_number(self) -> int:
    """Get the maximum number of eHDR frames.

    Only available on the X3 Ultra and X7.

    Returns:
        The maximum number of eHDR frames.
    """
    self._update_camera_parameters()
    return self._camera_parameters.ehdr_exposure_max_number

get_ehdr_exposure_min_number

get_ehdr_exposure_min_number() -> int

Get the minimum number of eHDR frames.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The minimum number of eHDR frames.

Source code in blueye/sdk/camera.py
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
def get_ehdr_exposure_min_number(self) -> int:
    """Get the minimum number of eHDR frames.

    Only available on the X3 Ultra and X7.

    Returns:
        The minimum number of eHDR frames.
    """
    self._update_camera_parameters()
    return self._camera_parameters.ehdr_exposure_min_number

get_exposure

get_exposure() -> int

Get the camera exposure.

Returns:

  • int –

    The camera exposure.

Source code in blueye/sdk/camera.py
1172
1173
1174
1175
1176
1177
1178
1179
def get_exposure(self) -> int:
    """Get the camera exposure.

    Returns:
        The camera exposure.
    """
    self._update_camera_parameters()
    return self._camera_parameters.exposure

get_framerate

get_framerate() -> int

Get the camera frame rate.

Raises:

  • RuntimeError –

    If the drone reports a frame rate the SDK does not recognize.

Returns:

  • int –

    The camera frame rate.

Source code in blueye/sdk/camera.py
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
def get_framerate(self) -> int:
    """Get the camera frame rate.

    Raises:
        RuntimeError: If the drone reports a frame rate the SDK does not recognize.

    Returns:
        The camera frame rate.
    """
    self._update_camera_parameters()
    try:
        return _FRAMERATE_TO_FPS[self._camera_parameters.framerate]
    except KeyError:
        raise RuntimeError(
            "Drone reported an unsupported framerate: "
            f"{describe_enum(self._camera_parameters.framerate)}"
        ) from None

get_gain

get_gain() -> float

Get the camera gain.

On the X3 Ultra and X7 the drone reports -1 while auto exposure owns the gain, that is whenever the exposure is automatic or no manual gain has been set.

Returns:

  • float –

    The camera ISO gain (0..1), or -1 when the drone controls it.

Source code in blueye/sdk/camera.py
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
def get_gain(self) -> float:
    """Get the camera gain.

    On the X3 Ultra and X7 the drone reports -1 while auto exposure owns the gain, that is
    whenever the exposure is automatic or no manual gain has been set.

    Returns:
        The camera ISO gain (0..1), or -1 when the drone controls it.
    """
    self._update_camera_parameters()
    return self._camera_parameters.gain

get_gamma

get_gamma() -> int

Get the camera gamma.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The camera gamma.

Source code in blueye/sdk/camera.py
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
def get_gamma(self) -> int:
    """Get the camera gamma.

    Only available on the X3 Ultra and X7.

    Returns:
        The camera gamma.
    """
    self._update_camera_parameters()
    return self._camera_parameters.gamma

get_hue

get_hue() -> int

Get the camera hue.

Only available on Pioneer/Pro/X1/X3, the 4K camera in the X3 Ultra and X7 has no hue control.

Returns:

  • int –

    The camera hue.

Source code in blueye/sdk/camera.py
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
def get_hue(self) -> int:
    """Get the camera hue.

    Only available on Pioneer/Pro/X1/X3, the 4K camera in the X3 Ultra and X7 has no hue
    control.

    Returns:
        The camera hue.
    """
    self._update_camera_parameters()
    return self._camera_parameters.hue

get_mtu_size

get_mtu_size() -> int

Get the network MTU size used for video streaming.

Returns:

  • int –

    The MTU size in bytes (0 if the drone default is used).

Source code in blueye/sdk/camera.py
1853
1854
1855
1856
1857
1858
1859
1860
def get_mtu_size(self) -> int:
    """Get the network MTU size used for video streaming.

    Returns:
        The MTU size in bytes (0 if the drone default is used).
    """
    self._update_camera_parameters()
    return self._camera_parameters.mtu_size

get_pan_tilt_zoom

get_pan_tilt_zoom() -> Optional[CameraPanTiltZoom]

Get the digital pan, tilt and zoom state of the main camera.

The 4K camera in the X3 Ultra and X7 can crop and scale its sensor image, which gives a digital pan, tilt and zoom with no moving parts. The drone reports the state it has applied in CameraPanTiltZoomTel, published when the state changes.

Returns:

  • Optional[CameraPanTiltZoom] –

    The state with pan (-1..1), tilt (-1..1) and zoom (0..1), where 0 is centred and not zoomed, or None if the drone has not reported any, as is the case for older models and the guestport camera.

Source code in blueye/sdk/camera.py
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
def get_pan_tilt_zoom(self) -> Optional[blueye.protocol.CameraPanTiltZoom]:
    """Get the digital pan, tilt and zoom state of the main camera.

    The 4K camera in the X3 Ultra and X7 can crop and scale its sensor image, which gives a
    digital pan, tilt and zoom with no moving parts. The drone reports the state it has
    applied in `CameraPanTiltZoomTel`, published when the state changes.

    Returns:
        The state with `pan` (-1..1), `tilt` (-1..1) and `zoom` (0..1), where 0 is centred and
        not zoomed, or None if the drone has not reported any, as is the case for older
        models and the guestport camera.
    """
    if self._is_guestport_camera:
        return None
    tel = self._parent_drone.telemetry.get(blueye.protocol.CameraPanTiltZoomTel)
    if tel is None:
        return None
    return tel.camera_pan_tilt_zoom

get_record_time

get_record_time() -> Optional[int]

Get the duration of the current camera recording.

Returns:

  • Optional[int] –

    The length in seconds of the current recording, -1 if the camera is not currently recording. Returns None if the SDK hasn't received a RecordState telemetry message.

Source code in blueye/sdk/camera.py
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
def get_record_time(self) -> Optional[int]:
    """Get the duration of the current camera recording.

    Returns:
        The length in seconds of the current recording, -1 if the camera is not currently
        recording. Returns None if the SDK hasn't received a RecordState telemetry message.
    """
    record_state = self._get_record_state()
    if record_state is None:
        return None
    if self._is_guestport_camera:
        return record_state.guestport_seconds
    else:
        return record_state.main_seconds

get_recording_bitrate

get_recording_bitrate() -> int

Get the recording bitrate in bits per second.

A value of 0 means the drone will auto-compute a default bitrate based on the current resolution, framerate, and codec.

Returns:

  • int –

    The current recording bitrate in bits per second (0 if automatic).

Source code in blueye/sdk/camera.py
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
def get_recording_bitrate(self) -> int:
    """Get the recording bitrate in bits per second.

    A value of 0 means the drone will auto-compute a default bitrate based on the current
    resolution, framerate, and codec.

    Returns:
        The current recording bitrate in bits per second (0 if automatic).
    """
    self._update_camera_parameters()
    return self._camera_parameters.recording_bitrate

get_recording_codec

get_recording_codec() -> RecordingCodec

Get the recording video codec.

Returns:

Source code in blueye/sdk/camera.py
1763
1764
1765
1766
1767
1768
1769
1770
def get_recording_codec(self) -> blueye.protocol.RecordingCodec:
    """Get the recording video codec.

    Returns:
        The current recording codec setting.
    """
    self._update_camera_parameters()
    return self._camera_parameters.recording_codec

get_recording_resolution

get_recording_resolution() -> Resolution

Get the camera recording resolution.

For drones running Blunux version < 4.4.1 this is the same as the get_resolution method.

Returns:

Source code in blueye/sdk/camera.py
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
def get_recording_resolution(self) -> blueye.protocol.Resolution:
    """Get the camera recording resolution.

    For drones running Blunux version < 4.4.1 this is the same as the
    [`get_resolution`][blueye.sdk.camera.Camera.get_resolution] method.

    Returns:
        The camera recording resolution.
    """
    self._update_camera_parameters()

    # Drones running Blunux < 4.4 do not support recording resolution so we return the old
    # resolution field instead.
    if version.parse(self._parent_drone.software_version_short) < version.parse("4.4"):
        return self._camera_parameters.resolution
    else:
        return self._camera_parameters.recording_resolution

get_resolution

get_resolution() -> int

Get the camera resolution.

Deprecated

Drones running Blunux 4.4 or newer take the resolution from the stream and recording resolution fields. Use get_stream_resolution and get_recording_resolution instead.

Raises:

  • RuntimeError –

    If the drone reports a resolution the SDK does not recognize.

Returns:

  • int –

    The camera resolution.

Source code in blueye/sdk/camera.py
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
def get_resolution(self) -> int:
    """Get the camera resolution.

    Deprecated:
        Drones running Blunux 4.4 or newer take the resolution from the stream and recording
        resolution fields. Use
        [`get_stream_resolution`][blueye.sdk.camera.Camera.get_stream_resolution] and
        [`get_recording_resolution`][blueye.sdk.camera.Camera.get_recording_resolution]
        instead.

    Raises:
        RuntimeError: If the drone reports a resolution the SDK does not recognize.

    Returns:
        The camera resolution.
    """
    warnings.warn(
        "`Camera.get_resolution` is deprecated, use `Camera.get_stream_resolution` or "
        "`Camera.get_recording_resolution` instead",
        DeprecationWarning,
        stacklevel=2,
    )
    self._update_camera_parameters()
    try:
        return _RESOLUTION_TO_HEIGHT[self._camera_parameters.resolution]
    except KeyError:
        raise RuntimeError(
            "Drone reported an unsupported resolution: "
            f"{describe_enum(self._camera_parameters.resolution)}"
        ) from None

get_saturation

get_saturation() -> int

Get the camera saturation.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The camera saturation.

Source code in blueye/sdk/camera.py
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
def get_saturation(self) -> int:
    """Get the camera saturation.

    Only available on the X3 Ultra and X7.

    Returns:
        The camera saturation.
    """
    self._update_camera_parameters()
    return self._camera_parameters.saturation

get_scaled_calibration

get_scaled_calibration(
    resolution: Union[
        Resolution, Tuple[int, int], None
    ] = None,
) -> Optional[CameraCalibration]

Get the camera calibration scaled to a video resolution.

See scale_calibration for how the values are scaled.

Parameters:

  • resolution (Resolution | tuple[int, int], default: None ) –

    The resolution to scale the calibration to, either as a blueye.protocol.Resolution or as a (width, height) tuple in pixels. A Resolution maps to the frame size the drone's video pipeline produces for it: 640x480 for 480p and 16:9 for the others. Defaults to the current stream resolution.

Raises:

  • ValueError –

    If the resolution is not a blueye.protocol.Resolution or a (width, height) tuple of positive integers.

  • RuntimeError –

    If the drone reports a stream resolution the SDK does not recognize.

Returns:

  • Optional[CameraCalibration] –

    The scaled calibration, or None if the drone has not published one.

Source code in blueye/sdk/camera.py
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
def get_scaled_calibration(
    self,
    resolution: Union[blueye.protocol.Resolution, Tuple[int, int], None] = None,
) -> Optional[blueye.protocol.CameraCalibration]:
    """Get the camera calibration scaled to a video resolution.

    See [`scale_calibration`][blueye.sdk.camera.scale_calibration] for how the values are
    scaled.

    Args:
        resolution (blueye.protocol.Resolution | tuple[int, int], optional):
            The resolution to scale the calibration to, either as a
            `blueye.protocol.Resolution` or as a `(width, height)` tuple in pixels. A
            `Resolution` maps to the frame size the drone's video pipeline produces for it:
            640x480 for 480p and 16:9 for the others. Defaults to the current stream
            resolution.

    Raises:
        ValueError: If the resolution is not a `blueye.protocol.Resolution` or a
            `(width, height)` tuple of positive integers.
        RuntimeError: If the drone reports a stream resolution the SDK does not recognize.

    Returns:
        The scaled calibration, or None if the drone has not published one.
    """
    calibration = self.get_calibration()
    if calibration is None:
        return None
    if resolution is None:
        resolution = self.get_stream_resolution()
    if isinstance(resolution, blueye.protocol.Resolution):
        try:
            width, height = _RESOLUTION_TO_SIZE[resolution]
        except KeyError:
            raise RuntimeError(
                f"Drone reported an unsupported resolution: {describe_enum(resolution)}"
            ) from None
    else:
        try:
            width, height = resolution
        except (TypeError, ValueError):
            raise ValueError(
                f"{resolution!r} is not a valid resolution, expected a "
                "blueye.protocol.Resolution or a (width, height) tuple"
            ) from None
    return scale_calibration(calibration, width, height)

get_sharpness

get_sharpness() -> int

Get the camera sharpness.

Only available on the X3 Ultra and X7.

Returns:

  • int –

    The camera sharpness.

Source code in blueye/sdk/camera.py
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
def get_sharpness(self) -> int:
    """Get the camera sharpness.

    Only available on the X3 Ultra and X7.

    Returns:
        The camera sharpness.
    """
    self._update_camera_parameters()
    return self._camera_parameters.sharpness

get_stream_resolution

get_stream_resolution() -> Resolution

Get the camera stream resolution.

For drones running blunux version < 4.4.1 this is the same as the get_resolution method.

Returns:

Source code in blueye/sdk/camera.py
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
def get_stream_resolution(self) -> blueye.protocol.Resolution:
    """Get the camera stream resolution.

    For drones running blunux version < 4.4.1 this is the same as the
    [`get_resolution`][blueye.sdk.camera.Camera.get_resolution] method.

    Returns:
        The camera stream resolution
    """
    self._update_camera_parameters()

    # Drones running Blunux < 4.4 do not support stream resolution so we return the old
    # resolution field instead.
    if version.parse(self._parent_drone.software_version_short) < version.parse("4.4"):
        return self._camera_parameters.resolution
    else:
        return self._camera_parameters.stream_resolution

get_stream_url

get_stream_url() -> str

Get the RTSP URL of this camera's live stream.

The URL comes from the stream list the drone reports in its drone info, addressed to the IP this Drone connects to. Without a stream list, on older drones or before connecting, the default is returned: port 8554 for the main camera and 8555 for a guest port camera.

The drone streams over UDP only, see Live video streams for players and limits.

Returns:

  • str –

    The stream URL, such as "rtsp://192.168.1.101:8554/test".

Source code in blueye/sdk/camera.py
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
def get_stream_url(self) -> str:
    """Get the RTSP URL of this camera's live stream.

    The URL comes from the stream list the drone reports in its drone info, addressed to the
    IP this `Drone` connects to. Without a stream list, on older drones or before connecting,
    the default is returned: port 8554 for the main camera and 8555 for a guest port camera.

    The drone streams over UDP only, see
    [Live video streams](../../../video/streams.md) for players and limits.

    Returns:
        The stream URL, such as `"rtsp://192.168.1.101:8554/test"`.
    """
    # Only the port and path are taken from the drone's URL, so the stream is addressed to
    # the IP this Drone connects to.
    ip = self._parent_drone._ip
    host = f"[{ip}]" if ":" in ip else ip
    primary = not self._is_guestport_camera
    for service in self._parent_drone._services or []:
        if not isinstance(service, dict) or service.get("type") != "videostream":
            continue
        options = service.get("options")
        if not isinstance(options, dict) or bool(options.get("primary")) != primary:
            continue
        url = options.get("url")
        if not isinstance(url, str):
            continue
        try:
            parts = urllib.parse.urlsplit(url)
            port = parts.port
        except ValueError:
            continue
        if parts.scheme != "rtsp" or not parts.path:
            continue
        netloc = f"{host}:{port}" if port else host
        return urllib.parse.urlunsplit((parts.scheme, netloc, parts.path, parts.query, ""))
    if self._is_guestport_camera:
        return f"rtsp://{host}:8555/guestport_cam"
    return f"rtsp://{host}:8554/test"

get_streaming_protocol

get_streaming_protocol() -> StreamingProtocol

Get the streaming protocol (codec used for the RTSP stream).

Returns:

Source code in blueye/sdk/camera.py
1826
1827
1828
1829
1830
1831
1832
1833
def get_streaming_protocol(self) -> blueye.protocol.StreamingProtocol:
    """Get the streaming protocol (codec used for the RTSP stream).

    Returns:
        The current streaming protocol.
    """
    self._update_camera_parameters()
    return self._camera_parameters.streaming_protocol

get_turbidity_filter

get_turbidity_filter() -> Optional[FilterMessage]

Get the turbidity filter settings of the main camera.

The turbidity filter runs contrast limited adaptive histogram equalisation (CLAHE) on the video, which brings out detail in turbid water. Only available on the X3 Ultra and X7.

The drone publishes TurbidityFilterTel when the settings change rather than at a fixed rate. The value is the last change seen since connecting, and the drone is asked for its current settings if there has been none.

Returns:

  • Optional[FilterMessage] –

    The filter settings with enabled and intensity (0..1), or None if the drone has not reported any, as is the case for older models and the guestport camera.

Source code in blueye/sdk/camera.py
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
def get_turbidity_filter(self) -> Optional[blueye.protocol.FilterMessage]:
    """Get the turbidity filter settings of the main camera.

    The turbidity filter runs contrast limited adaptive histogram equalisation (CLAHE) on
    the video, which brings out detail in turbid water. Only available on the X3 Ultra and
    X7.

    The drone publishes `TurbidityFilterTel` when the settings change rather than at a fixed
    rate. The value is the last change seen since connecting, and the drone is asked for its
    current settings if there has been none.

    Returns:
        The filter settings with `enabled` and `intensity` (0..1), or None if the drone has
        not reported any, as is the case for older models and the guestport camera.
    """
    if self._is_guestport_camera:
        return None
    tel = self._parent_drone.telemetry.get(blueye.protocol.TurbidityFilterTel)
    if tel is None:
        return None
    return tel.turbidity_filter

get_whitebalance

get_whitebalance() -> int

Get the camera white balance.

Returns:

  • int –

    The camera white balance.

Source code in blueye/sdk/camera.py
1199
1200
1201
1202
1203
1204
1205
1206
def get_whitebalance(self) -> int:
    """Get the camera white balance.

    Returns:
        The camera white balance.
    """
    self._update_camera_parameters()
    return self._camera_parameters.white_balance

is_ehdr_enabled

is_ehdr_enabled() -> bool

Get the state of the eHDR mode.

Only available on the X3 Ultra and X7.

Returns:

  • bool –

    The current state of the eHDR mode.

Source code in blueye/sdk/camera.py
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
def is_ehdr_enabled(self) -> bool:
    """Get the state of the eHDR mode.

    Only available on the X3 Ultra and X7.

    Returns:
        The current state of the eHDR mode.
    """
    self._update_camera_parameters()
    return self._camera_parameters.ehdr_enabled

is_recording_active

is_recording_active() -> Optional[bool]

Get the camera recording state.

Returns:

  • Optional[bool] –

    True if the camera is currently recording, False if not. Returns None if the SDK hasn't received a RecordState telemetry message.

Source code in blueye/sdk/camera.py
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
def is_recording_active(self) -> Optional[bool]:
    """Get the camera recording state.

    Returns:
        True if the camera is currently recording, False if not. Returns None if the SDK
        hasn't received a RecordState telemetry message.
    """
    record_state = self._get_record_state()
    if record_state is None:
        return None
    if self._is_guestport_camera:
        return record_state.guestport_is_recording
    else:
        return record_state.main_is_recording

set_backlight_compensation

set_backlight_compensation(compensation: int)

Set the camera backlight compensation.

Only available on the X3 Ultra and X7.

Parameters:

  • compensation (int) –

    Set the backlight compensation (-150..150), 10 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
def set_backlight_compensation(self, compensation: int):
    """Set the camera backlight compensation.

    Only available on the X3 Ultra and X7.

    Args:
        compensation (int): Set the backlight compensation (-150..150), 10 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.backlight_compensation = compensation
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_bitrate

set_bitrate(bitrate: int)

Set the video stream bitrate.

Parameters:

  • bitrate (int) –

    Set the video stream bitrate in bits, valid values are in range (1 000 000 .. 16 000 000).

Source code in blueye/sdk/camera.py
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
def set_bitrate(self, bitrate: int):
    """Set the video stream bitrate.

    Args:
        bitrate (int): Set the video stream bitrate in bits, valid values are in range
                       (1 000 000 .. 16 000 000).
    """
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.h264_bitrate = bitrate
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_bitrate_still_picture

set_bitrate_still_picture(bitrate: int)

Set the bitrate for the still picture stream.

Parameters:

  • bitrate (int) –

    Set the still picture stream bitrate in bits, valid values are in range (1 000 000 .. 300 000 000). Default value is 100 000 000.

Source code in blueye/sdk/camera.py
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
def set_bitrate_still_picture(self, bitrate: int):
    """Set the bitrate for the still picture stream.

    Args:
        bitrate (int): Set the still picture stream bitrate in bits, valid values are in range
                       (1 000 000 .. 300 000 000). Default value is 100 000 000.
    """
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.mjpg_bitrate = bitrate
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_brightness

set_brightness(brightness: int)

Set the camera brightness.

Only available on the X3 Ultra and X7.

Parameters:

  • brightness (int) –

    Set the brightness (-10..10), 0 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
def set_brightness(self, brightness: int):
    """Set the camera brightness.

    Only available on the X3 Ultra and X7.

    Args:
        brightness (int): Set the brightness (-10..10), 0 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.brightness = brightness
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_color_correction

set_color_correction(enabled: bool, intensity: float)

Set the color correction filter on the main camera.

See get_color_correction for what the filter does.

Parameters:

  • enabled (bool) –

    Whether the filter is enabled.

  • intensity (float) –

    How much of the correction is applied, 0 leaves the image as is and 1 applies the full correction.

Raises:

  • ValueError –

    If the intensity is outside 0..1.

  • RuntimeError –

    If this is the guestport camera, the drone runs Blunux older than 5.0.0, or the drone is neither an X3 Ultra nor an X7.

Source code in blueye/sdk/camera.py
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
def set_color_correction(self, enabled: bool, intensity: float):
    """Set the color correction filter on the main camera.

    See [`get_color_correction`][blueye.sdk.camera.Camera.get_color_correction] for what the
    filter does.

    Args:
        enabled (bool): Whether the filter is enabled.
        intensity (float): How much of the correction is applied, 0 leaves the image as is
            and 1 applies the full correction.

    Raises:
        ValueError: If the intensity is outside 0..1.
        RuntimeError: If this is the guestport camera, the drone runs Blunux older than
            5.0.0, or the drone is neither an X3 Ultra nor an X7.
    """
    self._verify_4k_camera("Color correction")
    self._verify_in_range("Color correction intensity", intensity, 0.0, 1.0)
    self._parent_drone._ctrl_client.set_color_correction(enabled, intensity)

set_contrast

set_contrast(contrast: int)

Set the camera contrast.

Only available on the X3 Ultra and X7.

Parameters:

  • contrast (int) –

    Set the contrast (-50..50), 0 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
def set_contrast(self, contrast: int):
    """Set the camera contrast.

    Only available on the X3 Ultra and X7.

    Args:
        contrast (int): Set the contrast (-50..50), 0 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.contrast = contrast
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_denoise

set_denoise(denoise: int)

Set the camera noise reduction.

Only available on the X3 Ultra and X7.

Parameters:

  • denoise (int) –

    Set the noise reduction (-20..20), -20 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
def set_denoise(self, denoise: int):
    """Set the camera noise reduction.

    Only available on the X3 Ultra and X7.

    Args:
        denoise (int): Set the noise reduction (-20..20), -20 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.denoise = denoise
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_ehdr_exposure_max_number

set_ehdr_exposure_max_number(number: int)

Set the maximum number of eHDR frames.

Only available on the X3 Ultra and X7.

Parameters:

  • number (int) –

    Set the maximum number of eHDR frames (1..4), 2 is the default. Setting it higher than 2 can reduce the frame rate.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
def set_ehdr_exposure_max_number(self, number: int):
    """Set the maximum number of eHDR frames.

    Only available on the X3 Ultra and X7.

    Args:
        number (int): Set the maximum number of eHDR frames (1..4), 2 is the default. Setting
            it higher than 2 can reduce the frame rate.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.ehdr_exposure_max_number = number
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_ehdr_exposure_min_number

set_ehdr_exposure_min_number(number: int)

Set the minimum number of eHDR frames.

Only available on the X3 Ultra and X7.

Parameters:

  • number (int) –

    Set the minimum number of eHDR frames (1..4), 1 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
def set_ehdr_exposure_min_number(self, number: int):
    """Set the minimum number of eHDR frames.

    Only available on the X3 Ultra and X7.

    Args:
        number (int): Set the minimum number of eHDR frames (1..4), 1 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.ehdr_exposure_min_number = number
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_exposure

set_exposure(exposure: int)

Set the camera exposure.

On the X3 Ultra and X7 a shutter time longer than one frame at the current frame rate is shortened to the frame period, 333 at 30 fps, and get_exposure reports the shortened value.

Parameters:

  • exposure (int) –

    Shutter time in units of 1/10000 s (100 µs), so 100 = 10 ms. Valid values are in the range (1..5000) or -1 for auto exposure.

Source code in blueye/sdk/camera.py
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
def set_exposure(self, exposure: int):
    """Set the camera exposure.

    On the X3 Ultra and X7 a shutter time longer than one frame at the current frame rate
    is shortened to the frame period, 333 at 30 fps, and
    [`get_exposure`][blueye.sdk.camera.Camera.get_exposure] reports the shortened value.

    Args:
        exposure (int): Shutter time in units of 1/10000 s (100 µs), so 100 = 10 ms. Valid
            values are in the range (1..5000) or -1 for auto exposure.
    """
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.exposure = exposure
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_framerate

set_framerate(framerate: int)

Set the camera frame rate.

Parameters:

  • framerate (int) –

    Set the camera frame rate in frames per second. Valid values are 25, 30 or 60. 25 fps is only supported on Pioneer/Pro/X1/X3, and 60 fps only on the X3 Ultra and X7 at 1440p or lower. If the requested frame rate is not supported at the current resolution the drone reduces it while respecting the resolution. On the X3 Ultra and X7 the live stream is limited to 30 fps: at 60 fps it carries every other frame, and recordings keep the full rate.

Raises:

  • ValueError –

    If the frame rate is not 25, 30 or 60.

Source code in blueye/sdk/camera.py
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
def set_framerate(self, framerate: int):
    """Set the camera frame rate.

    Args:
        framerate (int): Set the camera frame rate in frames per second. Valid values are 25,
            30 or 60. 25 fps is only supported on Pioneer/Pro/X1/X3, and 60 fps only on the
            X3 Ultra and X7 at 1440p or lower. If the requested frame rate is not supported
            at the current resolution the drone reduces it while respecting the resolution.
            On the X3 Ultra and X7 the live stream is limited to 30 fps: at 60 fps it carries
            every other frame, and recordings keep the full rate.

    Raises:
        ValueError: If the frame rate is not 25, 30 or 60.
    """
    if framerate not in _FPS_TO_FRAMERATE:
        raise ValueError(f"{framerate} is not a valid framerate. Valid values are 25, 30 or 60")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.framerate = _FPS_TO_FRAMERATE[framerate]
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_gain

set_gain(gain: float)

Set the camera gain.

On the X3 Ultra and X7 a manual gain only takes effect together with a manual exposure (see set_exposure). With auto exposure, or with a gain of -1, the drone's auto exposure controls the gain. On Pioneer/Pro/X1/X3 a value of -1 leaves the gain unchanged.

Parameters:

  • gain (float) –

    Set the ISO gain (0..1), or -1 to let the drone control it.

Source code in blueye/sdk/camera.py
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
def set_gain(self, gain: float):
    """Set the camera gain.

    On the X3 Ultra and X7 a manual gain only takes effect together with a manual exposure
    (see [`set_exposure`][blueye.sdk.camera.Camera.set_exposure]). With auto exposure, or
    with a gain of -1, the drone's auto exposure controls the gain. On Pioneer/Pro/X1/X3 a
    value of -1 leaves the gain unchanged.

    Args:
        gain (float): Set the ISO gain (0..1), or -1 to let the drone control it.
    """
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.gain = gain
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_gamma

set_gamma(gamma: int)

Set the camera gamma.

Only available on the X3 Ultra and X7.

Parameters:

  • gamma (int) –

    Set the gamma (4..79), 22 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
def set_gamma(self, gamma: int):
    """Set the camera gamma.

    Only available on the X3 Ultra and X7.

    Args:
        gamma (int): Set the gamma (4..79), 22 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.gamma = gamma
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_hue

set_hue(hue: int)

Set the camera hue.

Only available on Pioneer/Pro/X1/X3, the 4K camera in the X3 Ultra and X7 has no hue control.

Parameters:

  • hue (int) –

    Set the camera hue. Valid values are in the range (-40..40).

Source code in blueye/sdk/camera.py
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
def set_hue(self, hue: int):
    """Set the camera hue.

    Only available on Pioneer/Pro/X1/X3, the 4K camera in the X3 Ultra and X7 has no hue
    control.

    Args:
        hue (int): Set the camera hue. Valid values are in the range (-40..40).
    """
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.hue = hue
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_mtu_size

set_mtu_size(mtu_size: int)

Set the network MTU size used for video streaming.

Parameters:

  • mtu_size (int) –

    Set the MTU size in bytes (68..65535). The Blueye app allows values between 500 and 1460. A value of 0 means the drone uses its default of 1400.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.1.0.

Source code in blueye/sdk/camera.py
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
def set_mtu_size(self, mtu_size: int):
    """Set the network MTU size used for video streaming.

    Args:
        mtu_size (int): Set the MTU size in bytes (68..65535). The Blueye app allows values
            between 500 and 1460. A value of 0 means the drone uses its default of 1400.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.1.0.
    """
    self._parent_drone._verify_required_blunux_version("5.1.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.mtu_size = mtu_size
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_pan_tilt_zoom

set_pan_tilt_zoom(
    pan: Optional[float] = None,
    tilt: Optional[float] = None,
    zoom: Optional[float] = None,
)

Set the digital pan, tilt and zoom of the main camera.

The three values are sent together in one message. An argument that is left out keeps the value this object last sent. Before the first call it keeps the value the drone last reported, or 0 if it has not reported one. The drone reports a change about 0.1 s after the command, which is why the last sent values are used rather than the report: two calls in a row would otherwise undo each other. A change made by another client after the last call from this object is not picked up; pass all three values to be sure. Pan and tilt only have an effect while zoomed in, since at zoom 0 the whole sensor image is already shown.

Laser dot tracking works on the full, unzoomed image, so enable_tracking resets pan, tilt and zoom to 0 when it starts, as the Blueye app does.

Parameters:

  • pan (float, default: None ) –

    Horizontal pan (-1..1), 0 is centred.

  • tilt (float, default: None ) –

    Vertical tilt (-1..1), 0 is centred.

  • zoom (float, default: None ) –

    Zoom level (0..1), 0 is no zoom.

Raises:

  • ValueError –

    If pan or tilt is outside -1..1, or zoom is outside 0..1.

  • RuntimeError –

    If this is the guestport camera, the drone runs Blunux older than 5.0.0, or the drone is neither an X3 Ultra nor an X7.

Source code in blueye/sdk/camera.py
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
def set_pan_tilt_zoom(
    self,
    pan: Optional[float] = None,
    tilt: Optional[float] = None,
    zoom: Optional[float] = None,
):
    """Set the digital pan, tilt and zoom of the main camera.

    The three values are sent together in one message. An argument that is left out keeps
    the value this object last sent. Before the first call it keeps the value the drone last
    reported, or 0 if it has not reported one. The drone reports a change about 0.1 s after
    the command, which is why the last sent values are used rather than the report: two
    calls in a row would otherwise undo each other. A change made by another client after
    the last call from this object is not picked up; pass all three values to be sure. Pan
    and tilt only have an effect while zoomed in, since at zoom 0 the whole sensor image is
    already shown.

    Laser dot tracking works on the full, unzoomed image, so
    [`enable_tracking`][blueye.sdk.guestport.Laser.enable_tracking] resets pan, tilt and
    zoom to 0 when it starts, as the Blueye app does.

    Args:
        pan (float, optional): Horizontal pan (-1..1), 0 is centred.
        tilt (float, optional): Vertical tilt (-1..1), 0 is centred.
        zoom (float, optional): Zoom level (0..1), 0 is no zoom.

    Raises:
        ValueError: If pan or tilt is outside -1..1, or zoom is outside 0..1.
        RuntimeError: If this is the guestport camera, the drone runs Blunux older than
            5.0.0, or the drone is neither an X3 Ultra nor an X7.
    """
    self._verify_4k_camera("Digital pan, tilt and zoom")
    if pan is not None:
        self._verify_in_range("Pan", pan, -1.0, 1.0)
    if tilt is not None:
        self._verify_in_range("Tilt", tilt, -1.0, 1.0)
    if zoom is not None:
        self._verify_in_range("Zoom", zoom, 0.0, 1.0)
    if None in (pan, tilt, zoom):
        if self._last_pan_tilt_zoom is not None:
            current = self._last_pan_tilt_zoom
        else:
            reported = self.get_pan_tilt_zoom()
            current = (
                (reported.pan, reported.tilt, reported.zoom)
                if reported is not None
                else (0.0, 0.0, 0.0)
            )
        pan = current[0] if pan is None else pan
        tilt = current[1] if tilt is None else tilt
        zoom = current[2] if zoom is None else zoom
    self._send_pan_tilt_zoom(pan, tilt, zoom)

set_recording

set_recording(start_recording: bool)

Set the camera recording state.

Parameters:

  • start_recording (bool) –

    Set to True to start a recording, set to False to stop the current recording.

Raises:

  • RuntimeError –

    If a recording is started while the drone's storage settings have videos switched off, in which case the drone would not record.

Source code in blueye/sdk/camera.py
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
def set_recording(self, start_recording: bool):
    """Set the camera recording state.

    Args:
        start_recording (bool): Set to True to start a recording, set to False to stop the
                                current recording.

    Raises:
        RuntimeError: If a recording is started while the drone's storage settings have
            videos switched off, in which case the drone would not record.
    """
    if start_recording and self._parent_drone._media_is_enabled("videos") is False:
        raise RuntimeError(
            "The drone's storage settings have video recording switched off, so it would not "
            "record. Enable videos under the drone's storage settings in the Blueye app."
        )
    record_state = self._get_record_state()
    if record_state is None:
        logger.warning("Unable to set recording state, no record state telemetry received")
        return
    # The drone applies all three recorders from one message, so the other camera and the
    # multibeam are sent as they are, from the latest RecordStateTel
    if self._is_guestport_camera:
        self._parent_drone._ctrl_client.set_recording_state(
            record_state.main_is_recording,
            start_recording,
            record_state.multibeam_is_recording,
        )
    else:
        self._parent_drone._ctrl_client.set_recording_state(
            start_recording,
            record_state.guestport_is_recording,
            record_state.multibeam_is_recording,
        )

set_recording_bitrate

set_recording_bitrate(bitrate: int)

Set the recording bitrate in bits per second.

A value of 0 means the drone will auto-compute a default bitrate based on the current resolution, framerate, and codec.

Parameters:

  • bitrate (int) –

    Set the recording bitrate in bits per second. Use 0 for automatic.

Raises:

  • RuntimeError –

    If the connected drone is running Blunux older than 5.0.0.

Source code in blueye/sdk/camera.py
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
def set_recording_bitrate(self, bitrate: int):
    """Set the recording bitrate in bits per second.

    A value of 0 means the drone will auto-compute a default bitrate based on the current
    resolution, framerate, and codec.

    Args:
        bitrate (int): Set the recording bitrate in bits per second. Use 0 for automatic.

    Raises:
        RuntimeError: If the connected drone is running Blunux older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.recording_bitrate = bitrate
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_recording_codec

set_recording_codec(codec: RecordingCodec)

Set the recording video codec.

Parameters:

  • codec (RecordingCodec) –

    Set the recording codec. RECORDING_CODEC_UNSPECIFIED uses the platform default (H.264). RECORDING_CODEC_H265 is only available on the X3 Ultra and X7.

Raises:

  • ValueError –

    If the codec is not a valid blueye.protocol.RecordingCodec type.

  • RuntimeError –

    If the connected drone is running Blunux older than 5.0.0.

Source code in blueye/sdk/camera.py
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
def set_recording_codec(self, codec: blueye.protocol.RecordingCodec):
    """Set the recording video codec.

    Args:
        codec (blueye.protocol.RecordingCodec): Set the recording codec.
            RECORDING_CODEC_UNSPECIFIED uses the platform default (H.264).
            RECORDING_CODEC_H265 is only available on the X3 Ultra and X7.

    Raises:
        ValueError: If the codec is not a valid `blueye.protocol.RecordingCodec` type.
        RuntimeError: If the connected drone is running Blunux older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if not isinstance(codec, blueye.protocol.RecordingCodec):
        raise ValueError(f"{codec} is not a valid RecordingCodec type")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.recording_codec = codec
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_recording_resolution

set_recording_resolution(resolution: Resolution)

Set the camera recording resolution.

For drones running Blunux version < 4.4.1 this is the same as the set_resolution method.

Parameters:

  • resolution (Resolution) –

    Set the camera recording resolution.

Raises:

  • ValueError –

    If the resolution is not a valid blueye.protocol.Resolution type

Source code in blueye/sdk/camera.py
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
def set_recording_resolution(self, resolution: blueye.protocol.Resolution):
    """Set the camera recording resolution.

    For drones running Blunux version < 4.4.1 this is the same as the
    [`set_resolution`][blueye.sdk.camera.Camera.set_resolution] method.

    Args:
        resolution (blueye.protocol.Resolution): Set the camera recording resolution.

    Raises:
        ValueError: If the resolution is not a valid `blueye.protocol.Resolution` type
    """
    if not isinstance(resolution, blueye.protocol.Resolution):
        raise ValueError(f"{resolution} is not a valid resolution type")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.recording_resolution = resolution
    # If the drone is running Blunux < 4.4 we need to set the resolution field as well.
    self._camera_parameters.resolution = resolution
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_resolution

set_resolution(resolution: int)

Set the camera resolution.

Deprecated

Drones running Blunux 4.4 or newer ignore this field when camera parameters are set, so calling this method has no effect on them. Use set_stream_resolution and set_recording_resolution instead.

Parameters:

  • resolution (int) –

    Set the camera in vertical pixels. Valid values are 480, 720, 1080, 1440 or 2160.

Raises:

  • ValueError –

    If the resolution is not one of the valid values.

Source code in blueye/sdk/camera.py
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
def set_resolution(self, resolution: int):
    """Set the camera resolution.

    Deprecated:
        Drones running Blunux 4.4 or newer ignore this field when camera parameters are set,
        so calling this method has no effect on them. Use
        [`set_stream_resolution`][blueye.sdk.camera.Camera.set_stream_resolution] and
        [`set_recording_resolution`][blueye.sdk.camera.Camera.set_recording_resolution]
        instead.

    Args:
        resolution (int): Set the camera in vertical pixels. Valid values are 480, 720, 1080,
            1440 or 2160.

    Raises:
        ValueError: If the resolution is not one of the valid values.
    """
    warnings.warn(
        "`Camera.set_resolution` is deprecated and is ignored by drones running Blunux 4.4 or "
        "newer, use `Camera.set_stream_resolution` or `Camera.set_recording_resolution` "
        "instead",
        DeprecationWarning,
        stacklevel=2,
    )
    if resolution not in _HEIGHT_TO_RESOLUTION:
        raise ValueError(
            f"{resolution} is not a valid resolution. "
            "Valid values are 480, 720, 1080, 1440 or 2160"
        )
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.resolution = _HEIGHT_TO_RESOLUTION[resolution]
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_saturation

set_saturation(saturation: int)

Set the camera saturation.

Only available on the X3 Ultra and X7.

Parameters:

  • saturation (int) –

    Set the saturation (0..50), 8 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
def set_saturation(self, saturation: int):
    """Set the camera saturation.

    Only available on the X3 Ultra and X7.

    Args:
        saturation (int): Set the saturation (0..50), 8 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.saturation = saturation
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_sharpness

set_sharpness(sharpness: int)

Set the camera sharpness.

Only available on the X3 Ultra and X7.

Parameters:

  • sharpness (int) –

    Set the sharpness (-20..20), -20 is the default.

Raises:

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.0.0.

Source code in blueye/sdk/camera.py
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
def set_sharpness(self, sharpness: int):
    """Set the camera sharpness.

    Only available on the X3 Ultra and X7.

    Args:
        sharpness (int): Set the sharpness (-20..20), -20 is the default.

    Raises:
        RuntimeError: If the connected drone is running a Blunux version older than 5.0.0.
    """
    self._parent_drone._verify_required_blunux_version("5.0.0")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.sharpness = sharpness
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_stream_resolution

set_stream_resolution(resolution: Resolution)

Set the camera stream resolution.

For drones running blunux version < 4.4.1 this is the same as the set_resolution method.

Parameters:

  • resolution (Resolution) –

    Set the camera stream resolution.

Raises:

  • ValueError –

    If the resolution is not a valid blueye.protocol.Resolution type

Source code in blueye/sdk/camera.py
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
def set_stream_resolution(self, resolution: blueye.protocol.Resolution):
    """Set the camera stream resolution.

    For drones running blunux version < 4.4.1 this is the same as the
    [`set_resolution`][blueye.sdk.camera.Camera.set_resolution] method.

    Args:
        resolution (blueye.protocol.Resolution): Set the camera stream resolution.

    Raises:
        ValueError: If the resolution is not a valid `blueye.protocol.Resolution` type
    """
    if not isinstance(resolution, blueye.protocol.Resolution):
        raise ValueError(f"{resolution} is not a valid resolution type")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.stream_resolution = resolution
    # If the drone is running Blunux < 4.4 we need to set the resolution field as well.
    self._camera_parameters.resolution = resolution
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_streaming_protocol

set_streaming_protocol(protocol: StreamingProtocol)

Set the streaming protocol (codec used for the RTSP stream).

Parameters:

Raises:

  • ValueError –

    If the protocol is not a valid blueye.protocol.StreamingProtocol type.

Source code in blueye/sdk/camera.py
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
def set_streaming_protocol(self, protocol: blueye.protocol.StreamingProtocol):
    """Set the streaming protocol (codec used for the RTSP stream).

    Args:
        protocol (blueye.protocol.StreamingProtocol): Set the streaming protocol.

    Raises:
        ValueError: If the protocol is not a valid `blueye.protocol.StreamingProtocol` type.
    """
    if not isinstance(protocol, blueye.protocol.StreamingProtocol):
        raise ValueError(f"{protocol} is not a valid StreamingProtocol type")
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.streaming_protocol = protocol
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

set_turbidity_filter

set_turbidity_filter(enabled: bool, intensity: float)

Set the turbidity filter on the main camera.

See get_turbidity_filter for what the filter does.

Parameters:

  • enabled (bool) –

    Whether the filter is enabled.

  • intensity (float) –

    How strongly the filter is applied (0..1).

Raises:

  • ValueError –

    If the intensity is outside 0..1.

  • RuntimeError –

    If this is the guestport camera, the drone runs Blunux older than 5.0.0, or the drone is neither an X3 Ultra nor an X7.

Source code in blueye/sdk/camera.py
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
def set_turbidity_filter(self, enabled: bool, intensity: float):
    """Set the turbidity filter on the main camera.

    See [`get_turbidity_filter`][blueye.sdk.camera.Camera.get_turbidity_filter] for what the
    filter does.

    Args:
        enabled (bool): Whether the filter is enabled.
        intensity (float): How strongly the filter is applied (0..1).

    Raises:
        ValueError: If the intensity is outside 0..1.
        RuntimeError: If this is the guestport camera, the drone runs Blunux older than
            5.0.0, or the drone is neither an X3 Ultra nor an X7.
    """
    self._verify_4k_camera("The turbidity filter")
    self._verify_in_range("Turbidity filter intensity", intensity, 0.0, 1.0)
    self._parent_drone._ctrl_client.set_turbidity_filter(enabled, intensity)

set_whitebalance

set_whitebalance(white_balance: int)

Set the camera white balance.

Parameters:

  • white_balance (int) –

    Colour temperature in kelvin. Valid values are in the range (2800..9300) on Pioneer/Pro/X1/X3 and (2300..15000) on the X3 Ultra and X7, or -1 for auto white balance.

Source code in blueye/sdk/camera.py
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
def set_whitebalance(self, white_balance: int):
    """Set the camera white balance.

    Args:
        white_balance (int): Colour temperature in kelvin. Valid values are in the range
            (2800..9300) on Pioneer/Pro/X1/X3 and (2300..15000) on the X3 Ultra and X7, or
            -1 for auto white balance.
    """
    if self._camera_parameters is None:
        self._update_camera_parameters()
    self._camera_parameters.white_balance = white_balance
    self._parent_drone._req_rep_client.set_camera_parameters(self._camera_parameters)

take_picture

take_picture()

Take a still picture and store it locally on the drone.

The picture command has no camera selector: the drone captures from the main camera and, if a guest port camera is attached, from that camera too, whichever Camera object the call is made on. See Recording video and taking pictures.

These pictures can be downloaded with the Blueye App, or by any WebDAV compatible client.

Raises:

  • RuntimeError –

    If the drone's storage settings have images switched off, in which case the drone would drop the picture.

Source code in blueye/sdk/camera.py
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
def take_picture(self):
    """Take a still picture and store it locally on the drone.

    The picture command has no camera selector: the drone captures from the main camera and,
    if a guest port camera is attached, from that camera too, whichever `Camera` object the
    call is made on. See [Recording video and taking
    pictures](../../../video/recording-and-stills.md).

    These pictures can be downloaded with the Blueye App, or by any WebDAV compatible client.

    Raises:
        RuntimeError: If the drone's storage settings have images switched off, in which case
            the drone would drop the picture.
    """
    if self._parent_drone._media_is_enabled("images") is False:
        raise RuntimeError(
            "The drone's storage settings have images switched off, so it would drop the "
            "picture. Enable images under the drone's storage settings in the Blueye app."
        )
    self._parent_drone._ctrl_client.take_still_picture()

GuestPortLight

GuestPortLight(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
)

Represents a light connected to a guest port on the Blueye drone.

Parameters:

Methods:

Attributes:

Source code in blueye/sdk/guestport.py
174
175
176
177
178
179
180
181
182
183
184
def __init__(
    self, parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
):
    """Initialize the GuestPortLight class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.
    """
    Peripheral.__init__(self, parent_drone, port_number, device)

compatible_guest_ports instance-attribute

compatible_guest_ports: List[GuestPortNumber] = list(
    compatible_guest_ports
)

Ports on this drone where the device is fully supported.

Computed by the drone from the port capabilities and the device requirements.

required_capabilities instance-attribute

required_capabilities: List[GuestPortCapability] = list(
    required_capabilities
)

Interfaces the device requires from the port it is connected to.

get_detach_status

get_detach_status() -> GuestPortDetachStatus

Get the current attach state of a detachable device.

The state is read from the latest drone info telemetry so it follows the device being attached or detached during a session. If no newer telemetry is available, the state reported when the peripheral was discovered is returned.

Returns:

  • GuestPortDetachStatus –

    The detach status. GUEST_PORT_DETACH_STATUS_UNSPECIFIED for devices that cannot be detached.

Source code in blueye/sdk/guestport.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def get_detach_status(self) -> bp.GuestPortDetachStatus:
    """Get the current attach state of a detachable device.

    The state is read from the latest drone info telemetry so it follows the device being
    attached or detached during a session. If no newer telemetry is available, the state
    reported when the peripheral was discovered is returned.

    Returns:
        The detach status. `GUEST_PORT_DETACH_STATUS_UNSPECIFIED` for devices that cannot be
        detached.
    """
    drone_info_tel = self.parent_drone.telemetry.get(bp.DroneInfoTel)
    if drone_info_tel is not None:
        device = _find_device(drone_info_tel.drone_info.gp, self)
        if device is not None:
            return device.detach_status
    return self._detach_status

get_intensity

get_intensity() -> Optional[float]

Get the intensity of the guest port light.

The drone only publishes the guest port light state after the lights have been set once in the session, so this can be None for a while after connecting.

Returns:

  • Optional[float] –

    The intensity of the light (0..1), or None if the drone has not reported it yet.

Source code in blueye/sdk/guestport.py
201
202
203
204
205
206
207
208
209
210
211
212
213
def get_intensity(self) -> Optional[float]:
    """Get the intensity of the guest port light.

    The drone only publishes the guest port light state after the lights have been set once
    in the session, so this can be `None` for a while after connecting.

    Returns:
        The intensity of the light (0..1), or `None` if the drone has not reported it yet.
    """
    telemetry_msg = self.parent_drone.telemetry.get(bp.GuestPortLightsTel)
    if telemetry_msg is None:
        return None
    return telemetry_msg.lights.value

set_intensity

set_intensity(intensity: float)

Set the intensity of the guest port light.

The drone applies the value to every light on its guest ports at once.

Parameters:

  • intensity (float) –

    The intensity of the light (0..1).

Raises:

  • ValueError –

    If the intensity is not between 0 and 1.

Source code in blueye/sdk/guestport.py
186
187
188
189
190
191
192
193
194
195
196
197
198
199
def set_intensity(self, intensity: float):
    """Set the intensity of the guest port light.

    The drone applies the value to every light on its guest ports at once.

    Args:
        intensity (float): The intensity of the light (0..1).

    Raises:
        ValueError: If the intensity is not between 0 and 1.
    """
    if not 0 <= intensity <= 1:
        raise ValueError("Light intensity must be between 0 and 1.")
    self.parent_drone._ctrl_client.set_guest_port_lights(intensity)

Laser

Laser(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
)

Represents a scaling laser connected to a guest port on the Blueye drone.

On the X3 Ultra and X7 the laser can be modulated at 5 Hz, and the drone then tracks the two dots in the main camera image and reports their positions, pixel distance and the estimated distance to the subject in LaserTel. The drone overwrites the modulation flag with every LaserCtrl, so set_intensity keeps the reported flag unless told otherwise.

Parameters:

Methods:

Attributes:

Source code in blueye/sdk/guestport.py
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
def __init__(
    self, parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
):
    """Initialize the Laser class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.
    """
    Peripheral.__init__(self, parent_drone, port_number, device)
    # What was last commanded from this object and when. The drone reports the laser once a
    # second, so for a short while after a command the report may predate it. The modulation
    # has its own clock: it is only restarted when the flag is chosen explicitly, so a script
    # that keeps setting the intensity picks up a change another client made to tracking.
    self._commanded_intensity: Optional[float] = None
    self._intensity_commanded_at: Optional[float] = None
    self._commanded_modulated = False
    self._modulation_commanded_at: Optional[float] = None

compatible_guest_ports instance-attribute

compatible_guest_ports: List[GuestPortNumber] = list(
    compatible_guest_ports
)

Ports on this drone where the device is fully supported.

Computed by the drone from the port capabilities and the device requirements.

required_capabilities instance-attribute

required_capabilities: List[GuestPortCapability] = list(
    required_capabilities
)

Interfaces the device requires from the port it is connected to.

enable_tracking

enable_tracking(enabled: bool)

Start or stop laser dot tracking.

Tracking modulates the laser at 5 Hz, and the drone picks the flickering dots out of the main camera image. Only available on the X3 Ultra and X7; older firmware ignores the flag. The intensity stays as the drone last reported it, or as last commanded from this object in the last two seconds or while the drone has not reported any, and a laser that is off is turned fully on when tracking starts, since the drone needs the dots to track. Tracking works on the full camera image, so starting it also resets the digital pan, tilt and zoom to 0, as the Blueye app does.

Parameters:

  • enabled (bool) –

    True to start tracking, False to stop it and keep the laser on continuously.

Raises:

  • RuntimeError –

    If the drone is known to be neither an X3 Ultra nor an X7.

Source code in blueye/sdk/guestport.py
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
def enable_tracking(self, enabled: bool):
    """Start or stop laser dot tracking.

    Tracking modulates the laser at 5 Hz, and the drone picks the flickering dots out of the
    main camera image. Only available on the X3 Ultra and X7; older firmware ignores the
    flag. The intensity stays as the drone last reported it, or as last commanded from this
    object in the last two seconds or while the drone has not reported any, and a laser
    that is off is turned fully on when tracking starts, since the drone needs the dots to
    track. Tracking works on the full camera image, so starting it also resets the digital
    pan, tilt and zoom to 0, as the Blueye app does.

    Args:
        enabled (bool): True to start tracking, False to stop it and keep the laser on
            continuously.

    Raises:
        RuntimeError: If the drone is known to be neither an X3 Ultra nor an X7.
    """
    if self.parent_drone.is_jetson_platform() is False:
        raise RuntimeError("Laser tracking is only available on the X3 Ultra and X7")
    intensity = self.get_intensity()
    if intensity is None or self._is_fresh(self._intensity_commanded_at):
        intensity = self._commanded_intensity
    if enabled and not intensity:
        intensity = 1.0
    elif intensity is None:
        intensity = 0.0
    if enabled:
        # Through the camera, so its record of the last sent values stays right
        self.parent_drone.camera._send_pan_tilt_zoom(0.0, 0.0, 0.0)
    self._send(intensity, enabled, modulation_explicit=True)

get_detach_status

get_detach_status() -> GuestPortDetachStatus

Get the current attach state of a detachable device.

The state is read from the latest drone info telemetry so it follows the device being attached or detached during a session. If no newer telemetry is available, the state reported when the peripheral was discovered is returned.

Returns:

  • GuestPortDetachStatus –

    The detach status. GUEST_PORT_DETACH_STATUS_UNSPECIFIED for devices that cannot be detached.

Source code in blueye/sdk/guestport.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def get_detach_status(self) -> bp.GuestPortDetachStatus:
    """Get the current attach state of a detachable device.

    The state is read from the latest drone info telemetry so it follows the device being
    attached or detached during a session. If no newer telemetry is available, the state
    reported when the peripheral was discovered is returned.

    Returns:
        The detach status. `GUEST_PORT_DETACH_STATUS_UNSPECIFIED` for devices that cannot be
        detached.
    """
    drone_info_tel = self.parent_drone.telemetry.get(bp.DroneInfoTel)
    if drone_info_tel is not None:
        device = _find_device(drone_info_tel.drone_info.gp, self)
        if device is not None:
            return device.detach_status
    return self._detach_status

get_detection

get_detection() -> Optional[LaserDetection]

Get the latest laser dot detection.

The detection carries detected, the two dot centroids, their distance in pixels before and after lens undistortion, the confidence, the frame size, the real distance between the dots and the estimated distance to the subject in metres. Only the X3 Ultra and X7 report it, and only while tracking is enabled.

Returns:

  • Optional[LaserDetection] –

    The detection, or None if the drone has not reported one.

Source code in blueye/sdk/guestport.py
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
def get_detection(self) -> Optional[bp.LaserDetection]:
    """Get the latest laser dot detection.

    The detection carries `detected`, the two dot centroids, their distance in pixels before
    and after lens undistortion, the confidence, the frame size, the real distance between
    the dots and the estimated distance to the subject in metres. Only the X3 Ultra and X7
    report it, and only while tracking is enabled.

    Returns:
        The detection, or None if the drone has not reported one.
    """
    telemetry_msg = self.parent_drone.telemetry.get(bp.LaserTel)
    if telemetry_msg is None or "laser_detection" not in telemetry_msg:
        return None
    return telemetry_msg.laser_detection

get_estimated_distance

get_estimated_distance() -> Optional[float]

Get the estimated distance to the subject the laser dots are on.

Returns:

  • Optional[float] –

    The distance in metres, or None if the dots are not detected.

Source code in blueye/sdk/guestport.py
442
443
444
445
446
447
448
449
450
451
def get_estimated_distance(self) -> Optional[float]:
    """Get the estimated distance to the subject the laser dots are on.

    Returns:
        The distance in metres, or None if the dots are not detected.
    """
    detection = self.get_detection()
    if detection is None or not detection.detected:
        return None
    return detection.estimated_distance

get_intensity

get_intensity() -> Optional[float]

Get the current intensity of the laser.

Returns:

  • Optional[float] –

    The current intensity of the laser.

Source code in blueye/sdk/guestport.py
371
372
373
374
375
376
377
378
379
380
def get_intensity(self) -> Optional[float]:
    """Get the current intensity of the laser.

    Returns:
        The current intensity of the laser.
    """
    laser = self._get_laser()
    if laser is None:
        return None
    return laser.value

is_tracking

is_tracking() -> Optional[bool]

Check whether the laser is modulated for dot tracking.

Returns:

  • Optional[bool] –

    True while the drone modulates the laser, False otherwise, or None if the drone has not reported the laser state.

Source code in blueye/sdk/guestport.py
414
415
416
417
418
419
420
421
422
423
424
def is_tracking(self) -> Optional[bool]:
    """Check whether the laser is modulated for dot tracking.

    Returns:
        True while the drone modulates the laser, False otherwise, or None if the drone has
        not reported the laser state.
    """
    laser = self._get_laser()
    if laser is None:
        return None
    return laser.modulated

set_intensity

set_intensity(
    intensity: float, modulated: Optional[bool] = None
)

Set the intensity of the laser.

If the laser does not support dimming but only on and off, a value of 0 turns the laser off, and any value above 0 turns the laser on.

Parameters:

  • intensity (float) –

    The intensity of the laser (0..1).

  • modulated (bool, default: None ) –

    Whether the laser is modulated for dot tracking. Left out, the setting the drone last reported is kept, so an intensity change does not switch tracking off. For two seconds after the flag was chosen from this object, with this argument or with enable_tracking, that choice is kept instead, since the drone reports the laser once a second and the report may predate it. A call that leaves the flag out does not restart those two seconds, so a script that sets the intensity often still follows what another client does to tracking. See enable_tracking.

Raises:

  • ValueError –

    If the intensity is not between 0 and 1.

Source code in blueye/sdk/guestport.py
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
def set_intensity(self, intensity: float, modulated: Optional[bool] = None):
    """Set the intensity of the laser.

    If the laser does not support dimming but only on and off, a value of 0 turns the laser off,
    and any value above 0 turns the laser on.

    Args:
        intensity (float): The intensity of the laser (0..1).
        modulated (bool, optional): Whether the laser is modulated for dot tracking. Left out,
            the setting the drone last reported is kept, so an intensity change does not
            switch tracking off. For two seconds after the flag was chosen from this object,
            with this argument or with `enable_tracking`, that choice is kept instead, since
            the drone reports the laser once a second and the report may predate it. A call
            that leaves the flag out does not restart those two seconds, so a script that
            sets the intensity often still follows what another client does to tracking. See
            [`enable_tracking`][blueye.sdk.guestport.Laser.enable_tracking].

    Raises:
        ValueError: If the intensity is not between 0 and 1.
    """
    if not 0 <= intensity <= 1:
        raise ValueError("Laser intensity must be between 0 and 1.")
    explicit = modulated is not None
    if modulated is None:
        laser = self._get_laser()
        if self._is_fresh(self._modulation_commanded_at) or laser is None:
            modulated = self._commanded_modulated
        else:
            modulated = laser.modulated
    self._send(intensity, modulated, modulation_explicit=explicit)

Peripheral

Peripheral(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
)

Represents a peripheral device connected to a guest port on the Blueye drone.

Parameters:

Methods:

Attributes:

Source code in blueye/sdk/guestport.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def __init__(
    self, parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
):
    """Initialize the Peripheral class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.
    """
    self.parent_drone = parent_drone
    self.port_number: bp.GuestPortNumber = port_number
    self.name: str = device.name
    self.manufacturer: str = device.manufacturer
    self.serial_number: str = device.serial_number
    self.depth_rating: float = device.depth_rating
    self.required_blunux_version: str = device.required_blunux_version
    self.device_id: bp.GuestPortDeviceID = device.device_id
    self._detach_status: bp.GuestPortDetachStatus = device.detach_status
    self.required_capabilities: List[bp.GuestPortCapability] = list(
        device.required_capabilities
    )
    """Interfaces the device requires from the port it is connected to."""
    self.compatible_guest_ports: List[bp.GuestPortNumber] = list(device.compatible_guest_ports)
    """Ports on this drone where the device is fully supported.

    Computed by the drone from the port capabilities and the device requirements."""
    if self.required_blunux_version != "":
        if version.parse(self.required_blunux_version) > version.parse(
            parent_drone.software_version_short
        ):
            logger.warning(
                f"Peripheral {self.name} requires Blunux version "
                f"{self.required_blunux_version}, but the drone is running "
                f"{parent_drone.software_version_short}"
            )

compatible_guest_ports instance-attribute

compatible_guest_ports: List[GuestPortNumber] = list(
    compatible_guest_ports
)

Ports on this drone where the device is fully supported.

Computed by the drone from the port capabilities and the device requirements.

required_capabilities instance-attribute

required_capabilities: List[GuestPortCapability] = list(
    required_capabilities
)

Interfaces the device requires from the port it is connected to.

get_detach_status

get_detach_status() -> GuestPortDetachStatus

Get the current attach state of a detachable device.

The state is read from the latest drone info telemetry so it follows the device being attached or detached during a session. If no newer telemetry is available, the state reported when the peripheral was discovered is returned.

Returns:

  • GuestPortDetachStatus –

    The detach status. GUEST_PORT_DETACH_STATUS_UNSPECIFIED for devices that cannot be detached.

Source code in blueye/sdk/guestport.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def get_detach_status(self) -> bp.GuestPortDetachStatus:
    """Get the current attach state of a detachable device.

    The state is read from the latest drone info telemetry so it follows the device being
    attached or detached during a session. If no newer telemetry is available, the state
    reported when the peripheral was discovered is returned.

    Returns:
        The detach status. `GUEST_PORT_DETACH_STATUS_UNSPECIFIED` for devices that cannot be
        detached.
    """
    drone_info_tel = self.parent_drone.telemetry.get(bp.DroneInfoTel)
    if drone_info_tel is not None:
        device = _find_device(drone_info_tel.drone_info.gp, self)
        if device is not None:
            return device.detach_status
    return self._detach_status

SkidServo

SkidServo(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
)

Represents the tilt servo for a multibeam sonar.

Covers the skid-mounted servo (first and second generation), which tilts ±28 degrees, and the head-mounted multibeam servo, which tilts ±45 degrees. The drone drives all of them through the same control message, so one class serves all three; min_angle and max_angle give the range of the connected servo.

Parameters:

Methods:

  • get_angle –

    Get the current angle of the multibeam servo.

  • get_detach_status –

    Get the current attach state of a detachable device.

  • get_set_point –

    Get the angle the multibeam servo is moving towards.

  • set_angle –

    Set the angle of the multibeam servo.

Attributes:

Source code in blueye/sdk/guestport.py
591
592
593
594
595
596
597
598
599
600
601
602
603
604
def __init__(
    self, parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
):
    """Initialize the SkidServo class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.
    """
    limit = self._ANGLE_LIMITS.get(device.device_id, 28)
    self.max_angle = limit
    self.min_angle = -limit
    Peripheral.__init__(self, parent_drone, port_number, device)

compatible_guest_ports instance-attribute

compatible_guest_ports: List[GuestPortNumber] = list(
    compatible_guest_ports
)

Ports on this drone where the device is fully supported.

Computed by the drone from the port capabilities and the device requirements.

required_capabilities instance-attribute

required_capabilities: List[GuestPortCapability] = list(
    required_capabilities
)

Interfaces the device requires from the port it is connected to.

get_angle

get_angle() -> float | None

Get the current angle of the multibeam servo.

Returns:

  • float | None –

    The current angle of the servo in degrees. None if telemetry is not available.

Source code in blueye/sdk/guestport.py
622
623
624
625
626
627
628
629
630
631
632
def get_angle(self) -> float | None:
    """Get the current angle of the multibeam servo.

    Returns:
        The current angle of the servo in degrees. None if telemetry is not available.
    """
    telemetry_msg = self.parent_drone.telemetry.get(bp.MultibeamServoTel)
    if telemetry_msg is None:
        return None
    else:
        return telemetry_msg.servo.angle

get_detach_status

get_detach_status() -> GuestPortDetachStatus

Get the current attach state of a detachable device.

The state is read from the latest drone info telemetry so it follows the device being attached or detached during a session. If no newer telemetry is available, the state reported when the peripheral was discovered is returned.

Returns:

  • GuestPortDetachStatus –

    The detach status. GUEST_PORT_DETACH_STATUS_UNSPECIFIED for devices that cannot be detached.

Source code in blueye/sdk/guestport.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def get_detach_status(self) -> bp.GuestPortDetachStatus:
    """Get the current attach state of a detachable device.

    The state is read from the latest drone info telemetry so it follows the device being
    attached or detached during a session. If no newer telemetry is available, the state
    reported when the peripheral was discovered is returned.

    Returns:
        The detach status. `GUEST_PORT_DETACH_STATUS_UNSPECIFIED` for devices that cannot be
        detached.
    """
    drone_info_tel = self.parent_drone.telemetry.get(bp.DroneInfoTel)
    if drone_info_tel is not None:
        device = _find_device(drone_info_tel.drone_info.gp, self)
        if device is not None:
            return device.detach_status
    return self._detach_status

get_set_point

get_set_point() -> float | None

Get the angle the multibeam servo is moving towards.

Returns:

  • float | None –

    The commanded angle in degrees. None if telemetry is not available.

Source code in blueye/sdk/guestport.py
634
635
636
637
638
639
640
641
642
643
644
def get_set_point(self) -> float | None:
    """Get the angle the multibeam servo is moving towards.

    Returns:
        The commanded angle in degrees. None if telemetry is not available.
    """
    telemetry_msg = self.parent_drone.telemetry.get(bp.MultibeamServoTel)
    if telemetry_msg is None:
        return None
    else:
        return telemetry_msg.set_point

set_angle

set_angle(angle: float) -> None

Set the angle of the multibeam servo.

Parameters:

  • angle (float) –

    The angle to set for the servo in degrees, within min_angle and max_angle (±28 for the skid servos, ±45 for the head servo).

Raises:

  • ValueError –

    If the angle is not within the allowed range.

Source code in blueye/sdk/guestport.py
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
def set_angle(self, angle: float) -> None:
    """Set the angle of the multibeam servo.

    Args:
        angle (float): The angle to set for the servo in degrees, within `min_angle` and
            `max_angle` (±28 for the skid servos, ±45 for the head servo).

    Raises:
        ValueError: If the angle is not within the allowed range.
    """
    if not self.min_angle <= angle <= self.max_angle:
        raise ValueError(
            f"Angle must be between {self.min_angle} and {self.max_angle} degrees."
        )
    self.parent_drone._ctrl_client.set_multibeam_servo_angle(angle)

connector_info_to_guest_port

connector_info_to_guest_port(
    parent_drone: Drone,
    connector_info: GuestPortConnectorInfo,
) -> GuestPort

Build a GuestPort from the drone's connector info.

Parameters:

  • parent_drone (Drone) –

    The parent drone instance.

  • connector_info (GuestPortConnectorInfo) –

    The per-port message from GuestPortInfo.

Returns:

  • GuestPort –

    The guest port with its capabilities, connector error, and discovered peripherals.

Source code in blueye/sdk/guestport.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
def connector_info_to_guest_port(
    parent_drone: "Drone", connector_info: bp.GuestPortConnectorInfo
) -> GuestPort:
    """Build a [GuestPort][blueye.sdk.guestport.GuestPort] from the drone's connector info.

    Args:
        parent_drone (Drone): The parent drone instance.
        connector_info (bp.GuestPortConnectorInfo): The per-port message from `GuestPortInfo`.

    Returns:
        The guest port with its capabilities, connector error, and discovered peripherals.
    """
    port = GuestPort(
        number=connector_info.guest_port_number,
        capabilities=list(connector_info.capabilities),
    )
    if "error" in connector_info:
        port.error = connector_info.error
        if port.error == bp.GuestPortError.GUEST_PORT_ERROR_NOT_CONNECTED:
            logger.debug(f"Nothing connected to {describe_enum(port.number)}")
        else:
            logger.warning(
                f"Guest port {describe_enum(port.number)} reports connector error "
                f"{describe_enum(port.error)}"
            )
    else:
        for device in connector_info.device_list.devices:
            port.devices.append(device_to_peripheral(parent_drone, port.number, device))
    return port

device_to_peripheral

device_to_peripheral(
    parent_drone: Drone,
    port_number: GuestPortNumber,
    device: GuestPortDevice,
) -> Peripheral

Convert a device to its corresponding peripheral class.

Parameters:

Returns:

  • Peripheral –

    The corresponding peripheral class instance.

Source code in blueye/sdk/guestport.py
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
def device_to_peripheral(
    parent_drone: "Drone", port_number: bp.GuestPortNumber, device: bp.GuestPortDevice
) -> Peripheral:
    """Convert a device to its corresponding peripheral class.

    Args:
        parent_drone (Drone): The parent drone instance.
        port_number (bp.GuestPortNumber): The guest port number.
        device (bp.GuestPortDevice): The guest port device.

    Returns:
        The corresponding peripheral class instance.
    """
    logger.debug(f"Found a {device.name} at port {port_number}")
    if device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUEYE_CAM:
        peripheral = GuestPortCamera(parent_drone, port_number, device)
    elif (
        device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUEYE_LIGHT
        or device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUEYE_LIGHT_PAIR
        or device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUE_ROBOTICS_LUMEN
    ):
        peripheral = GuestPortLight(parent_drone, port_number, device)
    elif (
        device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUE_ROBOTICS_NEWTON
        or device.device_id
        == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUE_ROBOTICS_DETACHABLE_NEWTON
        or device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUEPRINT_LAB_REACH_ALPHA
    ):
        peripheral = Gripper(parent_drone, port_number, device)
    elif (
        device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUEYE_SCALING_LASER
        or device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_LASER_TOOLS_SEA_BEAM
        or device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_SPOT_X_LASER_SCALERS
    ):
        peripheral = Laser(parent_drone, port_number, device)
    elif device.device_id == bp.GuestPortDeviceID.GUEST_PORT_DEVICE_ID_BLUEYE_GENERIC_SERVO:
        peripheral = GenericServo(parent_drone, port_number, device)
    elif device.device_id in SkidServo._ANGLE_LIMITS:
        peripheral = SkidServo(parent_drone, port_number, device)
    else:
        peripheral = Peripheral(parent_drone, port_number, device)
    return peripheral