0

I'm trying to make a simple Takeoff command.

Here is the code below:

ControlApi.getApi(this.drone).takeoff(10, new AbstractCommandListener() {
            @Override
            public void onSuccess() {

            }

            @Override
            public void onError(int executionError) {
                alertUser("Error: " + executionError);
            }

            @Override
            public void onTimeout() {

                alertUser("timeout");

            }
        });

Although I am managing to ARM the copter, the takeoff command always returns error, with executionError 3 or 4 and I don't know what it means? Any one have the executionError codes meanings? Or maybe know what is the issue?

Seiran
  • 126
  • 9
  • You need to arm the copter, and you also need to be in guided mode. Have you met both of those conditions? – squilter Apr 26 '17 at 15:32
  • @squilter Yes, first I'm arming, then switching to guided mode with `VehicleApi.getApi(this.drone).setVehicleMode(VehicleMode.COPTER_GUIDED);` and then the code above. – Seiran Apr 26 '17 at 16:58
  • Did you wait to get confirmation that the mode change was successful? – squilter Apr 27 '17 at 17:34
  • @squilter yes, I am waiting until `AttributeEvent.STATE_VEHICLE_MODE` in the `onDroneEvent` changed, and then pushing the takeoff button. Any other thoughts? BTW did you manage to takeoff with real quad copter? I'm asking because for testing I'm using real quad copter with PX4 controller. – Seiran Apr 27 '17 at 18:38
  • Oh, dronekit-android is really only designed to work with ArduCopter. It could definitely be made to work with PX4, but I wouldn't expect it to work out of the box. – squilter Apr 28 '17 at 19:18
  • @squilter I have another question about droneKit , can you please have a look at it? http://stackoverflow.com/questions/43832575/dronekit-mission-not-sent-to-drone – Seiran May 09 '17 at 15:36

1 Answers1

2

[Solved]. Here is the steps that need to be taken in order the code to work:

1.

VehicleApi.getApi(this.drone).arm(true, new AbstractCommandListener() {
            @Override
            public void onSuccess() {

            }

            @Override
            public void onError(int executionError) {

            }

            @Override
            public void onTimeout() {

            }
        });

Make sure you get proper response in onSuccess method.

2.

VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_GUIDED);

Here is where was my problem. I somehow managed to put the copter in Guided_NoGps According to Arducopter documentation, this mode can be put without sufficient GPS satellites count. Also you need a 3DFix in GPS to switch to Guided Mode. You need to make sure you have more than 9 stable satellites locks or this code just wont work.

3.

Run the code below

ControlApi.getApi(this.drone).takeoff(10, new AbstractCommandListener() {
            @Override
            public void onSuccess() {

            }

            @Override
            public void onError(int executionError) {
                alertUser("Error: " + executionError);
            }

            @Override
            public void onTimeout() {

                alertUser("timeout");

            }
        });

I have tested this on real quad-copter based on PX4 controller. Also you need ArduCopter version 3.4 (or above)

Seiran
  • 126
  • 9