Skip to content

blueye.sdk.drone

drone

Classes:

  • Config –

    Handles the configuration settings for the Blueye drone.

  • Drone –

    A class providing an interface to a Blueye drone's functions.

  • Telemetry –

    Handles the telemetry messages for the Blueye drone.

Config

Config(parent_drone: 'Drone')

Handles the configuration settings for the Blueye drone.

Parameters:

  • parent_drone (Drone) –

    The parent drone instance.

Methods:

Source code in blueye/sdk/drone.py
55
56
57
58
59
60
61
62
def __init__(self, parent_drone: "Drone"):
    """Initialize the Config class.

    Args:
        parent_drone (Drone): The parent drone instance.
    """
    self._parent_drone = parent_drone
    self._water_density: Optional[float] = None

get_water_density

get_water_density() -> Optional[float]

Get the water density this SDK instance last sent to the drone.

The drone does not report the density it uses, and the Blueye app sends its own value whenever it takes control, so the drone's value cannot be read here. This method returns what set_water_density sent, or None if nothing has been sent in this session.

The drone starts with salt water, 1025 grams per liter, until a client sets another value.

Returns:

  • Optional[float] –

    The water density in grams per liter last set through this object, or None.

Source code in blueye/sdk/drone.py
64
65
66
67
68
69
70
71
72
73
74
75
76
def get_water_density(self) -> Optional[float]:
    """Get the water density this SDK instance last sent to the drone.

    The drone does not report the density it uses, and the Blueye app sends its own value
    whenever it takes control, so the drone's value cannot be read here. This method returns
    what `set_water_density` sent, or `None` if nothing has been sent in this session.

    The drone starts with salt water, 1025 grams per liter, until a client sets another value.

    Returns:
        The water density in grams per liter last set through this object, or `None`.
    """
    return self._water_density

set_drone_time

set_drone_time(time: int)

Set the system time for the drone.

This method is used to set the system time for the drone. The argument time is expected to be a Unix timestamp (i.e., the number of seconds since the epoch).

Parameters:

  • time (int) –

    The Unix timestamp to set.

Source code in blueye/sdk/drone.py
 97
 98
 99
100
101
102
103
104
105
106
def set_drone_time(self, time: int):
    """Set the system time for the drone.

    This method is used to set the system time for the drone. The argument `time` is expected to
    be a Unix timestamp (i.e., the number of seconds since the epoch).

    Args:
        time (int): The Unix timestamp to set.
    """
    self._parent_drone._req_rep_client.sync_time(time)

set_water_density

set_water_density(density: float)

Set the water density the drone uses to convert pressure to depth.

The drone starts with salt water, 1025 grams per liter. The Blueye app sends the salinity chosen by the pilot each time it takes control, so a value set here lasts until the app or another client sends a new one. The drone rescales its current depth reading when the density changes.

The WaterDensities class contains typical densities for salty-, brackish-, and fresh water (these are the same values that the Blueye app uses).

Parameters:

  • density (float) –

    The water density in grams per liter.

Source code in blueye/sdk/drone.py
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def set_water_density(self, density: float):
    """Set the water density the drone uses to convert pressure to depth.

    The drone starts with salt water, 1025 grams per liter. The Blueye app sends the salinity
    chosen by the pilot each time it takes control, so a value set here lasts until the app
    or another client sends a new one. The drone rescales its current depth reading when the
    density changes.

    The [WaterDensities][blueye.sdk.constants.WaterDensities] class contains typical densities
    for salty-, brackish-, and fresh water (these are the same values that the Blueye app uses).

    Args:
        density (float): The water density in grams per liter.
    """
    self._parent_drone._ctrl_client.set_water_density(density)
    self._water_density = density

Drone

Drone(
    ip="192.168.1.101",
    auto_connect=True,
    timeout=10,
    disconnect_other_clients=False,
    connect_as_observer=False,
    **connect_args: Dict[str, Any]
)

A class providing an interface to a Blueye drone's functions.

Automatically connects to the drone using the default IP when instantiated. This behavior can be disabled by setting auto_connect=False.

Parameters:

  • ip (str, default: '192.168.1.101' ) –

    The IP address of the drone.

  • auto_connect (bool, default: True ) –

    Whether to automatically connect to the drone.

  • timeout (int, default: 10 ) –

    The timeout for the connection attempt.

  • disconnect_other_clients (bool, default: False ) –

    Whether to disconnect other clients.

  • connect_as_observer (bool, default: False ) –

    Whether to connect as an observer.

  • **connect_args (Dict[str, Any], default: {} ) –

    Additional keyword arguments to pass to the connect method.

Methods:

Attributes:

  • battery –

    Battery state, see Battery.

  • camera –

    The main camera: recording, pictures and camera parameters.

  • client_id (int) –

    The id the drone assigned to this client when connecting, None before that.

  • config –

    Drone time and water density, see Config.

  • connected –

    Whether the drone is connected.

  • cv_models –

    Computer vision models installed on the drone.

  • external_camera (Optional[GuestPortCamera]) –

    Camera on a guest port, or None if none has been discovered.

  • external_light (Optional[GuestPortLight]) –

    Light on a guest port, or None if none has been discovered.

  • features (List[str]) –

    Optional hardware the drone reported when connecting, as a list of names.

  • gripper (Optional[Gripper]) –

    Gripper on a guest port, or None if none has been discovered.

  • in_control (bool) –

    Whether this client held control when it connected or last took control.

  • laser (Optional[Laser]) –

    Scaling laser on a guest port, or None if none has been discovered.

  • legacy_logs –

    Logs in the CSV format of Blunux versions before 3.0.

  • logs –

    The dive logs stored on the drone, see Logs.

  • mission –

    Loading and running missions, see Mission.

  • motion –

    Thruster input and the auto modes, see Motion.

  • peripherals (Optional[List[Peripheral]]) –

    The peripherals connected to the drone's guest ports.

  • serial_number (str) –

    The drone's serial number. Set when connecting.

  • servo (Optional[GenericServo]) –

    Generic servo on a guest port, or None if none has been discovered.

  • skid_servo (Optional[SkidServo]) –

    Multibeam (skid) servo on a guest port, or None if none has been discovered.

  • software_version (str) –

    The full Blunux version string, such as "5.2.212-wrynose-jetson-dev".

  • software_version_short (str) –

    The Blunux version number without the build suffix, such as "5.2.212".

  • telemetry –

    Telemetry messages, callbacks and publish rates.

  • uuid (str) –

    The drone's hardware id. Set when connecting.

