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:
-
get_water_density–Get the water density used for increased pressure sensor accuracy.
-
set_drone_time–Set the system time for the drone.
-
set_water_density–Set the current water density for increased pressure sensor accuracy.
Source code in blueye/sdk/drone.py
42 43 44 45 46 47 48 49 | |
get_water_density
get_water_density() -> float
Get the water density used for increased pressure sensor accuracy.
The WaterDensities class contains typical densities for salty-, brackish-, and fresh water (these are the same values that the Blueye app uses).
Returns:
-
float–The currently configured water density in grams per liter.
Source code in blueye/sdk/drone.py
51 52 53 54 55 56 57 58 59 60 | |
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
78 79 80 81 82 83 84 85 86 87 | |
set_water_density
set_water_density(density: float)
Set the current water density for increased pressure sensor accuracy.
Older software versions will assume a water density of 1025 grams per liter.
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 to set.
Source code in blueye/sdk/drone.py
62 63 64 65 66 67 68 69 70 71 72 73 74 | |
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
connectmethod.
Methods:
-
connect–Establish a connection to the drone.
-
disconnect–Disconnects the connection, allowing another client to take control of the drone.
-
get_active_video_streams–Get the number of currently active connections to the video stream.
-
get_altitude–Get the current altitude in meters.
-
get_client_in_control–Get the client ID of the client in control of the drone.
-
get_connected_clients–Get a list of connected clients.
-
get_depth–Get the current depth in meters.
-
get_dive_time–Get the amount of time the drone has been submerged.
-
get_error_flags–Get the error flags.
-
get_lights–Get the intensity of the drone lights.
-
get_pose–Get the current orientation of the drone.
-
get_water_temperature–Get the water temperature in degrees Celsius.
-
ping–Ping the drone.
-
set_lights–Set the intensity of the drone lights.
-
take_control–Take control of the drone, disconnecting other clients.
Attributes:
-
peripherals(Optional[List[Peripheral]]) –This list holds the peripherals connected to the drone. If it is
None, then no
Source code in blueye/sdk/drone.py
212 213 214 215 216 217 218 219 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 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
peripherals
instance-attribute
peripherals: Optional[List[Peripheral]] = None
This list holds the peripherals connected to the drone. If it is None, then no
Guestport telemetry message has been received yet.
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.
When a watchdog message is received by the drone, the thrusters are armed. To stop the drone from moving unexpectedly when connecting, all thruster set points are set to zero when connecting.
Parameters:
-
client_info(ClientInfo, default:None) –Information about the client connecting. If None, the SDK will attempt to read it from the environment.
-
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
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 | |
disconnect
disconnect()
Disconnects the connection, allowing another client to take control of the drone.
Source code in blueye/sdk/drone.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
get_active_video_streams
get_active_video_streams() -> Dict[str, int]
Get the number of currently active connections to the video stream.
Every client connected to the RTSP stream (does not matter if it's directly from GStreamer, or from the Blueye app) counts as one connection.
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
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |
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
601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
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 of the client in control, or None if no client is in control.
Source code in blueye/sdk/drone.py
507 508 509 510 511 512 513 514 515 516 517 | |
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 no clients are connected.
Source code in blueye/sdk/drone.py
493 494 495 496 497 498 499 500 501 502 503 | |
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
568 569 570 571 572 573 574 575 576 577 578 | |
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
679 680 681 682 683 684 685 686 687 688 689 690 691 | |
get_error_flags
get_error_flags() -> Dict[str, bool]
Get the error flags.
Returns:
-
Dict[str, bool]–The error flags as bools in a dictionary.
Source code in blueye/sdk/drone.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
get_lights
get_lights() -> Optional[float]
Get the intensity of the drone lights.
Returns:
-
Optional[float]–The intensity of the drone light (0..1).
Noneif no telemetry message has been received.
Source code in blueye/sdk/drone.py
541 542 543 544 545 546 547 548 549 550 551 | |
get_pose
get_pose() -> Optional[Dict[str, float]]
Get the current orientation of the drone.
Returns:
-
Optional[Dict[str, float]]–A dictionary with roll, pitch, and yaw in degrees, from 0 to 359.
Source code in blueye/sdk/drone.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |
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
666 667 668 669 670 671 672 673 674 675 | |
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
654 655 656 657 658 659 660 661 662 663 664 | |
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
553 554 555 556 557 558 559 560 561 562 563 564 | |
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
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
Telemetry
Telemetry(parent_drone: 'Drone')
Handles the telemetry messages for the Blueye drone.
Parameters:
-
parent_drone(Drone) –The parent drone instance.
Methods:
-
add_msg_callback–Register a telemetry message callback.
-
get–Get the latest telemetry message of the specified type.
-
remove_msg_callback–Remove a telemetry message callback.
-
set_msg_publish_frequency–Set the publishing frequency of a specific telemetry message.
Source code in blueye/sdk/drone.py
106 107 108 109 110 111 112 | |
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.
-
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
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
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
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
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
167 168 169 170 171 172 173 | |
set_msg_publish_frequency
set_msg_publish_frequency(msg: Message, frequency: float)
Set the publishing frequency of a specific telemetry message.
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. Valid range is (0 .. 100).
Raises:
-
RuntimeError–If the drone fails to set the frequency. Possible causes could be a frequency outside the valid range, or an incorrect message type.
Source code in blueye/sdk/drone.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |