Olympe 7.0.2 event listener

I’ve updated from olympe 1.7 to 7.0.2 and I am trying to subscribe to events, but with no luck. This code is working fine on the older version, but I want to use it on the newest version of olympe:

import olympe
from olympe.messages.ardrone3.PilotingState import AttitudeChanged
import time

class FlightListener(olympe.EventListener):

    @olympe.listen_event(AttitudeChanged())
    def AttitudeChange(self, event, scheduler):
        roll = event.args['roll']
        pitch = event.args['pitch']
        yaw = event.args['yaw']
        print(f"roll: {roll}, pitch: {pitch}, yaw: {yaw}")

olympe.log.update_config({"loggers": {"olympe": {"level": "ERROR"}}})
SKYCTRL_IP = "192.168.53.1"
drone = olympe.Drone(SKYCTRL_IP)
drone.connect()
listener = FlightListener(drone)
listener.subscribe()

print(drone.get_state(AttitudeChanged))
while True:
    time.sleep(0.5)

The print with the drone.get_state is working fine, but the one in the event listener is never triggered. Could you suggest a solution?

1 Like

I’ve made a pull request with the fix that you can check out here. It looks like this fix is working as expected, but it needs to be reviewed so that it can be used with pip as a release.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.