Source code in blueye/sdk/drone.py
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
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
370
371
372
373
374
375
376
377
378
379
380
381
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
def __init__(
    self,
    ip="192.168.1.101",
    auto_connect=True,
    timeout=10,
    disconnect_other_clients=False,
    connect_as_observer=False,
    **connect_args: Dict[str, Any],
):
    """Initialize the Drone class.

    Args:
        ip (str, optional):
            The IP address of the drone.
        auto_connect (bool, optional):
            Whether to automatically connect to the drone.
        timeout (int, optional):
            The timeout for the connection attempt.
        disconnect_other_clients (bool, optional):
            Whether to disconnect other clients.
        connect_as_observer (bool, optional):
            Whether to connect as an observer.
        **connect_args:
            Additional keyword arguments to pass to the [`connect`][blueye.sdk.drone.Drone.connect]
            method.
    """
    self._ip = ip
    self.camera = Camera(self, is_guestport_camera=False)
    """The main camera: recording, pictures and camera parameters.

    See [`Camera`][blueye.sdk.camera.Camera]. Camera tilt is under `camera.tilt`
    ([`Tilt`][blueye.sdk.camera.Tilt]) and the video overlay under `camera.overlay`
    ([`Overlay`][blueye.sdk.camera.Overlay])."""
    self.motion = Motion(self)
    """Thruster input and the auto modes, see [`Motion`][blueye.sdk.motion.Motion]."""
    self.logs = Logs(self)
    """The dive logs stored on the drone, see [`Logs`][blueye.sdk.logs.Logs]."""
    self.legacy_logs = LegacyLogs(self)
    """Logs in the CSV format of Blunux versions before 3.0.

    See [`LegacyLogs`][blueye.sdk.logs.LegacyLogs]."""
    self.config = Config(self)
    """Drone time and water density, see [`Config`][blueye.sdk.drone.Config]."""
    self.battery = Battery(self)
    """Battery state, see [`Battery`][blueye.sdk.battery.Battery]."""
    self.telemetry = Telemetry(self)
    """Telemetry messages, callbacks and publish rates.

    See [`Telemetry`][blueye.sdk.drone.Telemetry]."""
    self.mission = Mission(self)
    """Loading and running missions, see [`Mission`][blueye.sdk.mission.Mission]."""
    self.cv_models = CvModels(self)
    """Computer vision models installed on the drone.

    See [`CvModels`][blueye.sdk.cv_models.CvModels]."""
    self.connected = False
    """Whether the drone is connected.

    True between a successful [`connect`][blueye.sdk.drone.Drone.connect] and
    [`disconnect`][blueye.sdk.drone.Drone.disconnect]."""
    self.client_id: int = None
    """The id the drone assigned to this client when connecting, `None` before that."""
    self.in_control: bool = False
    """Whether this client held control when it connected or last took control.

    Set by [`connect`][blueye.sdk.drone.Drone.connect] and
    [`take_control`][blueye.sdk.drone.Drone.take_control]. Not updated when the drone hands
    control to another client; compare
    [`get_client_in_control`][blueye.sdk.drone.Drone.get_client_in_control] with
    `client_id` for the current state."""
    # Set by connect() from the drone's HTTP drone_info. Declared here, without a value, so
    # the reference documents them; reading one before connecting raises AttributeError.
    self.features: List[str]
    """Optional hardware the drone reported when connecting, as a list of names.

    `"tilt"` on every model except the original Pioneer, `"gpdrone"` on drones with guest
    ports, and `"gplight"`, `"gpcam"` and `"gripper"` when such a device is attached. The
    [`Tilt`][blueye.sdk.camera.Tilt] methods raise `RuntimeError` without `"tilt"`. Not
    updated while connected. Empty when the drone could not read its hardware within its own
    5 s limit and answered with default information instead. Use
    [`peripherals`][blueye.sdk.drone.Drone.peripherals] for the attached devices."""
    self.software_version: str
    """The full Blunux version string, such as `"5.2.212-wrynose-jetson-dev"`.

    Set when connecting."""
    self.software_version_short: str
    """The Blunux version number without the build suffix, such as `"5.2.212"`.

    Set when connecting."""
    self.serial_number: str
    """The drone's serial number. Set when connecting."""
    self.uuid: str
    """The drone's hardware id. Set when connecting."""
    # The drone's persistent storage settings from drone_info, which say which media the
    # drone writes at all. None until read, and on drones that do not report them.
    self._storage_settings: Optional[Dict[str, bool]] = None
    # The drone's service list from drone_info, which carries its video stream URLs. None
    # until read, and on drones that do not report it.
    self._services: Optional[List[dict]] = None
    self._watchdog_publisher = _NoConnectionClient()
    self._telemetry_watcher = _NoConnectionClient()
    self._req_rep_client = _NoConnectionClient()
    self._ctrl_client = _NoConnectionClient()

    self.peripherals: Optional[List[Peripheral]] = None
    """The peripherals connected to the drone's guest ports.

    `None` until the drone has reported its guest ports (through `DroneInfoTel`), and an
    empty list when the drone reports no peripherals.

    The drone can report its guest ports after `connect()` returns, so the shortcuts below
    can still be `None` right after connecting. While `peripherals` is `None`, a `None`
    shortcut means "not reported yet" rather than "not attached". Every shortcut is `None`
    again after `disconnect()`."""
    self._guest_ports: Optional[List[GuestPort]] = None
    self.external_camera: Optional[GuestPortCamera] = None
    """Camera on a guest port, or `None` if none has been discovered.

    See [`peripherals`][blueye.sdk.drone.Drone.peripherals]."""
    self.external_light: Optional[GuestPortLight] = None
    """Light on a guest port, or `None` if none has been discovered.

    See [`peripherals`][blueye.sdk.drone.Drone.peripherals]."""
    self.gripper: Optional[Gripper] = None
    """Gripper on a guest port, or `None` if none has been discovered.

    See [`peripherals`][blueye.sdk.drone.Drone.peripherals]."""
    self.laser: Optional[Laser] = None
    """Scaling laser on a guest port, or `None` if none has been discovered.

    See [`peripherals`][blueye.sdk.drone.Drone.peripherals]."""
    self.servo: Optional[GenericServo] = None
    """Generic servo on a guest port, or `None` if none has been discovered.

    See [`peripherals`][blueye.sdk.drone.Drone.peripherals]."""
    self.skid_servo: Optional[SkidServo] = None
    """Multibeam (skid) servo on a guest port, or `None` if none has been discovered.

    See [`peripherals`][blueye.sdk.drone.Drone.peripherals]."""
    self._guest_ports_known = False
    self._drone_info_cb_id: Optional[str] = None
    # The drone publishes one GenericServoTel per guest port under the same message type, so
    # the telemetry store only keeps the last one. This keeps the latest per port, filled by
    # a callback that is registered while a generic servo is discovered.
    self._generic_servo_tel: Dict[
        blueye.protocol.GuestPortNumber, blueye.protocol.GenericServoTel
    ] = {}
    self._generic_servo_cb_id: Optional[str] = None

    if auto_connect is True:
        self.connect(
            timeout=timeout,
            disconnect_other_clients=disconnect_other_clients,
            connect_as_observer=connect_as_observer,
            **connect_args,
        )

