Bebop Mavlink file format description?


#21

Notice it has no upload method


#22

decompiling some stuff here…

private static final int MAVLINK_FTP_PORT = 61;
public static final java.lang.String remoteMavlinkFilePath = "/flightPlan.mavlink";

Trying to see if I can find where FF does the actual transfer.


#23

The java implementation appears to do it all in this createUploader method…

/**
 * Creates the ARDataTransfer Uploader
 * @param utilsManager The FTP server ip address
 * @param remotePath The FTP Server local directory
 * @param localPath The local system directory
 * @return void
 * @throws ARDataTransferException if error
 */
public void createUploader(ARUtilsManager utilsManager, String remotePath, String localPath, ARDataTransferUploaderProgressListener progressListener, Object progressArg, ARDataTransferUploaderCompletionListener completionListener, Object completionArg, ARDATATRANSFER_UPLOADER_RESUME_ENUM resume) throws ARDataTransferException
{
    int result = nativeNew(nativeManager, utilsManager.getManager(), remotePath, localPath, progressListener, progressArg, completionListener, completionArg, resume.getValue());

    ARDATATRANSFER_ERROR_ENUM error = ARDATATRANSFER_ERROR_ENUM.getFromValue(result);

    if (error != ARDATATRANSFER_ERROR_ENUM.ARDATATRANSFER_OK)
    {
        throw new ARDataTransferException(error);
    }
    else
    {
        isInit = true;
    }
}

#24

This is just creating the uploader, there isn’t anything else happening in here. That method exists in C as well, but how do you upload a file?


#25

I assumed with all the callbacks (listeners) that it’d just go off and do its thing… take a look at my other replies… there’s another FTP server apparently listening on port 61 and the flight plan file to upload is /flightPlan.mavlink

I agree our Parrot developers need to provide a smidge of guidance here.


#26

Synman, I understand what you’re saying…but the questions is how do the methods work. How do you get a file uploaded to the drone FTP? That information is useless if you can’t get a file uploaded


#27

who cares… just upload the file using your own ftp client… port 61 root directory and go fly!

http://developer.parrot.com/docs/bebop/#a-name-common-mavlink-start-a


#28

Hi,

I confirm your findings: first upload the file to the port 61 FTP (which is also accessible as a subdirectory to the port 21 FTP, but you should use the port 61 ;)), then run the sendMavlinkStart command.

On iOS, you can use NSURLConnection and CFFTPStream to do the actual FTP upload. Those APIs should be well documented on Apple website :wink: But as @synman pointed, you can use any FTP client, as it is just plain FTP (as we have a big C codebase inside the apps, we use cURL to do the job)

Regards,
Nicolas.


#29

Hello again,
i have now managed to upload the created file to the bebop using the ftp4j library.
I checked to see if the files are actually transfered with FileZilla and they are.

Still when the sendMavlinkStart function is called i get no reaction whatsoever.

The only Mavlink information report happens on connection:
02-09 01:35:12.761 D/droneOperation: Mavlink state: Mavlink file is stopped (arg filepath and type are useless in this state) Filepath: /data/flightplan1.csv Type: ARCOMMANDS_COMMON_MAVLINKSTATE_MAVLINKFILEPLAYINGSTATECHANGED_TYPE_MAX

If i disconnect after calling sendMavlinkStart with my Filename it does report my filename on reconnect though:
02-09 01:35:37.045 D/droneOperation: Mavlink state: Mavlink file is stopped (arg filepath and type are useless in this state) Filepath: gotopos19.csv Type: ARCOMMANDS_COMMON_MAVLINKSTATE_MAVLINKFILEPLAYINGSTATECHANGED_TYPE_MAX

I have not tested it outdoors yet, but according to the documentation i should receive an “AUTONOMOUS FLIGHT STATE ERROR” if there’s no GPS reception anyway.

I have also tried to add /flightplans/ infront of the filename as that is the location when connecting at port 21, but that does not make any difference.

Thoughts anyone?


#30

Hi derb, I finally got this working. If you connect at port 21 your file should be in the /internal_000/flightpaths/ directory. You should really just use port 61 because that will take you straight to the flight path directory. So place your file in the root at port 61. Then, when sending the command to play the file just send the file name with no directory. The sdk automatically puts the directory information in front of the file name. From the looks of it you’re putting the file in a different directory.


#31

Hi Slobdell,

i did use port 61, the files are in the flightplans directory, that’s why i tried to add "/flightplans/ infront of it.

The problem still is that nothing happens(with or without /flighplans/).

So did you get it to fly yet?


#32

Yea I got it to fly in my living room and had to hit emergency button. Your file path isn’t right, it’s coming back as data/xyzfile. When I start the mavlink the file path comes back as something (I’m trying to remember) like ftp/data//internal_000/flightpaths/xyzfile when sending the start command I only pass in xyzfile


#33

The
/data/flightplan1.csv
seems to be some kind of default value that is set when the drone starts.

It only reports the filename (gotopos19.csv in my post above) but that file does exist in the /flightplans/ dir.


