Skip to content

Commit

Permalink
[INTEGRATION] prepare 7.6.0-rc1 release
Browse files Browse the repository at this point in the history
Change-Id: I3e37f6f0d5582af6bb8ce3f71cc1b10deea52f80
Reviewed-on: https://gerrit-doc.parrot.biz/c/drones/sdk/olympe/+/204949
Reviewed-by: Nicolas Dessart <nicolas.dessart@parrot.com>
  • Loading branch information
ndessart committed Mar 24, 2023
1 parent e0d9c34 commit 068ed69
Show file tree
Hide file tree
Showing 14 changed files with 1,280 additions and 399 deletions.
17 changes: 12 additions & 5 deletions src/olympe/arsdkng/proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,13 @@ def message_type_from_field(self, feature_name, field_descriptor):
for enum_type in message_type.enum_types:
package = message_type.file.package
path = enum_type.full_name[len(package) + 1 :]
feature_name = enum_type.full_name[
: len(enum_type.full_name) - len(path) - 1
]
enum_types.append(self._make_enum(feature_name, path, enum_type))
self.features_package_map[message_type.file.package] = feature_name
if message_type.file.package not in self.features_package_map:
self.features_package_map[message_type.file.package] = feature_name
else:
assert (
self.features_package_map[message_type.file.package] == feature_name
)
return message_type, enum_types

def list_oneof_messages(self, feature_name, oneof_descriptor):
Expand Down Expand Up @@ -648,7 +650,12 @@ def parse_proto(
)
feature_name = filename
if module.DESCRIPTOR.package:
self.features_package_map[module.DESCRIPTOR.package] = feature_name
if module.DESCRIPTOR.package not in self.features_package_map:
self.features_package_map[module.DESCRIPTOR.package] = feature_name
else:
assert (
self.features_package_map[module.DESCRIPTOR.package] == feature_name
)
services = []
if hasattr(module, "Command"):
services.append(
Expand Down
14 changes: 10 additions & 4 deletions src/olympe/concurrent/_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import concurrent
import inspect
import threading
from collections import defaultdict
from dataclasses import dataclass, field, fields
from .future import Future
Expand Down Expand Up @@ -67,12 +68,17 @@ def cancel(self):
return True

def _step_blocking_impl(self, blocking, result):
assert self._loop is not None
assert threading.current_thread() is self._loop
# Yielded Future must come from Future.__iter__().
if isinstance(result, Future) and result._loop is not self._loop:
new_exc = RuntimeError(
f"Task {self!r} got Future {result!r} attached to a different loop"
)
self._loop.run_later(self.step, new_exc)
if result._loop is None:
new_exc = RuntimeError(
f"Task {self!r} got Future {result!r} not attached to any loop"
)
self._loop.run_later(self.step, new_exc)
else:
result.add_done_callback(self._wakeup)
elif blocking:
if result is self:
new_exc = RuntimeError(f"Task cannot await on itself: {self!r}")
Expand Down
36 changes: 18 additions & 18 deletions src/olympe/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,41 @@
import olympe_deps as od
from .arsdkng.cmd_itf import Connect, Disconnect, Connected, Disconnected # noqa
from .arsdkng.controller import ControllerBase
from .arsdkng.backend import BackendType
from .mixins.streaming import StreamingControllerMixin
from .mixins.media import MediaControllerMixin
from .mixins.mission import MissionControllerMixin
from .mixins.ipproxy import IpProxyMixin
from .mixins.cellular import CellularPairerMixin
from .utils import callback_decorator


class ControllerBase(
StreamingControllerMixin,
MissionControllerMixin,
MediaControllerMixin,
ControllerBase):
IpProxyMixin,
StreamingControllerMixin,
MissionControllerMixin,
MediaControllerMixin,
ControllerBase,
):
pass


class Drone(ControllerBase):
pass


class SkyController(ControllerBase):
def __init__(self, *args, **kwds):
super().__init__(*args, is_skyctrl=True, **kwds)
class SkyController(CellularPairerMixin, ControllerBase):
def __init__(self, *args, backend: BackendType = BackendType.MuxIp, **kwds):
super().__init__(*args, is_skyctrl=True, backend=backend, **kwds)