battery instance-attribute

battery = Battery(self)

Battery state, see Battery.

camera instance-attribute

camera = Camera(self, is_guestport_camera=False)

The main camera: recording, pictures and camera parameters.

See Camera. Camera tilt is under camera.tilt (Tilt) and the video overlay under camera.overlay (Overlay).

client_id instance-attribute

client_id: int = None

The id the drone assigned to this client when connecting, None before that.

config instance-attribute

config = Config(self)

Drone time and water density, see Config.

connected instance-attribute

connected = False

Whether the drone is connected.

True between a successful connect and disconnect.

cv_models instance-attribute

cv_models = CvModels(self)

Computer vision models installed on the drone.

See CvModels.

external_camera instance-attribute

external_camera: Optional[GuestPortCamera] = None

Camera on a guest port, or None if none has been discovered.

See peripherals.

external_light instance-attribute

external_light: Optional[GuestPortLight] = None

Light on a guest port, or None if none has been discovered.

See peripherals.

features instance-attribute

features: List[str]

Optional hardware the drone reported when connecting, as a list of names.

"tilt" on every model except the original Pioneer, "gpdrone" on drones with guest ports, and "gplight", "gpcam" and "gripper" when such a device is attached. The Tilt methods raise RuntimeError without "tilt". Not updated while connected. Empty when the drone could not read its hardware within its own 5 s limit and answered with default information instead. Use peripherals for the attached devices.

gripper instance-attribute

gripper: Optional[Gripper] = None

Gripper on a guest port, or None if none has been discovered.

See peripherals.

in_control instance-attribute

in_control: bool = False

Whether this client held control when it connected or last took control.

Set by connect and take_control. Not updated when the drone hands control to another client; compare get_client_in_control with client_id for the current state.

laser instance-attribute

laser: Optional[Laser] = None

Scaling laser on a guest port, or None if none has been discovered.

See peripherals.

legacy_logs instance-attribute

legacy_logs = LegacyLogs(self)

Logs in the CSV format of Blunux versions before 3.0.

See LegacyLogs.

logs instance-attribute

logs = Logs(self)

The dive logs stored on the drone, see Logs.

mission instance-attribute

mission = Mission(self)

Loading and running missions, see Mission.

motion instance-attribute

motion = Motion(self)

Thruster input and the auto modes, see Motion.

peripherals instance-attribute

peripherals: Optional[List[Peripheral]] = None

The peripherals connected to the drone's guest ports.

None until the drone has reported its guest ports (through DroneInfoTel), and an empty list when the drone reports no peripherals.

The drone can report its guest ports after connect() returns, so the shortcuts below can still be None right after connecting. While peripherals is None, a None shortcut means "not reported yet" rather than "not attached". Every shortcut is None again after disconnect().

serial_number instance-attribute

serial_number: str

The drone's serial number. Set when connecting.

servo instance-attribute

servo: Optional[GenericServo] = None

Generic servo on a guest port, or None if none has been discovered.

See peripherals.

skid_servo instance-attribute

skid_servo: Optional[SkidServo] = None

Multibeam (skid) servo on a guest port, or None if none has been discovered.

See peripherals.

software_version instance-attribute

software_version: str

The full Blunux version string, such as "5.2.212-wrynose-jetson-dev".

Set when connecting.

software_version_short instance-attribute

software_version_short: str

The Blunux version number without the build suffix, such as "5.2.212".

Set when connecting.

telemetry instance-attribute

telemetry = Telemetry(self)

Telemetry messages, callbacks and publish rates.

See Telemetry.

uuid instance-attribute

uuid: str

The drone's hardware id. Set when connecting.

__enter__

__enter__() -> Drone

Use the drone in a with block, see __exit__.

Source code in blueye/sdk/drone.py
909
910
911
def __enter__(self) -> Drone:
    """Use the drone in a `with` block, see [`__exit__`][blueye.sdk.drone.Drone.__exit__]."""
    return self

__exit__

__exit__(exc_type, exc_value, traceback)

Disconnect when the with block ends, however it ends.

Usage::

with Drone() as drone:
    drone.motion.set_surge(0.5)
    ...
# Thrusters zeroed and the drone told that we left, even after an exception
Source code in blueye/sdk/drone.py
913
914
915
916
917
918
919
920
921
922
923
924
def __exit__(self, exc_type, exc_value, traceback):
    """Disconnect when the `with` block ends, however it ends.

    Usage::

        with Drone() as drone:
            drone.motion.set_surge(0.5)
            ...
        # Thrusters zeroed and the drone told that we left, even after an exception
    """
    if self.connected:
        self.disconnect()

connect

connect(
    client_info: ClientInfo = None,
    timeout: float = 4,
    disconnect_other_clients: bool = False,
    connect_as_observer: bool = False,
    log_notifications: bool = False,
)

Establish a connection to the drone.

Spawns several threads for receiving telemetry, sending control messages, and publishing watchdog messages.

A watchdog message from the client in control arms the thrusters. When this connection receives control during setup, the SDK zeroes the thruster setpoints and synchronizes the drone's clock. An observer connection does neither and is excluded from control handover. Observer mode does not prevent setters from sending commands.

Parameters:

  • client_info (ClientInfo, default: None ) –

    Information about the client connecting. If None, the SDK supplies its version and uses Python's platform module for the OS and hostname shown in the app.

  • timeout (float, default: 4 ) –

    Seconds to wait for connection.

  • disconnect_other_clients (bool, default: False ) –

    If True, disconnect clients until the drone reports that we are in control.

  • connect_as_observer (bool, default: False ) –

    If True, the client will not be promoted to in control of the drone.

  • log_notifications (bool, default: False ) –

    If True, the notifications will be logged using the logging module.

Raises:

  • ConnectionError –

    If the connection attempt fails.

  • RuntimeError –

    If the Blunux version of the connected drone is too old.

