Olympe API Reference Documentation

class olympe.Drone

Generic Parrot drone controller class

This class should be able to connect to any Parrot ANAFI drone model when connected directly to the drone (not through a SkyController).

For ANAFI Ai, this class is only usable when the “Direct Connection” mode is enabled on the drone.

See AnafiAi and SkyController4 for more information.

__init__(*args, **kwds)
__call__(expectations)

This method can be used to:

  • send command messages and waiting for their associated expectations

  • monitor spontaneous drone event messages

  • check the state of the drone

It asynchronously process arsdk command and event message and expectations.

Parameters:

expectations – An SDK message expectation expression

Return type:

ArsdkExpectationBase

__enter__()
__exit__(exc_type, exc_val, exc_tb)
is_skyctrl()
start_piloting()

Start interface to send piloting commands

Return type:

bool

piloting(roll, pitch, yaw, gaz, piloting_time)

Send manual piloting commands to the drone. This function is a non-blocking.

Parameters:
  • roll (int) – roll consign for the drone (must be in [-100:100])

  • pitch (int) – pitch consign for the drone (must be in [-100:100])

  • yaw (int) – yaw consign for the drone (must be in [-100:100])

  • gaz (int) – gaz consign for the drone (must be in [-100:100])

  • piloting_time (float) – The time of the piloting command

Return type:

bool

stop_piloting()

Stop interface to send piloting commands

Return type:

bool

connect(**kwds)

Establish the connection between the device and the controller.

Parameters:
  • timeout – the global connection timeout in seconds (including the retried connection attempt duration when retry > 1) (default to TIMEOUT_CONNECTION)

  • retry – the number of connection attempts (default to 1)

  • later – the priority in the async event loop, if true, delay the connection process

Return type:

float

Return type:

int

Return type:

bool: True if the device is correctly connected, False otherwise.

disconnect(*, timeout: float = 30.0) bool

Disconnect current device (if any) Block until it is done or abandoned

Return type:

bool: True if device is correctly disconnected or in created state, False otherwise.

destroy()

explicit destructor

get_last_event(message, key=None)

Returns the drone last event for the event message given in parameter

get_last_events(message, key=None)

Returns the drone last event for the event message given in parameter

get_state(message)

Returns the drone current state for the event message given in parameter

Parameters:

message (ArsdkMessage) – an event message type

Returns:

an ordered dictionary containing the arguments of the last received event message that matches the message ID provided in parameter

check_state(message, *args, **kwds)

Returns True if the drone state associated to the given message is already reached. Otherwise, returns False

query_state(query)

Query the drone current state

Parameters:

query – the string to search for in the message received from the drone

Returns:

dictionary of every drone state whose message name contains the query string

Return type:

dict

drone_connection_state()

Returns the state of the connection to the drone

Return type:

bool

schedule(expectations)

See: Drone.__call__()

subscribe(callback, expectation, *args, **kwds)

See: subscribe()

unsubscribe(subscriber)

Unsubscribe a previously registered subscriber

Parameters:

subscriber (Subscriber) – the subscriber previously returned by subscribe()

property connection_state: ConnectionState
property connected: bool
property connecting: bool
property disconnected: bool
property disconnecting: bool
property created: bool
property scheduler
property flightplan: Flightplan
property media: Media
property mission
property streaming
property update: Update
class olympe.LocalController

Bases: ControllerBase

Generic Parrot drone local controller class

This class is to be used to connect to the local controller interface onboard a drone (e.g. from an Air SDK mission).

class olympe.Anafi

Bases: Drone

ANAFI controller class.

This class should be used when you’re trying to connect to an ANAFI drone directly and not through a SkyController.

When connecting Olympe to an ANAFI through a SkyController 3. You must use the SkyController3 class instead.

class olympe.AnafiUSA

Bases: Drone

ANAFI USA controller class.

This class should be used when you’re trying to connect to an ANAFI USA drone directly and not through a SkyController.

When connecting Olympe to an ANAFI USA through a SkyController USA or a SkyController 4 Black. You must use the SkyControllerUSA or SkyController4Black classes respectively.

class olympe.AnafiAi

Bases: Drone

ANAFI Ai controller class.

This class is only usable when the “Direct Connection” mode is enabled. By default, ANAFI Ai is only reachable from Olympe through a SkyController 4.

When connecting Olympe to an ANAFI Ai through a SkyController 4. You must use the SkyController4 class instead.

class olympe.controller.AnafiUKR

Bases: Drone

ANAFI UKR controller class.

This class cannot be used to connect directly to an ANAFI UKR without a SkyController. The MARS radio transceiver provided by a SkyController UKR is the only mean to connect to an ANAFI UKR.

When connecting Olympe to an ANAFI UKR through a SkyController UKR. You must use the SkyControllerUKR class instead.

class olympe.controller.Chuck

Bases: Drone

Chuck controller class.

This class should only be used to connect to a Chuck.

class olympe.SkyController

