Home return function


#1

Product: [Bebop2]

Hi guys,

In order for the drone to return home when flying manually using the controller or autonomously, what are the steps needed to establish a successful home return?
Do I need to set the home return coordinates than execute the home return?

public void setHome(double lat, double lng, double alt){
    if ((mDeviceController != null) || (mState.equals(ARCONTROLLER_DEVICE_STATE_ENUM.ARCONTROLLER_DEVICE_STATE_STOPPED))) {
        mDeviceController.getFeatureARDrone3().sendGPSSettingsSetHome(lat, lng, alt);
    }
}

public void home(){
    if ((mDeviceController != null) || (mState.equals(ARCONTROLLER_DEVICE_STATE_ENUM.ARCONTROLLER_DEVICE_STATE_RUNNING))) {
        mDeviceController.getFeatureARDrone3().sendPilotingNavigateHome((byte) 1);
    }
}

private void notifyHomeReturn(double latitude, double longtitude, double altitude){
    List<AutonomousController.Listener> listenersCpy = new ArrayList<>(mListeners);
    for (AutonomousController.Listener listener : listenersCpy) {
        listener.onHomeReturn(latitude, longtitude, altitude);
    }
}

public void onCommandReceived(ARDeviceController deviceController, ARCONTROLLER_DICTIONARY_KEY_ENUM commandKey, ARControllerDictionary elementDictionary) {
    
// if event received is the home location
if ((commandKey == ARCONTROLLER_DICTIONARY_KEY_ENUM.ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_GPSSETTINGSSTATE_HOMECHANGED) && (elementDictionary != null)){
            ARControllerArgumentDictionary<Object> args = elementDictionary.get(ARCONTROLLER_DICTIONARY_SINGLE_KEY);
            if (args != null) {
                final double latitude = (double)args.get(ARFeatureARDrone3.ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_GPSSETTINGSSTATE_HOMECHANGED_LATITUDE);
                final double longitude = (double)args.get(ARFeatureARDrone3.ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_GPSSETTINGSSTATE_HOMECHANGED_LONGITUDE);
                final double altitude = (double)args.get(ARFeatureARDrone3.ARCONTROLLER_DICTIONARY_KEY_ARDRONE3_GPSSETTINGSSTATE_HOMECHANGED_ALTITUDE);
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        notifyHomeReturn(latitude, longitude, altitude);
                    }
                });
            }
        }
}

Can anyone help please?


#2

Take a look at the “Preferred” Home type documentation.


#3

Hi,

As said in ReturnHome documentation, sending this command will make the drone return to its home. The current location of its home can be get using the event HomePosition.
This location is linked to the type of home. You can set a preference regarding this type. The drone will use the preferred type if available, if not, it will chose an available type in this order: FOLLOWEE ; TAKEOFF ; PILOT ; FIRST_FIX. To know the type chosen by the drone you can use this event.
If you want the drone to go back to a custom position, you should set the preferred home type to PILOT and set this custom position using SendControllerGPSPosition.

Finally, you can check if the return home is available (linked to gps connectivity, magnetometer calibration) with this event. With this same event, you are also informed about the return home state.


#4

Thanks synman. It was very useful.


#5

Hi Djavan,

So, first I set the home return preference to TAKEOFF.
When the home return button is triggered the drone will return home.
Correct?
If that is so, it means that upon every takeoff the home return location will automatically be stored by the system and we do not need to set the location latitude, longitude and altitude as long as the preference is set to TAKEOFF.
Correct?


#6

If you don’t specify a controller location the drone will default to takeoff or first fix.

I want to say an SC sends location automatically but I’d have to verify that first to be certain.


#7

Yes, when TAKE_OFF is preferred, if the drone has a gps fix when it takes off, it will automatically store the take off location and return to it when a disconnection appears or when the return home is triggered by the controller.