gerald
January 17, 2020, 11:56am
1
Hello,
I searched in the documentation and the forum but I didn’t find a way to listen events (beside the expectation mechanism). Is it something possible with Olympe ?
It would be very convenient to listen either for all events or for a specific list to do actions accordingly.
I saw on the documentation events like battery alerts, motor error, wifi signal and so on. With a listener, I would be able to add some security scenarios.
Unless there is another way to do it without a listener ?
Thanks in advance.
Gerald
Hi gerald,
This feature has already been requested multiple times and the good news is that this listener feature should be included in the next Olympe release.
Nicolas
gerald
February 12, 2020, 9:51am
3
Hello Nicolas,
Thank you for your answer. That’s a good news.
Is there already a target date for the next Olympe release ?
Gerald
End of February at best but the schedule depends on the GSDK 1.2.0 and Anafi 1.6.5 release date (those must be synchronized).
Nicolas
1 Like
Hi,
Olympe 1.2.0 has a new event monitoring API. You should probably have a look at the following examples:
# -*- coding: UTF-8 -*-
import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, Landing, moveBy
from olympe.messages.ardrone3.PilotingState import (
PositionChanged,
SpeedChanged,
AttitudeChanged,
AltitudeAboveGroundChanged,
AlertStateChanged,
FlyingStateChanged,
NavigateHomeStateChanged,
)
olympe.log.update_config({"loggers": {"olympe": {"level": "WARNING"}}})
def print_event(event):
# Here we're just serializing an event object and truncate the result if necessary
This file has been truncated. show original
# -*- coding: UTF-8 -*-
import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, Landing, moveBy
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged
from pprint import pformat
olympe.log.update_config({"loggers": {"olympe": {"level": "WARNING"}}})
drone = olympe.Drone("10.202.0.1")
# subscribe to all events during the drone connection
with drone.subscribe(
lambda event, controller: print("{}({})".format(event.message.fullName, pformat(event.args)))
):
drone.connect()
# Subscribe to FlyingStateChanged
# If you call `drone.subscribe` without using the `with` statement,
# you'll have to call `drone.unsubscribe()` later.
flying_sub = drone.subscribe(
lambda event, controller: print("Flyingstate =", event.args["state"]), FlyingStateChanged()
This file has been truncated. show original
Nicolas
1 Like
gerald
March 27, 2020, 4:55pm
6
That’s a very good news !
Thank you for updating the post.