Generic SkyController controller class

This class can be used to connect to any SkyController SDK API but should be avoided to access other APIs (media, streaming and cellular pairing APIs).

__init__(*args, cellular_autoconfigure: bool = False, user_apc_token: str | None = None, **kwds)
Parameters:
  • cellular_autoconfigureTrue to run Cellular.configure() automatically when Cellular.user_apc_token is set and the SkyController is connected, False otherwise. (defaults to False)

  • user_apc_token – User APC token to use for the cellular configuration; set Cellular.user_apc_token. If None and cellular_autoconfigure is True, the drone will be paired with a new anonymous APC token that will be automatically assigned to Cellular.user_apc_token when the SkyController is connected to the drone. If not None force cellular_autoconfigure to True and sets Cellular.user_apc_token. (defaults to None)

See also

Cellular.pair() to pair the drone with an user APC token. Cellular.configure() to configure the cellular.

__call__(expectations)

This method can be used to:

  • send command messages and waiting for their associated expectations

  • monitor spontaneous drone event messages

  • check the state of the drone

It asynchronously process arsdk command and event message and expectations.

Parameters:

expectations – An SDK message expectation expression

Return type:

ArsdkExpectationBase

__enter__()
__exit__(exc_type, exc_val, exc_tb)
is_skyctrl()
start_piloting()

Start interface to send piloting commands

Return type:

bool

piloting(roll, pitch, yaw, gaz, piloting_time)

Send manual piloting commands to the drone. This function is a non-blocking.

Parameters:
  • roll (int) – roll consign for the drone (must be in [-100:100])

  • pitch (int) – pitch consign for the drone (must be in [-100:100])

  • yaw (int) – yaw consign for the drone (must be in [-100:100])

  • gaz (int) – gaz consign for the drone (must be in [-100:100])

  • piloting_time (float) – The time of the piloting command

Return type:

bool

stop_piloting()

Stop interface to send piloting commands

Return type:

bool

connect(**kwds)

Establish the connection between the device and the controller.

Parameters:
  • timeout – the global connection timeout in seconds (including the retried connection attempt duration when retry > 1) (default to TIMEOUT_CONNECTION)

  • retry – the number of connection attempts (default to 1)

  • later – the priority in the async event loop, if true, delay the connection process

Return type:

float

Return type:

int

Return type:

bool: True if the device is correctly connected, False otherwise.

disconnect(*, timeout: float = 30.0) bool

Disconnect current device (if any) Block until it is done or abandoned

Return type:

bool: True if device is correctly disconnected or in created state, False otherwise.

destroy()

Destructor

get_last_event(message, key=None)

Returns the drone last event for the event message given in parameter

get_last_events(message, key=None)

Returns the drone last event for the event message given in parameter

get_state(message)

Returns the drone current state for the event message given in parameter

Parameters:

message (ArsdkMessage) – an event message type

Returns:

an ordered dictionary containing the arguments of the last received event message that matches the message ID provided in parameter

check_state(message, *args, **kwds)

Returns True if the drone state associated to the given message is already reached. Otherwise, returns False

query_state(query)

Query the drone current state

Parameters:

query – the string to search for in the message received from the drone

Returns:

dictionary of every drone state whose message name contains the query string

Return type:

dict

drone_connection_state()

Returns the state of the connection to the drone

Return type:

bool

schedule(expectations)

See: Drone.__call__()

subscribe(callback, expectation, *args, **kwds)

See: subscribe()

unsubscribe(subscriber)

Unsubscribe a previously registered subscriber

Parameters:

subscriber (Subscriber) – the subscriber previously returned by subscribe()

property connection_state: ConnectionState
property connected: bool
property connecting: bool
property disconnected: bool
property disconnecting: bool
property created: bool
property scheduler
property cellular: Cellular

Cellular API.

property flightplan: Flightplan
property media: Media
property mission
property streaming
property update: Update
class olympe.SkyController3

Bases: SkyControllerNet

SkyController 3 controller class

This class should be used to connect to ANAFI drones through a SkyController 3. Use the Anafi class instead when connecting to a drone directly.

class olympe.SkyControllerUSA

Bases: SkyControllerNet

SkyController USA controller class

This class should be used to connect to ANAFI USA drones through a SkyController USA. Use the AnafiUSA class instead when connecting to a drone directly.

class olympe.SkyController4Black

Bases: SkyControllerMux

SkyController 4 Black controller class

This class should be used to connect to ANAFI USA drones through a SkyController 4 Black. Use the AnafiUSA class instead when connecting to a drone directly.

class olympe.SkyController4

Bases: SkyControllerMuxCellular

SkyController 4 controller class

This class should be used to connect to ANAFI Ai drones through a SkyController 4. Use the AnafiAi class instead when connecting to a drone directly (the Direct connection mode should have been enabled on the drone in this case).

class olympe.SkyControllerUKR

Bases: SkyControllerMux

SkyController UKR controller class