@callback_decorator()
def _link_status_cb(
self,
_arsdk_device,
_arsdk_device_info,
status,
_user_data):
def _link_status_cb(self, _arsdk_device, _arsdk_device_info, status, _user_data):
"""
Notify link status. At connection completion, it is assumed to be
initially OK. If called with KO, user is responsible to take action.
It can either wait for link to become OK again or disconnect
immediately. In this case, call arsdk_device_disconnect and the
'disconnected' callback will be called.
Notify link status. At connection completion, it is assumed to be
initially OK. If called with KO, user is responsible to take action.
It can either wait for link to become OK again or disconnect
immediately. In this case, call arsdk_device_disconnect and the
'disconnected' callback will be called.
"""
self.logger.info(f"Link status: {status}")
if status == od.ARSDK_LINK_STATUS_KO:
Expand Down
63 changes: 63 additions & 0 deletions src/olympe/doc/examples/cellular.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import os

import olympe
from olympe.messages.drone_manager import connection_state
from olympe.messages import network
from olympe.enums.network import LinkType, LinkStatus


olympe.log.update_config({"loggers": {"olympe": {"level": "WARNING"}}})

SKYCTRL_IP = os.environ.get("SKYCTRL_IP", "192.168.53.1")


def test_cellular():
"""
This script allows to pair in cellular a SkyController and a Drone previously paired together in wifi.
"""

print("Test of cellular pairing")

# Create a skycontroller
skyctrl = olympe.SkyController(SKYCTRL_IP)
# Connect to skycontroller
assert skyctrl.connect()
print("- SkyController connected")

# Wait for the skycontroller and the drone to be connected
skyctrl(connection_state(state="connected")).wait()
print("- Drone connected")

# Get the cellular link status before pairing
assert skyctrl(network.Command.GetState() >> network.Event.State()).wait().success()
links = skyctrl.get_state(network.Event.State)["links_status"]["links"]
cellular_link = next(
filter(lambda link: link["type"] == LinkType.LINK_TYPE_CELLULAR, links), None
)
print(f" cellular link status: {cellular_link['status']}")
# Should be different from LinkStatus.running

# Pair the SkyController and the Drone in cellular
print("- Cellular pairing of the SkyController and the Drone")
assert skyctrl.cellular.pair()

print("- Waiting for cellular link to be running")

# Wait for cellular link status pass to Link Status.running
while cellular_link["status"] != LinkStatus.running:
skyctrl(network.Event.State(_policy="wait"))
links = skyctrl.get_state(network.Event.State)["links_status"]["links"]
cellular_link = next(
filter(lambda link: link["type"] == LinkType.LINK_TYPE_CELLULAR, links),
None,
)

# Log cellular link status
print(f" cellular link status: {cellular_link['status']}")

# Disconnect the skycontroller
skyctrl.disconnect()
print("- SkyController disconnected")

if __name__ == "__main__":
test_cellular()
4 changes: 3 additions & 1 deletion src/olympe/doc/olympeapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ Olympe API Reference Documentation
.. automethod:: __init__
.. automethod:: play
.. automethod:: pause
.. automethod:: close
.. automethod:: resume
.. automethod:: stop
.. automethod:: set_output_files
.. automethod:: set_callbacks
.. automethod:: get_session_metadata
.. autoproperty:: state
.. automethod:: wait
.. automethod:: close

.. autoclass:: olympe.Media()

Expand Down
4 changes: 2 additions & 2 deletions src/olympe/doc/userguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ Bitfield example:

Additional usage examples are available in the unit tests of `olympe.arsdkng.enums`.

Using Olympe exptectation eDSL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Using Olympe expectation eDSL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Before continuing with this Olympe example, you might want to read the :ref:`Olympe eDSL <Olympe eDSL>` section.

Expand Down
Loading

0 comments on commit 068ed69

Please sign in to comment.