Source code in blueye/sdk/drone.py
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
def connect(
    self,
    client_info: blueye.protocol.ClientInfo = None,
    timeout: float = 4,
    disconnect_other_clients: bool = False,
    connect_as_observer: bool = False,
    log_notifications: bool = False,
):
    """Establish a connection to the drone.

    Spawns several threads for receiving telemetry, sending control messages, and publishing
    watchdog messages.

    A watchdog message from the client in control arms the thrusters. When this connection
    receives control during setup, the SDK zeroes the thruster setpoints and synchronizes the
    drone's clock. An observer connection does neither and is excluded from control handover.
    Observer mode does not prevent setters from sending commands.

    Args:
        client_info (blueye.protocol.ClientInfo, optional):
            Information about the client connecting. If None, the SDK supplies its version
            and uses Python's `platform` module for the OS and hostname shown in the app.
        timeout (float, optional):
            Seconds to wait for connection.
        disconnect_other_clients (bool, optional):
            If True, disconnect clients until the drone reports that we are in control.
        connect_as_observer (bool, optional):
            If True, the client will not be promoted to in control of the drone.
        log_notifications (bool, optional):
            If True, the notifications will be logged using the logging module.

    Raises:
        ConnectionError: If the connection attempt fails.
        RuntimeError: If the Blunux version of the connected drone is too old.
    """
    logger.info(f"Attempting to connect to drone at {self._ip}")
    time_connection_start = time.time()
    self._update_drone_info(timeout=timeout)
    self._verify_required_blunux_version("3.2")

    self._telemetry_watcher = TelemetryClient(self)
    self._ctrl_client = CtrlClient(self)
    self._watchdog_publisher = WatchdogPublisher(self)
    self._req_rep_client = ReqRepClient(self)

    self._telemetry_watcher.start()
    self._req_rep_client.start()
    self._ctrl_client.start()

    # Anything that fails from here on must not leave the threads behind. A watchdog thread
    # that outlives a failed connect() would pet the drone as client 0, which the drone takes
    # as the client in control whenever nobody is, and that keeps its failsafe from tripping.
    try:
        self._connect(
            client_info, disconnect_other_clients, connect_as_observer, log_notifications
        )
    except BaseException:
        self._stop_clients()
        raise
    logger.debug("Connected in {:.2f} seconds".format(time.time() - time_connection_start))

disconnect

disconnect(timeout: float = 1.0)

Disconnects the connection, allowing another client to take control of the drone.

The drone keeps the last motion input it received until a new one arrives or its watchdog times out, and on a handover to another client the watchdog never times out. So when this client is in control, every setpoint is zeroed and sent before the drone is told that the client is leaving.

Does nothing when there is no connection, such as after a failed connect(), so it is safe in a finally block.

Parameters:

  • timeout (float, default: 1.0 ) –

    Seconds to wait for the zero setpoint and any other queued control message to go out before the disconnect request is sent.

Source code in blueye/sdk/drone.py
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
def disconnect(self, timeout: float = 1.0):
    """Disconnects the connection, allowing another client to take control of the drone.

    The drone keeps the last motion input it received until a new one arrives or its
    watchdog times out, and on a handover to another client the watchdog never times out.
    So when this client is in control, every setpoint is zeroed and sent before the drone is
    told that the client is leaving.

    Does nothing when there is no connection, such as after a failed `connect()`, so it is
    safe in a `finally` block.

    Args:
        timeout (float, optional): Seconds to wait for the zero setpoint and any other
            queued control message to go out before the disconnect request is sent.
    """
    if isinstance(self._req_rep_client, _NoConnectionClient):
        # Never connected, already disconnected, or connect() failed and stopped the threads
        return
    if self.connected:
        # No motion input from other threads or callbacks after this, so that the zero is
        # the last input the drone gets from this client
        in_control = self._has_control_now()
        self.motion._stop_input(zero=in_control)
        if in_control and not self._ctrl_client.flush(timeout):
            logger.warning("The zero thruster setpoint did not go out before disconnecting")
    self.connected = False
    _connected_drones.discard(self)
    try:
        self._req_rep_client.disconnect_client(self.client_id)
    except blueye.protocol.exceptions.ResponseTimeout:
        # If there's no response the connection is likely already closed, so we can just
        # continue to stop threads and disconnect
        pass
    self._stop_clients()

get_active_video_streams

get_active_video_streams() -> Dict[str, int]

Get the number of currently active connections to the video stream.

Every RTSP session counts, whether it comes from the Blueye app, GStreamer, VLC or OpenCV. A session counts from the moment the player sets it up. It stops counting when the player closes the main camera stream, or when the session times out, about 5 seconds after the player stops keeping it alive; the guest port camera stream only drops sessions on the timeout. The drone publishes the count once a second. Each stream accepts 4 sessions; a player that asks for a fifth is refused, see Live video streams.

Returns:

  • Dict[str, int] –

    A dictionary with the number of active connections to the main and guestport video streams.

Source code in blueye/sdk/drone.py
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
def get_active_video_streams(self) -> Dict[str, int]:
    """Get the number of currently active connections to the video stream.

    Every RTSP session counts, whether it comes from the Blueye app, GStreamer, VLC or
    OpenCV. A session counts from the moment the player sets it up. It stops counting when
    the player closes the main camera stream, or when the session times out, about 5 seconds
    after the player stops keeping it alive; the guest port camera stream only drops
    sessions on the timeout. The drone publishes the count once a second. Each stream accepts
    4 sessions; a player that asks for a fifth is refused, see
    [Live video streams](../../../video/streams.md).

    Returns:
        A dictionary with the number of active connections to the main and guestport video
        streams.
    """
    n_streamers_msg_tel = self.telemetry.get(blueye.protocol.NStreamersTel)
    if n_streamers_msg_tel is None:
        return None
    n_streamers_msg = n_streamers_msg_tel.n_streamers
    return {"main": n_streamers_msg.main, "guestport": n_streamers_msg.guestport}

get_altitude

get_altitude() -> Optional[float]

Get the current altitude in meters.

If the drone has a DVL or a positioning system with a valid reading, this method will return the current altitude.

Returns:

  • Optional[float] –

    The altitude in meters above the bottom.

Source code in blueye/sdk/drone.py
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
def get_altitude(self) -> Optional[float]:
    """Get the current altitude in meters.

    If the drone has a DVL or a positioning system with a valid reading, this method will
    return the current altitude.

    Returns:
        The altitude in meters above the bottom.
    """
    altitude_tel = self.telemetry.get(blueye.protocol.AltitudeTel)
    if altitude_tel is None or altitude_tel.altitude.is_valid is False:
        return None
    else:
        return altitude_tel.altitude.value

get_attitude

get_attitude() -> Optional[Dict[str, float]]

Get the current orientation of the drone as signed angles.

Unlike get_pose, the angles are returned as the drone reports them: 0 when the drone is level and pointing north, with small deviations keeping their sign. A roll to the right and a pitch with the nose up are positive. This is the natural form when working with the roll and pitch input on the Blueye X7.

Returns:

  • Optional[Dict[str, float]] –

    A dictionary with roll, pitch, and yaw in degrees, from -180 to 180. None if no attitude telemetry has been received.

Source code in blueye/sdk/drone.py
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
def get_attitude(self) -> Optional[Dict[str, float]]:
    """Get the current orientation of the drone as signed angles.

    Unlike `get_pose`, the angles are returned as the drone reports them: 0 when the drone is
    level and pointing north, with small deviations keeping their sign. A roll to the right and
    a pitch with the nose up are positive. This is the natural form when working with the roll
    and pitch input on the Blueye X7.

    Returns:
        A dictionary with roll, pitch, and yaw in degrees, from -180 to 180. None if no
        attitude telemetry has been received.
    """
    attitude_tel = self.telemetry.get(blueye.protocol.AttitudeTel)
    if attitude_tel is None:
        return None
    attitude = attitude_tel.attitude
    return {
        "roll": attitude.roll,
        "pitch": attitude.pitch,
        "yaw": attitude.yaw,
    }