This class should be used to connect to ANAFI UKR drones through a SkyController UKR.

class olympe.controller.SkyControllerUKR5G

Bases: SkyControllerMuxCellular

SkyController UKR controller class

This class should be used to connect to ANAFI UKR drones with 5G, through a SkyController UKR.

class olympe.controllers.cmd_itf.ConnectionState

An enumeration.

Created = 1
Connecting = 2
Connected = 3
Disconnecting = 4
Disconnected = 5
Timeout = 6
Error = 7
class olympe.video.pdraw.OutfilesPath

OutfilesPath(info: Optional[str] = None, video: Optional[str] = None, meta: Optional[str] = None)

class olympe.video.pdraw.Outfiles

Outfiles(info: Optional[TextIO] = None, video: Optional[olympe.features.video.mp4.Mp4Mux] = None, meta: Optional[TextIO] = None)

class olympe.video.pdraw.Callbacks

Callbacks(media_type: Tuple[int, Optional[int]], video_frame: Optional[Callable[[olympe.features.video.frame.VideoFrame], NoneType]] = None, flush: Optional[Callable[[Dict[str, Any]], NoneType]] = None, drain: Optional[Callable[[Dict[str, Any]], NoneType]] = None, start: Optional[Callable[[], NoneType]] = None, end: Optional[Callable[[], NoneType]] = None)

class olympe.video.pdraw.StreamInfo

StreamInfo(name: str, has_renderer: bool = False, outfiles_path: Optional[olympe.features.video.pdraw.OutfilesPath] = None, callbacks: List[olympe.features.video.pdraw.Callbacks] = <factory>)

class olympe.video.pdraw.video_frame_type

An enumeration.

class olympe.video.pdraw.h264_coded_data_format

An enumeration.

class olympe.video.pdraw.Pdraw
__init__(name: str | None = None, device_name: str | None = None, buffer_queue_size: int = 8, loop: Loop | None = None, controller: MixinBase | None = None)

PDrAW Olympe class

Parameters:
  • name (Optional[str], optional) – PDrAW client name (used by Olympe logs), defaults to None

  • device_name (Optional[str], optional) – Drone device name (used by Olympe logs), defaults to None

  • buffer_queue_size (int, optional) – Video buffer queue size, defaults to 8

  • loop (Optional[Loop], optional) – Thread to run PDrAW. If ‘None’, a new thread is created, defaults to None

  • controller (Optional["MixinBase"], optional) – Controller owner of the PDrAW instance, defaults to None

wait(state: PdrawState, timeout: float = 5) bool

Wait for the provided PDrAW state

If the requested state is already reached, this function returns True immediately.

This function may block indefinitely when called with a timeout of 0.

Parameters:
  • state (PdrawState) – PDrAW state to wait for

  • timeout (float, optional) – Timeout duration in seconds, defaults to 5

Returns:

True when the requested state is reached or False if the timeout duration is reached

Return type:

bool

get_session_metadata() Dict[str, Any] | None

Returns video stream session metadata

Returns:

Video stream session metadata

Return type:

Dict[str, Any]

get_session_metadata_dict() Dict[str, Dict[str, Any]]

Returns a dictionnary of video stream session metadata

Returns:

a dictionnary of video stream session metadata

Return type:

Dict[str, Dict[str, Any]]

seek_next_frame(timeout: float = 5) Tuple[bool, PlayData | None]

Go to next frame in frame-by-frame playback. This function plays the next frame while the playback is paused. If the playback is not currently paused an error is returned. Frame-by-frame is only available on local replays (MP4 records).

Parameters:

timeout (float) – time block let to perform next frame seeking

seek_previous_frame(timeout: float = 5) Tuple[bool, PlayData | None]

Go to previous frame in frame-by-frame playback. This function plays the previous frame while the playback is paused. If the playback is not currently paused an error is returned. Frame-by-frame is only available on local replays (MP4 records).

Parameters:

timeout (float) – time block let to perform next frame seeking

seek_from(delta: int, exact: int = 1, timeout: float = 5) Tuple[bool, PlayData | None]

Seek a frame from a given delta of time Seeking is only available on replays (local or streamed), but not on live streams

Parameters:
  • delta (int) – delta to seek the frame from, in microseconds. Positive delta seeks forward, negative delta seeks backward

  • exact (bool) – flag set to 0 to seek to the nearest synchronization sample preceeding the timestamp, flag set to 1 to seek to the nearest sample to the timestamp

  • timeout (float) – time block let to perform seeking from

seek_to(timestamp: int, exact: int = 1, timeout: float = 5) Tuple[bool, PlayData | None]

Seek a frame to a given time Seeking is only available on replays (local or streamed), but not on live streams

Parameters:
  • timestamp (int) – timestamp to seek the frame to, in microseconds

  • exact (bool) – flag set to 0 to seek to the nearest synchronization sample preceeding the timestamp, flag set to 1 to seek to the nearest sample to the timestamp

  • timeout (float) – time block let to perform seeking to