#34

Not sure then, seems different that what I’m seeing. Try locating the flightplan1.csv and putting your file there. Then try sending in /data/gotopos19.csv


Setting up onCommandReceived for MavLink
#35

I checked with telnet …there is no flightplan1.csv in /data/.
I’m also pretty sure that i can’t access /data/ via ftp so the error has to be somewhere else.


#36

Hi,

The workflow for the autonomous flights is the following:

  • Create a ARMavlinkFileGenerator with ARMAVLINK_FileGenerator_New
  • Add items to the file generator with ARMAVLINK_FileGenerator_AddMissionItem. You can create missionItems easily with ARMAVLINK_MissionItemUtils…
  • Create the mavlink file with ARMAVLINK_FileGenerator_CreateMavlinkFile. Once this function has been called, the mavlink file is on your file system.
  • Check that the drone is able to run a mavlink file with the event FlightPlanStateComponentStateListChanged:
void onCommandReceived (eARCONTROLLER_DICTIONARY_KEY commandKey, ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary, void *customData)
{
    if ((commandKey == ARCONTROLLER_DICTIONARY_KEY_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED) && (elementDictionary != NULL))
    {
        ARCONTROLLER_DICTIONARY_ARG_t *arg = NULL;
        ARCONTROLLER_DICTIONARY_ELEMENT_t *dictElement = NULL;
        ARCONTROLLER_DICTIONARY_ELEMENT_t *dictTmp = NULL;
        HASH_ITER(hh, elementDictionary, dictElement, dictTmp)
        {
            HASH_FIND_STR (dictElement->arguments, ARCONTROLLER_DICTIONARY_KEY_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED_COMPONENT, arg);
            if (arg != NULL)
            {
                eARCOMMANDS_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED_COMPONENT component = arg->value.I32;
            }
            HASH_FIND_STR (dictElement->arguments, ARCONTROLLER_DICTIONARY_KEY_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED_STATE, arg);
            if (arg != NULL)
            {
                uint8_t State = arg->value.U8;
            }
        }
    }
}

GPS and Calibration of this event should be set to 1.

  • Send your mavlink file to the drone using the ftp port 61 with filePath FILENAME.
  • Once the Mavlink file has been received by the drone, you can send the StartMavlinkPlay command with your file name and with the type ARCOMMANDS_COMMON_MAVLINK_START_TYPE_FLIGHTPLAN:
deviceController->common->sendMavlinkStart(deviceController->common, FILENAME, ARCOMMANDS_COMMON_MAVLINK_START_TYPE_FLIGHTPLAN);
  • If autonomous flight has been started, event MavlinkFilePlayingStateChanged is triggered with param state set to playing.
  • Otherwise, event MavlinkFilePlayingStateChanged is triggered with param state set to stopped and event MavlinkPlayErrorStateChanged is triggered with an explanation of the error.

If this doesn’t work, try changing the name of your mavlink file to flightplan.mavlink.

Hope this helps,
Best regards,
Djavan


Please explain mavlink (autoflight) file elements
Not receiving Mavlink error command
Autonomous drone navigation app
#37

Hello Djavan,

can you please post the Java equivalent of the Code posted above.

I always get a NullPointerException when using it like this:

 public void onCommandReceived(ARDeviceController deviceController, ARCONTROLLER_DICTIONARY_KEY_ENUM commandKey, ARControllerDictionary elementDictionary)
    {
        if (elementDictionary != null)
        {
            if ((commandKey == ARCONTROLLER_DICTIONARY_KEY_ENUM.ARCONTROLLER_DICTIONARY_KEY_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED))
            {
                ARControllerArgumentDictionary<Object> args = elementDictionary.get(ARControllerDictionary.ARCONTROLLER_DICTIONARY_SINGLE_KEY);
                if (args != null)
                {
                   ARCOMMANDS_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED_COMPONENT_ENUM component = ARCOMMANDS_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED_COMPONENT_ENUM.getFromValue((Integer)args.get(ARFeatureCommon.ARCONTROLLER_DICTIONARY_KEY_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED_COMPONENT));
                    byte state = (byte)((Integer)args.get(ARFeatureCommon.ARCONTROLLER_DICTIONARY_KEY_COMMON_FLIGHTPLANSTATE_COMPONENTSTATELISTCHANGED_STATE)).intValue();


                    Log.d(TAG,"Flightplanstate Component: "+component+" State: "+state);
                }
            }
        }
        else
        {
            Log.e(TAG, "elementDictionary is null");
        }
    }

#38

Hi,

You can find here how to use this event in your app.

Best regards,
Djavan


#39

Thank you!
I get the information now.
Unfortunately it is very cloudy here today, so the drone won’t get a GPS fix.

Is there no way to test whether the Mavlink file & path are properly transfered without having a GPS fix?


#40

Hi,

The file transfer has nothing to do with the gps fix.
So, yes, you can send your file to the drone without the gps fix. You just won’t be able to play it.

Regards,
Djavan