Disable takeoff button until drone finish taking off

In the example from Ground SDK Hello Drone Tutorial - 7.7 it seems like the switch cases doesn’t cover when the drone is in the middle of taking off. I.e. if I press takeOff, the land button will become enabled right away instead of waiting until the drone is finish taking off. Is this the intended behavior? Is there a way to detect when the drone is still in the middle of taking off versus finished taking off?

private func managePilotingItfState(itf: ManualCopterPilotingItf) {
        switch itf.state {
        case ActivablePilotingItfState.unavailable:
            // Piloting interface is unavailable.
            takeOffLandBt.isEnabled = false

        case ActivablePilotingItfState.idle:
            // Piloting interface is idle.
            takeOffLandBt.isEnabled = false

            // Activate the interface.
            _ = itf.activate()

        case ActivablePilotingItfState.active:
            // Piloting interface is active.
            if itf.canTakeOff {
                // Drone can takeOff.
                takeOffLandBt.isEnabled = true
                takeOffLandBt.setTitle("TakeOff", for: .normal)
            } else if itf.canLand {
                // Drone can land.
                takeOffLandBt.isEnabled = true
                takeOffLandBt.setTitle("Land", for: .normal)
            } else {
                // Disable the button.
                takeOffLandBt.isEnabled = false

Take a look at the FlightIndicators instrument.

So altimeter maybe? Thanks.


The reason why the land button becomes enabled as soon as the drone starts to take off is because it can be pressed to call land() method, which will cancel take-off.

If you disable the land button until the drone has finished its take-off, this means you will not be able to cancel take-off early.

To answer the other part of your question: you can know when the drone has finished take-off by using the FlyingIndicators instrument, as @synman suggested (not the Altimeter instrument, which will only inform about drone current altitude).

From the FlyingIndicators instrument, you may query the flyingState and know whether the drone is still taking off (state will be ‘takingOff’ in such a case).