get_chapter_list() List[ChapterList] | None

Get the video chapter list

This function returns the video chapter list if available. If the video does not contain any chapter, None is returned The chapter timestamps can be used to seek to the desired chapter. This function is available on a record demuxer only; on any other type of muxer None is returned.

Returns:

list of chapters

Return type:

List[Chapter]

get_replay_duration() float | None

Get the playback duration

The duration is only available on replays (either local or streamed), not on live streams

Returns:

the duration in microseconds on success, 0 in case of error

Return type:

float

get_replay_current_time() float | None

Get the playback current time

On replays (either local or streamed) this is the position between 0 and the duration; on live streams this is the time since the start of the stream session.

Returns:

the current time in microseconds on success, 0 in case of error

Return type:

float

stop(timeout: float = 5)

Stop the video streaming

Parameters:

timeout (float, optional) – beyong this timeout, the task to stop the streaming is canceled. Closing is therefore probably not correctly done, defaults to 5

Returns:

A Future task, done or canceled

Return type:

Future

play_multiple_stream(url: str | None = None, *, address: str | None = None, port: int | None = None, streams_list: List[StreamInfo | StreamInfoDefault | StreamInfoSingle] = [], resource_name: str = 'live', timeout: float = 5, speed: float | None = None) bool

Play multiple videostreams

By default, open and play a live video streaming session available from rtsp://192.168.42.1/live where “192.168.42.1” is the default IP address of a physical (Anafi) drone. The default is equivalent to Pdraw.play(url=”rtsp://192.168.42.1/live”)