get_client_in_control

get_client_in_control() -> Optional[int]

Get the client ID of the client in control of the drone.

Returns:

  • Optional[int] –

    The client ID in control, 0 if nobody holds control, or None if client-list telemetry has not arrived.

Source code in blueye/sdk/drone.py
940
941
942
943
944
945
946
947
948
949
950
951
def get_client_in_control(self) -> Optional[int]:
    """Get the client ID of the client in control of the drone.

    Returns:
        The client ID in control, 0 if nobody holds control, or None if client-list
        telemetry has not arrived.
    """
    clients_tel = self.telemetry.get(blueye.protocol.ConnectedClientsTel)
    if clients_tel is None:
        return None
    else:
        return clients_tel.client_id_in_control

get_connected_clients

get_connected_clients() -> Optional[List[ConnectedClient]]

Get a list of connected clients.

Returns:

  • Optional[List[ConnectedClient]] –

    A list of connected clients, or None if client-list telemetry has not arrived.

Source code in blueye/sdk/drone.py
926
927
928
929
930
931
932
933
934
935
936
def get_connected_clients(self) -> Optional[List[blueye.protocol.ConnectedClient]]:
    """Get a list of connected clients.

    Returns:
        A list of connected clients, or None if client-list telemetry has not arrived.
    """
    clients_tel = self.telemetry.get(blueye.protocol.ConnectedClientsTel)
    if clients_tel is None:
        return None
    else:
        return list(clients_tel.connected_clients)

get_depth

get_depth() -> Optional[float]

Get the current depth in meters.

Returns:

  • Optional[float] –

    The depth in meters of water column.

Source code in blueye/sdk/drone.py
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
def get_depth(self) -> Optional[float]:
    """Get the current depth in meters.

    Returns:
        The depth in meters of water column.
    """
    depth_tel = self.telemetry.get(blueye.protocol.DepthTel)
    if depth_tel is None:
        return None
    else:
        return depth_tel.depth.value

get_depth_sensor_type

get_depth_sensor_type() -> Optional[PressureSensorType]

Get the type of depth sensor connected to the drone.

Returns:

  • Optional[PressureSensorType] –

    The depth sensor type, or None if no DroneInfo message has been received yet.

Source code in blueye/sdk/drone.py
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
def get_depth_sensor_type(self) -> Optional[blueye.protocol.PressureSensorType]:
    """Get the type of depth sensor connected to the drone.

    Returns:
        The depth sensor type, or None if no `DroneInfo` message has been received yet.
    """
    drone_info = self.get_drone_info()
    if drone_info is None:
        return None
    return drone_info.depth_sensor

get_dive_time

get_dive_time() -> Optional[int]

Get the amount of time the drone has been submerged.

The drone starts incrementing this value when the depth is above 250 mm.

Returns:

  • Optional[int] –

    The time in seconds the drone has been submerged.

Source code in blueye/sdk/drone.py
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
def get_dive_time(self) -> Optional[int]:
    """Get the amount of time the drone has been submerged.

    The drone starts incrementing this value when the depth is above 250 mm.

    Returns:
        The time in seconds the drone has been submerged.
    """
    dive_time_tel = self.telemetry.get(blueye.protocol.DiveTimeTel)
    if dive_time_tel is None:
        return None
    else:
        return dive_time_tel.dive_time.value

get_drone_info

get_drone_info() -> Optional[DroneInfo]

Get the identity and hardware information the drone publishes about itself.

This is the DroneInfo message from the DroneInfoTel telemetry message. It carries the drone model, serial numbers, the depth sensor type, the power source, the installed computer vision models, the guest port configuration and, on the X3 Ultra and X7, the main camera calibration.

Returns:

  • Optional[DroneInfo] –

    The latest DroneInfo message, or None if it has not been received yet.

Source code in blueye/sdk/drone.py
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
def get_drone_info(self) -> Optional[blueye.protocol.DroneInfo]:
    """Get the identity and hardware information the drone publishes about itself.

    This is the `DroneInfo` message from the `DroneInfoTel` telemetry message. It carries the
    drone model, serial numbers, the depth sensor type, the power source, the installed
    computer vision models, the guest port configuration and, on the X3 Ultra and X7, the
    main camera calibration.

    Returns:
        The latest `DroneInfo` message, or None if it has not been received yet.
    """
    drone_info_tel = self.telemetry.get(blueye.protocol.DroneInfoTel)
    if drone_info_tel is None:
        return None
    return drone_info_tel.drone_info

get_error_flags

get_error_flags() -> Optional[Dict[str, bool]]

Get the error flags.

The flags are the fields of the ErrorFlags message, true while the error is present. The IMU flags in IMU_ERROR_FLAGS are left out on drones running Blunux older than 5.2, which do not report them.

Returns:

  • Optional[Dict[str, bool]] –

    The error flags as bools in a dictionary, or None if no ErrorFlagsTel message has been received.

Source code in blueye/sdk/drone.py
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
def get_error_flags(self) -> Optional[Dict[str, bool]]:
    """Get the error flags.

    The flags are the fields of the
    [`ErrorFlags`][blueye.protocol.types.message_formats.ErrorFlags] message, true while the
    error is present. The IMU flags in
    [`IMU_ERROR_FLAGS`][blueye.sdk.constants.IMU_ERROR_FLAGS] are left out on drones running
    Blunux older than 5.2, which do not report them.

    Returns:
        The error flags as bools in a dictionary, or None if no `ErrorFlagsTel` message has
        been received.
    """
    error_flags_tel = self.telemetry.get(blueye.protocol.ErrorFlagsTel)
    if error_flags_tel is None:
        return None
    error_flags_msg = error_flags_tel.error_flags
    reports_imu_flags = version.parse(self.software_version_short) >= version.parse("5.2")
    error_flags = {}
    possible_flags = [attr for attr in dir(error_flags_msg) if not attr.startswith("__")]
    for flag in possible_flags:
        if flag in IMU_ERROR_FLAGS and not reports_imu_flags:
            continue
        error_flags[flag] = getattr(error_flags_msg, flag)
    return error_flags

get_guest_ports

get_guest_ports() -> Optional[List[GuestPort]]

Get the state of every guest port on the drone.

Each entry carries the port number, the interfaces the port provides, the connector error the drone reports for it (if any), and the peripherals discovered on it. A port with nothing plugged in reports GUEST_PORT_ERROR_NOT_CONNECTED and no devices.

