How to tell drone to return home

Hi,

How do I tell the drone to fly back to the takeoff coordinate while it’s hovering? There is a ReturnHomePilotingItf (ReturnHomePilotingItf Protocol Reference) but I’m not too sure how to exactly trigger the drone to return home. Do I simply call activate()? Thanks.

Here’s an Android Java example (click event of a view):

goHomeImage.setOnClickListener(view -> {
    if (ardrone != null && ardrone.getReturnHomePilot() != null) {
        final ReturnHomePilotingItf rth = ardrone.getReturnHomePilot();

        switch (rth.getState()) {
            case IDLE:
                rth.activate();
                break;

            case ACTIVE:
                rth.deactivate();
                break;

            case UNAVAILABLE:
                showToastOnUiThread(this, "Return To Home is unavailable", Toast.LENGTH_SHORT);
                break;
        }
    }
});

Basically, if the RTH ITF is idle, you activate it to start RTH. If it is Active, you can deactivate it to abort an RTH operation, and if it is Unavailable, the drone is unable to perform an RTH (likely no GPS fix).