For a live video streaming from a simulated drone, the default simulated drone IP address has to be specified (10.202.0.1) instead: Pdraw.play(url=”rtsp://10.202.0.1/live”).

The url parameter can also point to a local file example: Pdraw.play(url=”file://~/Videos/100000010001.MP4”).

Parameters:
  • url (Optional[str], optional) – rtsp or local file video URL, defaults to None

  • address (Optional[str], optional) – address of the rtsp URL, defaults to None

  • port (Optional[int], optional) – port of the rtsp URL, defaults to None

  • streams_list (List[Union[StreamInfo, StreamInfoDefault, StreamInfoSingle]], optional) – Union[StreamInfo, StreamInfoDefault, StreamInfoSingle] of the streams to play, defaults to []

  • resource_name (str, optional) – resource name, defaults to “live”

  • timeout (float, optional) – beyond this timeout, the task to play the streams is canceled. Playing all streams is therefore probably not done, defaults to 5

  • speed (float, optional) – play the playback of a video at the requested speed, defaults to None. If the speed parameter is negative, the video is played backward. If the speed is greater than or equal to PDRAW_PLAY_SPEED_MAX, the speed is ignored and the video is played at the maximum speed achievable. If the speed is less than or equal to -PDRAW_PLAY_SPEED_MAX, the speed is ignored and the video is played backward at the maximum speed achievable. Speed cannot be null, if requested. On a live stream, the speed parameter has no effect.

Raises:

ValueError – if multiple Default Streams are provided. There must be only one default stream provided by the user

Returns:

Future task, done or canceled

Return type:

Future

play(url: str | None = None, *, address: str | None = None, port: int | None = None, media_name: str = 'Front camera', resource_name: str = 'live', speed: float | None = None, timeout: float = 5, data_formats: List[int] = [h264_coded_data_format.bytestream], raw_cb: Callable[[VideoFrame], None] | None = None, coded_cb: Callable[[VideoFrame], None] | None = None, coded_avcc_cb: Callable[[VideoFrame], None] | None = None, coded_bytestream_cb: Callable[[VideoFrame], None] | None = None, start_cb: Callable[[], None] | None = None, start_raw_cb: Callable[[], None] | None = None, start_coded_avcc_cb: Callable[[], None] | None = None, start_coded_bytestream_cb: Callable[[], None] | None = None, end_cb: Callable[[], None] | None = None, end_raw_cb: Callable[[], None] | None = None, end_coded_avcc_cb: Callable[[], None] | None = None, end_coded_bytestream_cb: Callable[[], None] | None = None, flush_raw_cb: Callable[[Dict[str, Any]], None] | None = None, flush_coded_avcc_cb: Callable[[Dict[str, Any]], None] | None = None, flush_coded_bytestream_cb: Callable[[Dict[str, Any]], None] | None = None, drain_raw_cb: Callable[[Dict[str, Any]], None] | None = None, drain_coded_avcc_cb: Callable[[Dict[str, Any]], None] | None = None, drain_coded_bytestream_cb: Callable[[Dict[str, Any]], None] | None = None, has_renderer: bool = False, outfiles_path: OutfilesPath | None = None) bool

Play a videostream

By default, open and play a live video streaming session available from rtsp://192.168.42.1/live where “192.168.42.1” is the default IP address of a physical (Anafi) drone. The default is equivalent to Pdraw.play(url=”rtsp://192.168.42.1/live”)

For a live video streaming from a simulated drone, the default simulated drone IP address has to be specified (10.202.0.1) instead: Pdraw.play(url=”rtsp://10.202.0.1/live”).

The url parameter can also point to a local file example: Pdraw.play(url=”file://~/Videos/100000010001.MP4”).

Parameters:
  • url (Optional[str], optional) – rtsp or local file video URL, defaults to None

  • address (Optional[str], optional) – address of the rtsp URL, defaults to None

  • port (Optional[int], optional) – port of the rtsp URL, defaults to None

  • media_name (str, optional) – name of the stream/track, defaults to “Front camera”

  • resource_name (str, optional) – resource name, defaults to “live”

  • timeout (float, optional) – beyond this timeout, the task to play the stream is canceled. Playing the stream is therefore probably not done, defaults to 5

  • speed (float, optional) – play the playback of a video at the requested speed, defaults to None. If the speed parameter is negative, the video is played backward. If the speed is greater than or equal to PDRAW_PLAY_SPEED_MAX, the speed is ignored and the video is played at the maximum speed achievable. If the speed is less than or equal to -PDRAW_PLAY_SPEED_MAX, the speed is ignored and the video is played backward at the maximum speed achievable. Speed cannot be null, if requested. On a live stream, the speed parameter has no effect.

  • data_formats (List[int], optional) – Coded video frame formats requested, defaults to list([h264_coded_data_format.bytestream])

  • raw_cb (Optional[Callable[[VideoFrame], None]], optional) – callback to process raw frames, defaults to None

  • coded_cb (Optional[Callable[[VideoFrame], None]], optional) – callback to process encoded frames (whether they are bytestream or avcc), defaults to None

  • coded_avcc_cb (Optional[Callable[[VideoFrame], None]], optional) – callback to process encoded frames for avcc type, defaults to None

  • coded_bytestream_cb (Optional[Callable[[VideoFrame], None]], optional) – callback to process encoded frames for bytestream type, defaults to None

  • start_cb (Optional[Callable[[], None]], optional) – callback to call at the beginning of the streaming, for retrocompatibility. Linked to bytestream frames by default, defaults to None

  • start_raw_cb (Optional[Callable[[], None]], optional) – callback to call at the beginning of the streaming, for raw frames, defaults to None

  • start_coded_avcc_cb (Optional[Callable[[], None]], optional) – callback to call at the beginning of the streaming, or avcc frames, defaults to None

  • start_coded_bytestream_cb (Optional[Callable[[], None]], optional) – callback to call at the beginning of the streaming, for bytestream frames, defaults to None

  • end_cb (Optional[Callable[[], None]], optional) – callback to call at the end of the streaming, for retrocompatibility. Linked to bytestream frames by default, defaults to None

  • end_raw_cb (Optional[Callable[[], None]], optional) – callback to call at the beginning of the streaming, for raw frames, defaults to None

  • end_coded_avcc_cb (Optional[Callable[[], None]], optional) – callback to call at the end of the streaming, for avcc frames, defaults to None

  • end_coded_bytestream_cb (Optional[Callable[[], None]], optional) – callback to call at the end of the streaming, for bytestream frames, defaults to None

  • flush_raw_cb (Optional[Callable[[Dict[str, Any]], None]], optional) – callback to call when flushing raw frames, defaults to None

  • flush_coded_avcc_cb (Optional[Callable[[Dict[str, Any]], None]], optional) – callback to call when flushing avcc frames, defaults to None

  • flush_coded_bytestream_cb (Optional[Callable[[Dict[str, Any]], None]], optional) – callback to call when flushing bytestream frames, defaults to None

  • drain_raw_cb (Optional[Callable[[Dict[str, Any]], None]], optional) – callback to call when draining raw frames, defaults to None

  • drain_coded_avcc_cb (Optional[Callable[[Dict[str, Any]], None]], optional) – callback to call when draining avcc frames, defaults to None

  • drain_coded_bytestream_cb (Optional[Callable[[Dict[str, Any]], None]], optional) – callback to call when draining bytestream frames, defaults to None

  • has_renderer (bool, optional) – indicates if the streaming needs a renderer, defaults to False

  • outfiles_path (Optional[OutfilesPath], optional) – paths of the output files, defaults to None

Returns:

Future task, done or canceled

Return type:

Future

pause(timeout: float = 5)

Pause the current playing streaming

Parameters:

timeout (float, optional) – beyond this timeout, the task to pause the stream will be canceled. The stream will therefore probably not be paused, defaults to 5

Returns:

A Future task, done or canceled

Return type:

Future

cleanup(timeout: float = 5)

Clean up function, for a proper clean (Stop streaming, loop callbacks, clear multistreams info and attributes of the session, stop the PDrAW session properly, close the PDrAW state machine, destroy PDrAW instance)

Parameters:

timeout (float, optional) – not used anymore, DEPRECATED

destroy()

Stop streaming, loop callbacks, clear multistreams info and attributes of the session, stop the PDrAW session properly, close the PDrAW state machine, destroy PDrAW instance

property state: PdrawState

Return the current state of the PDrAW state machine

Returns:

the current PDrAW state self._state

Return type:

PdrawState

class olympe.video.pdraw.PdrawState

An enumeration.

Created = 1
Open_requested = 2
Opened = 3
Play_requested = 4
Playing = 5
Pause_requested = 6
Paused = 7
Close_requested = 8
Closed = 9
Cleaned = 10
Error = 11
class olympe.video.frame.VideoFrame
__init__(logger, mbuf_video_frame, media_id, stream, session_metadata)
__bool__()
ref()

This function increments the reference counter of the underlying buffer(s)

unref()

This function decrements the reference counter of the underlying buffer(s)

media_id()
as_ctypes_pointer()

This function return a 2-tuple (frame_pointer, frame_size) where frame_pointer is a ctypes pointer and frame_size the frame size in bytes.

See: https://docs.python.org/3/library/ctypes.html

as_ndarray()

This function returns an non-owning numpy 1D (h264) or 2D (YUV) array on this video frame

info()

Returns a dictionary of video frame info

vmeta()

Returns a 2-tuple (VMetaFrameType, dictionary of video frame metadata)

format()
userdata_sei()

This returns some additional and optional userdata SEI associated to this frame

session_metadata()

Returns video stream session metadata

property frame_type
property width
property height
class olympe.Cellular

Controller Cellular API class Controller mixin providing the cellular pairing.

__init__(controller: MixinBase, autoconfigure: bool = False, user_apc_token: str | None = None)
Parameters:
  • autoconfigureTrue to run configure() automatically when user_apc_token is set and the SkyController is connected to a drone, False otherwise. (defaults to False)

  • user_apc_token – User APC token to use for the cellular configuration; set user_apc_token. If None and autoconfigure is True, the drone will be paired with a new anonymous APC token automatically assigned to user_apc_token when the SkyController is connected to the drone. If not None force autoconfigure to True and sets user_apc_token. (defaults to None)

pair(user_apc_token: str | None = None, timeout: float | None = None) str

Pairs a user APC token with the currently connected Drone.

Parameters:
  • user_apc_token – User APC token to pair with the drone. If None, another anonymous APC token will be generated. (defaults to None)

  • timeout – the timeout in seconds or None for infinite timeout (the default)

Raises:
  • HTTPError – in case of failure.

  • TimeoutError – in case of timeout.

Returns:

the user APC token paired with the Drone.

configure(user_apc_token: str | None = None, timeout: float | None = None)

Configures the cellular connection using a user APC token.

Parameters:
  • user_apc_token – User APC token to used for the cellular connection. If not None, user_apc_token is set as user_apc_token. If None, user_apc_token will be used (the default).

  • timeout – the timeout in seconds or None for infinite timeout (the default)

Raises:
  • HTTPError – in case of failure.

  • TimeoutError – in case of timeout.

property autoconfigure: bool

True if the automatic cellular configuration is enabled, False otherwise.

property user_apc_token: str | None

Current user APC token used.

class olympe.Flightplan

Drone Flightplan API class

This class connects to the drone web flightplan interface (REST API) and synchronizes the drone flightplan information in a background thread.

Flightplan info:
  • download_all()

See usage example in examples/flightplan.py

__init__(hostname, name=None, version=1, session: Session | None = None)
set_hostname(hostname: str | None)
upload(flightplan_data, timeout=None) str
download_all(timeout=None) Tuple[str | None, FlightplanInfo]
download(flightplan_id, timeout=None)
remove(flightplan_id, timeout=None)
shutdown()
destroy() bool

Properly close and stop the flightplan API background thread

class olympe.Media

Drone Media API class

This class automatically connects to the drone web media interface (REST and websocket API) and synchronizes the drone media information in a background thread.

Media info:
Media monitoring with the Subscriber/listener API:

See usage example in examples/media.py

__init__(hostname=None, version=1, name=None, device_name=None, scheduler=None, download_dir=None, integrity_check=None, session: Session | None = None)
get_hostname()
set_hostname(hostname: str | None)
connect(timeout=5)
disconnect(timeout=5)
shutdown()

Properly close and stop the websocket connection and the media API background thread

destroy()

Properly close and stop the websocket connection and the media API background thread

wait_for_pending_downloads(timeout=None)
schedule(expectations)
resource_info(media_id=None, resource_id=None, with_md5=False, with_signature=False, timeout=None)

Returns a list resources info associated to a media_id or a specific resource info associated to a resource_id. This function raises a ValueError if media_id and resource_id are both left to None.

Return type:

list(ResourceInfo) or ResourceInfo

media_info(media_id=None)

Returns a media info object if media_id is None or a list of all available media info otherwise.

Return type:

list(MediaInfo) or MediaInfo

list_media()

Returns a list of all available media id

list_resources(media_id=None)

Returns a list of all available resource id if media_id is None or a list of resource id associated to the given media_id otherwise.

last_media()
last_media_id()
next_media_id()
subscribe(*args, **kwds)

See: subscribe()

unsubscribe(subscriber)

Unsubscribe a previously registered subscriber

Parameters:

subscriber (Subscriber) – the subscriber previously returned by subscribe()

property download_dir
property integrity_check
property indexing_state

Returns the current media indexing state :rtype IndexingState:

property scheduler
class olympe.MediaInfo

Namedtuple class MediaInfo(media_id, type, title, datetime, boot_date, flight_date, size, run_id, custom_id, resources, duration, thumbnail, gps, video_mode, photo_mode, panorama_type, expected_count, replay_url, thermal)

  • media_id (str): unique id of the media

  • type ( MediaType): type of the media

  • title (str): title of the media

  • datetime (str) :iso8601 datetime of the media

  • boot_date (str) :iso8601 datetime of the drone boot

  • flight_date (str) :iso8601 datetime of the flight

  • size (int): size (in bytes) of the media (total size of all its resources)

  • duration (int): duration (in milliseconds) of the video media (total duration of all its resources)

  • run_id (str): run id of the media

  • thumbnail (str): relative url to be used in a GET request to download the media thumbnail (if available)

  • gps (GPS): gps coordinates of the media (if available)

  • photo_mode (PhotoMode): photo mode of the media (if available and media is a photo)

  • panorama_type (panorama_type enum): panorama type of the media (if available, media is a photo and photo_mode is panorama)

  • expected_count (int): expected number of resources in the media ( if available, media is a photo and photo_mode is panorama)

  • replay_url (str): media rtsp replay url (prefixed by rtsp://drone.ip.address:rtsp_port/)

  • resources (list( ResourceInfo )): resource list of the media

  • thermal (bool): media includes resources with thermal metadata (if value is true)

class olympe.ResourceInfo

Namedtuple class ResourceInfo(media_id, resource_id, type, path, format, datetime, size, url, width, height, duration, thumbnail, preview, signature, gps, video_mode, replay_url, thermal, md5, storage, download_path, download_md5_path, thumbnail_download_path, thumbnail_download_md5_path)

  • media_id (str): unique id of the media

  • resource_id (str): unique id of the resource

  • type ( MediaType): type of the resource

  • path (str): path to the resource on the file system, relative to the storage root path

  • format ( ResourceFormat): format of the resource

  • datetime (str): iso8601 datetime of the media

  • size (int): size (in bytes) of the media (total size of all its resources)

  • duration (int): duration (in milliseconds) of the video media (total duration of all its resources)

  • url (str): relative url to be used in a GET request to download the resource

  • thumbnail (str): relative url to be used in a GET request to download the resource thumbnail (if available)

  • preview (str): elative url to be used in a GET request to download the resource preview (if available)

  • signature (str): resource signature (optional)

  • gps (GPS): gps coordinates of the media (if available)

  • width (int): width (in pixels) of the resource

  • height (int): height (in pixels) of the resource

  • replay_url (str): media rtsp replay url (prefixed by rtsp://drone.ip.address:rtsp_port/)

  • thermal (bool): media includes resources with thermal metadata (if value is true)

  • md5 (str): media md5 checksum (if resource is photo)

  • video_mode (str): video mode of the resource (if available and resource is a video)

  • storage (str): storage where the resource is located

class olympe.media.GPS

Namedtuple class GPS(latitude, longitude, altitude)

class olympe.MissionController
__init__(controller: ControllerBase, hostname: str, version: int = 1, name: str | None = None, session: Session | None = None, mission_dir: Path | None = None)
stop()
set_hostname(hostname: str)
set_device_name(device_name: str)
list_remote()
from_path(url_or_path: Path | str, feature_name_from_file: bool = False, timeout: float | None = None) Mission

Creates and returns an olympe.Mission object from a local path or an URL to an AirSDK mission archive.

property mission_dir: Path
class olympe.Mission
__init__(mission_controller: MissionController, resource: Resource, feature_name_from_file: bool = False)
__enter__()
__exit__(exception_type, exception_value, traceback)
__bool__()
open(raw: bool = False, verify: bool = True, ca_pub_key_der=None)
close()
install(verify: bool = True, ca_pub_key_der=None, allow_downgrade=None, is_default=None, timeout: float | None = 30, **kwds)

Install this mission onto the remote drone. The drone must be rebooted before this mission becomes available.

hash()
verify() bool
wait_ready(timeout: float | None = None) bool

Wait for the mission to become ready to communicate with the drone. Which means wait for the drone to send the mission the recipient ID.

Parameters:

timeout (Optional[float], default to None. If timeout is set to 'None', this means the timeout runs undefinitely) – timeout to wait the mission to be ready for, defaults to None.

Returns:

True if recipient_id is retrieved, False otherwise

Return type:

bool

subscribe(callback, service_name: str | None = None, msg_num: int | None = None, recipient_id: int | None = None)

Subscribe a callback function to every event messages associated to this mission.

See: subscribe()

property resource: Resource
property filepath: Path
property state
property recipient_id: int | None
property ready: bool
property messages: Dict

Returns a dictionary of mission (non-protobuf) messages usable with the Olympe DSL API.

property enums

Returns a dictionary of mission enums usable with the Olympe DSL API.

property modules
property signature: MissionSignature | None
class olympe.Expectation
__bool__() bool
__or__(other)
__and__(other)
__rshift__(other)
__str__()

Return str(self).

abstract check(*args, **kwds)
abstract expected_events()
abstract received_events()

Returns a collection of events that have matched at least one of the messages ID monitored by this expectation.

abstract matched_events()

Returns a collection of events that have matched this expectation (or a child expectation)

abstract unmatched_events()

Returns a collection of events object that are still expected

marked_events(default_marked_events=EventMarker.unmatched)

Returns a collection of events with matched/unmatched markers.

explain()

Returns a debug string that explain this expectation current state.

success()
wait(_timeout=None)
cancel()
cancelled()
set_timeout(_timeout)
timedout()
abstract copy()

All expectations sublclasses must implement a shallow copy.

done() bool
result(timeout=None)
class olympe.messaging.expectations.SuccessExpectation

Bases: ExpectationBase

class olympe.messaging.expectations.FailedExpectation

Bases: ExpectationBase

class olympe.messaging.expectations.FutureExpectation

Bases: ExpectationBase

class olympe.messaging.expectations.CheckWaitStateExpectation

Bases: CheckWaitStateExpectationMixin, Expectation

class olympe.messaging.expectations.MultipleExpectation

Bases: MultipleExpectationMixin, Expectation

class olympe.messaging.expectations.WhenAnyExpectation

Bases: WhenAnyExpectationMixin, MultipleExpectation

class olympe.messaging.expectations.WhenAllExpectations

Bases: WhenAllExpectationsMixin, MultipleExpectation

class olympe.messaging.expectations.WhenSequenceExpectations

Bases: WhenSequenceExpectationsMixin, MultipleExpectation

class olympe.messaging.expectations.ExpectPolicy

An enumeration.

check = 1
check_wait = 2
wait = 0
class olympe.messaging.arsdk_expectations.MatchingMode

Expectation matching mode enum class

  • MatchingMode.pattern: (the default) matches if the expected arguments are present among the received arguments and match some of them.

  • MatchingMode.exact: further restrict the matching events to those that don’t contain more arguments than the expected arguments.

  • MatchingMode.negative_pattern: matches if not all expected arguments are present in the received arguments.

This enum controls how expectations are matched internally.

exact = 2
negative_pattern = 3
pattern = 1
class olympe.Event
property policy
property uuid
property date
property id
class olympe.EventListener

EventListener base class

This class implements the visitor pattern and is meant to be overridden to dispatch drone event messages to the correct class method.

To start/stop listening to event messages EventListener.subscribe() EventListener.unsubscribe() methods should be called. Alternatively, this class can be used as a context manager.

Example:

import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, Landing, moveBy
from olympe.messages.ardrone3.PilotingState import (
    PositionChanged,
    AlertStateChanged,
    FlyingStateChanged,
    NavigateHomeStateChanged,
)

class FlightListener(olympe.EventListener):

    @olympe.listen_event(
        FlyingStateChanged(_policy="wait")
        | AlertStateChanged(_policy="wait")
        | NavigateHomeStateChanged())
    def onStateChanged(self, event, scheduler):
        print("{} = {}".format(event.message.name, event.args["state"]))

    @olympe.listen_event(PositionChanged(_policy="wait"))
    def onPositionChanged(self, event, scheduler):
        print(
            "latitude = {latitude} "
            "longitude = {longitude} "
            "altitude = {altitude}".format(
                **event.args
            )
        )


drone = olympe.Drone("10.202.0.1")
with FlightListener(drone):
    drone.connect()
    drone(
        FlyingStateChanged(state="hovering")
        | (TakeOff() & FlyingStateChanged(state="hovering"))
    ).wait()
    drone(moveBy(10, 0, 0, 0)).wait()
    drone(Landing()).wait()
    drone(FlyingStateChanged(state="landed")).wait()
    drone.disconnect()
__init__(*contexts, timeout=10)
Parameters:
  • scheduler – an olympe.Drone or an olympe.messaging.expectations.Scheduler object for which this listener will subscribe to event messages.

  • timeout – the listener callbacks timeout in seconds

__enter__()
__exit__(*args, **kwds)
subscribe()

Start to listen to the scheduler event messages

unsubscribe()

Stop from listening scheduler event messages

property timeout
olympe.listen_event(expectation=None, queue_size=None)

See EventListener documentation.

olympe.log.update_config(update, on_update=None)

Update (recursively) the current logging configuration dictionary.

See: Logging config dictionary schema