Returns:

  • Optional[List[GuestPort]] –

    One GuestPort per port the drone reports, or None if no guest port information has been received from the drone yet.

Source code in blueye/sdk/drone.py
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
def get_guest_ports(self) -> Optional[List[GuestPort]]:
    """Get the state of every guest port on the drone.

    Each entry carries the port number, the interfaces the port provides, the connector error
    the drone reports for it (if any), and the peripherals discovered on it. A port with
    nothing plugged in reports `GUEST_PORT_ERROR_NOT_CONNECTED` and no devices.

    Returns:
        One [GuestPort][blueye.sdk.guestport.GuestPort] per port the drone reports, or `None`
        if no guest port information has been received from the drone yet.
    """
    return self._guest_ports

get_lights

get_lights() -> Optional[float]

Get the intensity of the drone lights.

Returns:

  • Optional[float] –

    The intensity of the drone light (0..1). None if no telemetry message has been received.

Source code in blueye/sdk/drone.py
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
def get_lights(self) -> Optional[float]:
    """Get the intensity of the drone lights.

    Returns:
        The intensity of the drone light (0..1). `None` if no telemetry message has been
        received.
    """
    lights_tel = self.telemetry.get(blueye.protocol.LightsTel)
    if lights_tel is None:
        return None
    return lights_tel.lights.value

get_model

get_model() -> Optional[Model]

Get the model of the connected drone.

The model is read from the DroneInfoTel telemetry message. The HTTP drone_info endpoint also reports a model_name string, but its formatting varies between drones, so it is not used.

Returns:

  • Optional[Model] –

    The drone model, or None if no DroneInfo message has been received yet.

Source code in blueye/sdk/drone.py
971
972
973
974
975
976
977
978
979
980
981
982
983
984
def get_model(self) -> Optional[blueye.protocol.Model]:
    """Get the model of the connected drone.

    The model is read from the `DroneInfoTel` telemetry message. The HTTP `drone_info`
    endpoint also reports a `model_name` string, but its formatting varies between drones, so
    it is not used.

    Returns:
        The drone model, or None if no `DroneInfo` message has been received yet.
    """
    drone_info = self.get_drone_info()
    if drone_info is None:
        return None
    return drone_info.model

get_pose

get_pose() -> Optional[Dict[str, float]]

Get the current orientation of the drone.

The angles are wrapped to 0..359, so a drone rolled slightly to the left reports a roll just below 360. Use get_attitude for signed angles.

Returns:

  • Optional[Dict[str, float]] –

    A dictionary with roll, pitch, and yaw in degrees, from 0 to 359. None if no attitude telemetry has been received.

Source code in blueye/sdk/drone.py
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
def get_pose(self) -> Optional[Dict[str, float]]:
    """Get the current orientation of the drone.

    The angles are wrapped to 0..359, so a drone rolled slightly to the left reports a roll
    just below 360. Use `get_attitude` for signed angles.

    Returns:
        A dictionary with roll, pitch, and yaw in degrees, from 0 to 359. None if no attitude
        telemetry has been received.
    """
    attitude_tel = self.telemetry.get(blueye.protocol.AttitudeTel)
    if attitude_tel is None:
        return None
    attitude = attitude_tel.attitude
    pose = {
        "roll": (attitude.roll + 360) % 360,
        "pitch": (attitude.pitch + 360) % 360,
        "yaw": (attitude.yaw + 360) % 360,
    }
    return pose

get_power_source

get_power_source() -> Optional[PowerSource]

Get how the drone is powered.

The X7 runs two batteries in parallel, the other models a single battery. Drones running a Blunux version that predates this field report POWER_SOURCE_UNSPECIFIED.

Returns:

  • Optional[PowerSource] –

    The power source, or None if no DroneInfo message has been received yet.

Source code in blueye/sdk/drone.py
986
987
988
989
990
991
992
993
994
995
996
997
998
def get_power_source(self) -> Optional[blueye.protocol.PowerSource]:
    """Get how the drone is powered.

    The X7 runs two batteries in parallel, the other models a single battery. Drones running
    a Blunux version that predates this field report `POWER_SOURCE_UNSPECIFIED`.

    Returns:
        The power source, or None if no `DroneInfo` message has been received yet.
    """
    drone_info = self.get_drone_info()
    if drone_info is None:
        return None
    return drone_info.power_source

get_water_temperature

get_water_temperature() -> Optional[float]

Get the water temperature in degrees Celsius.

Returns:

  • Optional[float] –

    The water temperature in degrees Celsius.

Source code in blueye/sdk/drone.py
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
def get_water_temperature(self) -> Optional[float]:
    """Get the water temperature in degrees Celsius.

    Returns:
        The water temperature in degrees Celsius.
    """
    water_temperature_tel = self.telemetry.get(blueye.protocol.WaterTemperatureTel)
    if water_temperature_tel is None:
        return None
    return water_temperature_tel.temperature.value

has_attitude

has_attitude() -> Optional[bool]

Check whether the drone can estimate its attitude.

The drone estimates roll, pitch and yaw from any of its IMUs that works. Without one it sets the imu_attitude error flag and can only be driven by hand: it switches every auto mode off and refuses to turn one on, aborts a running mission, reports its attitude as NaN and turns camera tilt stabilization off. When an IMU recovers the flag is cleared, but the drone does not turn the auto modes or tilt stabilization back on by itself.

Returns:

  • Optional[bool] –

    True if the drone has an attitude estimate, False if it has none, or None if no ErrorFlagsTel message has been received.

Raises:

  • RuntimeError –

    If the connected drone is running Blunux older than 5.2, which does not report this.

Source code in blueye/sdk/drone.py
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
def has_attitude(self) -> Optional[bool]:
    """Check whether the drone can estimate its attitude.

    The drone estimates roll, pitch and yaw from any of its IMUs that works. Without one it
    sets the `imu_attitude` error flag and can only be driven by hand: it switches every auto
    mode off and refuses to turn one on, aborts a running mission, reports its attitude as
    NaN and turns camera tilt stabilization off. When an IMU recovers the flag is cleared,
    but the drone does not turn the auto modes or tilt stabilization back on by itself.

    Returns:
        True if the drone has an attitude estimate, False if it has none, or None if no
        `ErrorFlagsTel` message has been received.

    Raises:
        RuntimeError: If the connected drone is running Blunux older than 5.2, which does
            not report this.
    """
    self._verify_required_blunux_version("5.2")
    error_flags_tel = self.telemetry.get(blueye.protocol.ErrorFlagsTel)
    if error_flags_tel is None:
        return None
    return not error_flags_tel.error_flags.imu_attitude

is_jetson_platform

is_jetson_platform() -> Optional[bool]

Check if the connected drone is built on the NVIDIA Jetson platform.

