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?
[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)