POI anafi AI PointNFly

Hello,
I am trying to achieve a POI with olympe with pointnfly and keep the poi while moving.
I am working with a simulated drone under sphinx.
But when I try to execute the poi, this part of code

expectation_pointnfly_flying = drone(State(idle=dict())).wait(_timeout=10)
if not expectation_pointnfly_flying.success():
print(“PointNFly is not possible even if the drone is flying”)

It returns :
PointNFly is not possible even if the drone is flying

Have you any idea why would it be unavailable ?

Thanks !

Hello Jatou,

Have you changed something in the code I’ve given you?
I do not see a particular reason why you would got stuck at that step when I do not

You could use some debug logs to check the state of your directive such as :

possible_unavailability_reasons = drone(State()).wait(
    _timeout=15.0
)
assert possible_unavailability_reasons.success()

unavailability_reasons = (
    possible_unavailability_reasons.received_events().last().args["unavailable"]
)
print(f"Unavailibity reasons : {unavailability_reasons}")

Hello, thanks for the answer !
Actually I already coded some verification code :

if not execution.success():
        print("PointNfFly The drone has failed executing the 'Point' directive")
        expectation_point.explain()
        print(f" EXPLAIN : {expectation_point.explain()}")
        # print(f"PointNFly unavailibility reasons {self.drone(State(unavailable=dict(reasons=[])))}")
        # unavailable_state = 
        # reasons = unavailable_state # .unavailable.reasons
        i=0
        for reasons in self.drone(State(unavailable=dict())):
            print(f"PointNFly unavailibility type : {type(reasons)}, reasons : {vars(reasons)}, {i}")
            i=i+1
            # if i==1:
            #    print(f"PointNFly unavailibility reasons {reasons.Unavailable}")
        expectation_pointnfly_above_alt = self.drone(
        State(unavailable=dict(reasons=["UNAVAILABILITY_REASON_DRONE_ABOVE_MAX_ALTITUDE"]))
        ).wait(_timeout=10)
        if expectation_pointnfly_above_alt.success():
            print("PointNFly failed because above alt")
            return
        
        expectation_pointnfly_not_flying = self.drone(
        State(unavailable=dict(reasons=["UNAVAILABILITY_REASON_DRONE_NOT_FLYING"]))
        ).wait(_timeout=10)
        if expectation_pointnfly_not_flying.success():
            print("PointNFly is not possible when the drone is not flying")
            return
        
        expectation_pointnfly_not_calib = self.drone(
        State(unavailable=dict(reasons=["UNAVAILABILITY_REASON_DRONE_NOT_CALIBRATED"]))
        ).wait(_timeout=10)
        if expectation_pointnfly_not_calib.success():
            print("PointNFly failed because not calib")
            return
        
        expectation_pointnfly_closetogroud = self.drone(
        State(unavailable=dict(reasons=["UNAVAILABILITY_REASON_DRONE_TOO_CLOSE_TO_GROUND"]))
        ).wait(_timeout=10)
        if expectation_pointnfly_closetogroud.success():
            print("PointNFly failed because too close to ground")
            return
        
        expectation_pointnfly_no_batt = self.drone(
        State(unavailable=dict(reasons=["UNAVAILABILITY_REASON_DRONE_INSUFFICIENT_BATTERY"]))
        ).wait(_timeout=10)
        if expectation_pointnfly_no_batt.success():
            print("PointNFly failed because no battery")
            return
        
        expectation_pointnfly_no_gps = self.drone(
        State(unavailable=dict(reasons=["UNAVAILABILITY_REASON_DRONE_GPS_INFO_INACCURATE"]))
        ).wait(_timeout=10)
        if expectation_pointnfly_no_gps.success():
            print("PointNFly failed because no gps")
            return
        
        expectation_pointnfly_out_geo = self.drone(
        State(unavailable=dict(reasons=["UNAVAILABILITY_REASON_DRONE_OUT_GEOFENCE"]))
        ).wait(_timeout=10)
        if expectation_pointnfly_out_geo.success():
            print("PointNFly failed because out geofence")
            return
        print("PointNFly unavailable for none of the unavailibility reasons")
        return

Here is what it gives :

PointNfFly The drone has failed executing the 'Point' directive
        pointnfly.Event.State(
            active=pointnfly.State.Active(
                point=dict(gimbal_control_mode=0, latitude=45.422, longitude=1.35, altitude=10.0)
PointNFly unavailibility type : <class 'olympe.arsdkng.expectations.ArsdkCheckStateExpectation'>, reasons : {'_future': <Future at 0x7f2af43792e0 state=cancelled>, '_awaited': True, '_scheduler': <olympe.media.MediaScheduler object at 0x7f2af71bcd30>, '_success': False, '_timeout': None, '_deadline': None, '_timedout': False, '_scheduled_condition': <Condition(<unlocked _thread.RLock object owner=0 count=0 at 0x7f2af42636c0>, 0)>, '_asyncio_future': None, '_float_tol': (1e-07, 1e-09), 'expected_message': <olympe.arsdkng.messages.pointnfly.Event.State object at 0x7f2af4263fa0>, 'expected_event_type': <class 'olympe.arsdkng.events.ArsdkProtoMessageEvent'>, 'expected_args': OrderedDict([('unavailable', {})]), 'matched_state': None}, 0
PointNFly unavailibility type : <class 'olympe.arsdkng.expectations.ArsdkEventExpectation'>, reasons : {'_future': <Future at 0x7f2af4433f40 state=pending>, '_awaited': True, '_scheduler': <olympe.media.MediaScheduler object at 0x7f2af71bcd30>, '_success': False, '_timeout': None, '_deadline': None, '_timedout': False, '_scheduled_condition': <Condition(<unlocked _thread.RLock object owner=0 count=0 at 0x7f2af4433270>, 0)>, '_asyncio_future': None, '_float_tol': (1e-07, 1e-09), 'expected_message': <olympe.arsdkng.messages.pointnfly.Event.State object at 0x7f2af44336d0>, 'expected_args': OrderedDict([('unavailable', {})]), 'expected_event_type': <class 'olympe.arsdkng.events.ArsdkProtoMessageEvent'>, 'received_args': [], '_received_events': [], 'matched_args': OrderedDict()}, 1
PointNFly unavailable for none of the unavailibility reasons

Have you any idea what is the problem there ?

Hey,
I’ve made a global answer in your other topic : PointNFly anafi AI - #4 by Meryl

This topic was automatically closed after 30 days. New replies are no longer allowed.