The X3 Ultra and X7 run on the Jetson platform and have the 4K camera, which differs from the camera in the older models: it has no hue control, supports 60 fps and publishes its calibration. See JETSON_MODELS.

Returns:

  • Optional[bool] –

    True for the X3 Ultra and X7, False for the other models, and None if the model is not known yet.

Source code in blueye/sdk/drone.py
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
def is_jetson_platform(self) -> Optional[bool]:
    """Check if the connected drone is built on the NVIDIA Jetson platform.

    The X3 Ultra and X7 run on the Jetson platform and have the 4K camera, which differs
    from the camera in the older models: it has no hue control, supports 60 fps and publishes
    its calibration. See [`JETSON_MODELS`][blueye.sdk.constants.JETSON_MODELS].

    Returns:
        True for the X3 Ultra and X7, False for the other models, and None if the model is
        not known yet.
    """
    model = self.get_model()
    if model is None:
        return None
    return model in JETSON_MODELS

ping

ping(timeout: float = 1.0)

Ping the drone.

Parameters:

  • timeout (float, default: 1.0 ) –

    The timeout for the ping request.

Raises:

  • ResponseTimeout –

    If the drone does not respond within the timeout period.

Source code in blueye/sdk/drone.py
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
def ping(self, timeout: float = 1.0):
    """Ping the drone.

    Args:
        timeout (float, optional): The timeout for the ping request.

    Raises:
        blueye.protocol.exceptions.ResponseTimeout:
            If the drone does not respond within the timeout period.
    """
    self._req_rep_client.ping(timeout)

set_lights

set_lights(brightness: float)

Set the intensity of the drone lights.

Parameters:

  • brightness (float) –

    Set the intensity of the drone light (0..1).

Raises:

  • ValueError –

    If the brightness is not in the range (0..1).

Source code in blueye/sdk/drone.py
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
def set_lights(self, brightness: float):
    """Set the intensity of the drone lights.

    Args:
        brightness (float): Set the intensity of the drone light (0..1).

    Raises:
        ValueError: If the brightness is not in the range (0..1).
    """
    if not 0 <= brightness <= 1:
        raise ValueError("Error occurred while trying to set lights to: " f"{brightness}")
    self._ctrl_client.set_lights(brightness)

take_control

take_control(timeout=1)

Take control of the drone, disconnecting other clients.

Will disconnect other clients until the client is in control of the drone.

Parameters:

  • timeout (int, default: 1 ) –

    The timeout for taking control.

Raises:

  • RuntimeError –

    If the client could not take control of the drone in the given time.

Source code in blueye/sdk/drone.py
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
def take_control(self, timeout=1):
    """Take control of the drone, disconnecting other clients.

    Will disconnect other clients until the client is in control of the drone.

    Args:
        timeout (int, optional): The timeout for taking control.

    Raises:
        RuntimeError: If the client could not take control of the drone in the given time.
    """
    start_time = time.time()
    client_in_control = self.get_client_in_control()
    while self.client_id != client_in_control:
        if time.time() - start_time > timeout:
            raise RuntimeError("Could not take control of the drone in the given time")
        resp = self._req_rep_client.disconnect_client(client_in_control)
        client_in_control = resp.client_id_in_control
    self.in_control = True

Telemetry

Telemetry(parent_drone: 'Drone')

Handles the telemetry messages for the Blueye drone.

Parameters:

  • parent_drone (Drone) –

    The parent drone instance.

Methods:

Source code in blueye/sdk/drone.py
128
129
130
131
132
133
134
def __init__(self, parent_drone: "Drone"):
    """Initialize the Telemetry class.

    Args:
        parent_drone (Drone): The parent drone instance.
    """
    self._parent_drone = parent_drone

add_msg_callback

add_msg_callback(
    msg_filter: List[Message],
    callback: Callable[[str, Message], None],
    raw: bool = False,
    **kwargs: Dict[str, Any]
) -> str

Register a telemetry message callback.

The callback is called each time a message of the type is received.

Parameters:

  • msg_filter (List[Message]) –

    A list of message types to register the callback for. E.g., [blueye.protocol.DepthTel, blueye.protocol.Imu1Tel]. If the list is empty, the callback will be registered for all message types.

  • callback (Callable[[str, Message], None]) –

    The callback function. It should be minimal and return as fast as possible to not block the telemetry communication. It is called with two arguments, the message type name and the message object. An exception raised by the callback is logged and otherwise ignored, so it does not stop the telemetry thread or the other callbacks.

  • raw (bool, default: False ) –

    Pass the raw data instead of the deserialized message to the callback function.

  • **kwargs (Dict[str, Any], default: {} ) –

    Additional keyword arguments to pass to the callback function.

Returns:

  • str –

    The UUID of the callback.

Source code in blueye/sdk/drone.py
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
def add_msg_callback(
    self,
    msg_filter: List[proto.message.Message],
    callback: Callable[[str, proto.message.Message], None],
    raw: bool = False,
    **kwargs: Dict[str, Any],
) -> str:
    """Register a telemetry message callback.

    The callback is called each time a message of the type is received.

    Args:
        msg_filter (List[proto.message.Message]):
            A list of message types to register the callback for. E.g.,
            `[blueye.protocol.DepthTel, blueye.protocol.Imu1Tel]`. If the list is empty, the
            callback will be registered for all message types.
        callback (Callable[[str, proto.message.Message], None]):
            The callback function. It should be minimal and return as fast as possible to not
            block the telemetry communication. It is called with two arguments, the message
            type name and the message object. An exception raised by the callback is logged
            and otherwise ignored, so it does not stop the telemetry thread or the other
            callbacks.
        raw (bool, optional):
            Pass the raw data instead of the deserialized message to the callback function.
        **kwargs:
            Additional keyword arguments to pass to the callback function.

    Returns:
        The UUID of the callback.
    """
    uuid_hex = self._parent_drone._telemetry_watcher.add_callback(
        msg_filter, callback, raw, **kwargs
    )
    return uuid_hex

get

get(
    msg_type: Message, deserialize=True
) -> Optional[Message | bytes]

Get the latest telemetry message of the specified type.

Parameters:

  • msg_type (Message) –

    The message type to get. E.g., blueye.protocol.DepthTel.

  • deserialize (bool, default: True ) –

    If True, the message will be deserialized before being returned. If False, the raw bytes will be returned.

Returns:

  • Optional[Message | bytes] –

    The latest message of the specified type, or None if no message has been received yet.

Source code in blueye/sdk/drone.py
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
def get(
    self, msg_type: proto.message.Message, deserialize=True
) -> Optional[proto.message.Message | bytes]:
    """Get the latest telemetry message of the specified type.

    Args:
        msg_type (proto.message.Message):
            The message type to get. E.g., blueye.protocol.DepthTel.
        deserialize (bool, optional):
            If True, the message will be deserialized before being returned. If False, the raw
            bytes will be returned.

    Returns:
        The latest message of the specified type, or None if no message has been received yet.
    """
    try:
        msg = self._parent_drone._telemetry_watcher.get(msg_type)
    except KeyError:
        if version.parse(self._parent_drone.software_version_short) >= version.parse("3.3"):
            msg = self._parent_drone._req_rep_client.get_telemetry_msg(msg_type).payload.value
            if msg == b"":
                return None
        else:
            return None
    if deserialize:
        return msg_type.deserialize(msg)
    else:
        return msg

remove_msg_callback

remove_msg_callback(callback_id: str) -> Optional[str]

Remove a telemetry message callback.

Parameters:

  • callback_id (str) –

    The callback ID from when the callback was registered.

Source code in blueye/sdk/drone.py
255
256
257
258
259
260
261
def remove_msg_callback(self, callback_id: str) -> Optional[str]:
    """Remove a telemetry message callback.

    Args:
        callback_id (str): The callback ID from when the callback was registered.
    """
    self._parent_drone._telemetry_watcher.remove_callback(callback_id)

set_msg_log_frequency

set_msg_log_frequency(msg: Message, frequency: float)

Set how often a specific telemetry message is written to the dive log.

The log frequency is independent of the publish frequency, so a message can be logged at a higher rate than it is published to clients, or the other way around. Like the publish frequency it is shared by every client and stays in effect until the drone reboots, with one exception: on the X3 Ultra and X7 a multibeam recording raises the log rate of PositionEstimateTel, AttitudeTel, CalibratedImuTel, CalibratedImuHpTel, DepthTel and AltitudeTel while it runs and restores their defaults when it stops, which replaces a rate set here for those six.

Parameters:

  • msg (Message) –

    The message to set the log frequency of. Needs to be one of the messages in blueye.protocol that end in Tel, e.g., blueye.protocol.Imu1Tel.

  • frequency (float) –

    The frequency in Hz. Must be greater than 0 and at most 100.

Raises:

  • ValueError –

    If the frequency is not greater than 0 and at most 100 Hz.

  • RuntimeError –

    If the connected drone is running a Blunux version older than 5.1.0, or if the drone refuses to change the log frequency, because the connected drone does not publish the message or logs it as its data arrives rather than on a timer.

Source code in blueye/sdk/drone.py
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
def set_msg_log_frequency(self, msg: proto.message.Message, frequency: float):
    """Set how often a specific telemetry message is written to the dive log.

    The log frequency is independent of the publish frequency, so a message can be logged at a
    higher rate than it is published to clients, or the other way around. Like the publish
    frequency it is shared by every client and stays in effect until the drone reboots, with
    one exception: on the X3 Ultra and X7 a multibeam recording raises the log rate of
    `PositionEstimateTel`, `AttitudeTel`, `CalibratedImuTel`, `CalibratedImuHpTel`,
    `DepthTel` and `AltitudeTel` while it runs and restores their defaults when it stops,
    which replaces a rate set here for those six.

    Args:
        msg (proto.message.Message): The message to set the log frequency of. Needs to be one
                                     of the messages in blueye.protocol that end in Tel, e.g.,
                                     blueye.protocol.Imu1Tel.
        frequency (float): The frequency in Hz. Must be greater than 0 and at most 100.

    Raises:
        ValueError: If the frequency is not greater than 0 and at most 100 Hz.
        RuntimeError:
            If the connected drone is running a Blunux version older than 5.1.0, or if the
            drone refuses to change the log frequency, because the connected drone does not
            publish the message or logs it as its data arrives rather than on a timer.
    """
    self._parent_drone._verify_required_blunux_version("5.1.0")
    self._check_frequency(frequency)
    resp = self._parent_drone._req_rep_client.set_telemetry_msg_log_frequency(msg, frequency)
    if not resp.success:
        name = message_type_name(msg)
        raise RuntimeError(
            f"The drone could not change the log frequency of {name}. Either this drone does "
            "not publish it, or it is logged when its data arrives rather than on a timer"
        )

set_msg_publish_frequency

set_msg_publish_frequency(msg: Message, frequency: float)

Set the publishing frequency of a specific telemetry message.

The drone has one telemetry publisher shared by every connected client, so the new rate also applies to the Blueye app and any other SDK client, and it stays in effect until the drone reboots. Set the rate back before exiting if other clients depend on it.

Only messages the drone publishes on a timer have a publish frequency. The messages in EVENT_DRIVEN_TELEMETRY are published when their data arrives, and messages from peripherals are only published while the peripheral is connected.

Parameters:

  • msg (Message) –

    The message to set the frequency of. Needs to be one of the messages in blueye.protocol that end in Tel, e.g., blueye.protocol.DepthTel.

  • frequency (float) –

    The frequency in Hz. Must be greater than 0 and at most 100.

Raises:

  • ValueError –

    If the frequency is not greater than 0 and at most 100 Hz.

  • RuntimeError –

    If the drone refuses to change the frequency, because the message is published when its data arrives rather than on a timer, or because the connected drone does not publish it.

Source code in blueye/sdk/drone.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def set_msg_publish_frequency(self, msg: proto.message.Message, frequency: float):
    """Set the publishing frequency of a specific telemetry message.

    The drone has one telemetry publisher shared by every connected client, so the new rate
    also applies to the Blueye app and any other SDK client, and it stays in effect until the
    drone reboots. Set the rate back before exiting if other clients depend on it.

    Only messages the drone publishes on a timer have a publish frequency. The messages in
    [`EVENT_DRIVEN_TELEMETRY`][blueye.sdk.constants.EVENT_DRIVEN_TELEMETRY] are published
    when their data arrives, and messages from peripherals are only published while the
    peripheral is connected.

    Args:
        msg (proto.message.Message): The message to set the frequency of. Needs to be one of the
                                     messages in blueye.protocol that end in Tel, e.g.,
                                     blueye.protocol.DepthTel.
        frequency (float): The frequency in Hz. Must be greater than 0 and at most 100.

    Raises:
        ValueError: If the frequency is not greater than 0 and at most 100 Hz.
        RuntimeError:
            If the drone refuses to change the frequency, because the message is published
            when its data arrives rather than on a timer, or because the connected drone does
            not publish it.
    """
    self._check_frequency(frequency)
    resp = self._parent_drone._req_rep_client.set_telemetry_msg_publish_frequency(
        msg, frequency
    )
    if not resp.success:
        name = message_type_name(msg)
        if name in _EVENT_DRIVEN_TELEMETRY_NAMES:
            raise RuntimeError(
                f"The drone publishes {name} when its data arrives, not on a timer, so its "
                "publish frequency cannot be changed"
            )
        raise RuntimeError(
            f"The drone could not change the publish frequency of {name}. Either it is not a "
            "telemetry message, or this drone does not publish it: messages from peripherals "
            "are only published while the peripheral is connected"
        )