FlightPlan not starting


#1

Product: [Bebop2]
SDK platform: [Unix.]

Hello,
I’ve tried to write a piece of code adapted from the bebop sample in order to start a flightplan with my drone.
However when i hit the key, nothing happens.
I’ve successfully created a mavlink file, and the keypress works, but it seems that the command I’m trying isn’t starting the flightplan. Either that or the mavlink flightplan I’ve made isn’t a proper one.

Here’s the part of the switch case that deals with starting the flightplan :

ARCONTROLLER_Device_t *deviceController = (ARCONTROLLER_Device_t *)customData;
    eARCONTROLLER_ERROR error = ARCONTROLLER_OK;
    char * mavLinkFilePath;


	eARCOMMANDS_COMMON_MAVLINK_START_TYPE flightPlan = ARCOMMANDS_COMMON_MAVLINK_START_TYPE_FLIGHTPLAN;	//defines the file type   as FlightPlan (as opposed to MapMyHouse)
	
	
	
    switch (event)
    {
    case IHM_INPUT_PAUSE_FLIGHTPLAN:
    	//pause flightplan
		deviceController->common->sendMavlinkPause(deviceController->common);
    	break;
    case IHM_INPUT_STOP_FLIGHTPLAN:
    	//stop flightplan
		deviceController->common->sendMavlinkStop(deviceController->common);
    	break;
    case IHM_INPUT_START_SINGLE_WAYPOINT_FLIGHTPLAN:
    	if(deviceController != NULL)
        {
        deviceController->common->sendWifiSettingsOutdoorSetting(deviceController->common, 1);
	deviceController->common->sendCalibrationMagnetoCalibration(deviceController->common, 1);
    	 //create a flightplan file with a single waypoint
    		mavLinkFilePath = createSingleWaypointMavlinkFile( 48.847251, 2.357799, 1.30, 0, 0, "mavlinkTest2.mavlink"); 
    		
    	//start flightplan (mavlink)
			error = deviceController->common->sendMavlinkStart(deviceController->common, mavLinkFilePath, flightPlan);
		}
    	break;

and here is the function i’ve made to build the mavlink file :

char * createSingleWaypointMavlinkFile(float latitude, float longitude, float altitude, float yaw, float pitch, char * fileName)
{
	eARMAVLINK_ERROR errorlog;
	char * projectPath = "/home/norman/Documents/projetDrone/";
	
	ARMAVLINK_FileGenerator_t* generator = ARMAVLINK_FileGenerator_New(&errorlog);
	mavlink_mission_item_t missionItem;
	
	ARMAVLINK_MissionItemUtils_CreateMavlinkTakeoffMissionItem(&missionItem, latitude, longitude, altitude,yaw, pitch);
	ARMAVLINK_FileGenerator_AddMissionItem(generator, &missionItem);
	
	char * pathToMavlinkFile = malloc(strlen(fileName)+strlen(projectPath)+1);;
	strcpy(pathToMavlinkFile, projectPath);
	strcat(pathToMavlinkFile, fileName);
	
	ARMAVLINK_FileGenerator_CreateMavlinkFile(generator, pathToMavlinkFile);
	
	printf ("%s\n",ARMAVLINK_Error_ToString (errorlog));
	return pathToMavlinkFile;
}

Am I not using the proper missionItems? I assumed that takeoffmissionitem made the drone takeoff and then go to the provided coordinates.

Thanks in advance for the help!
Regards
Norman


#2

Could you show us the produced MAVLink file?

Also here’s my code for executing the command:

case IHM_INPUT_EVENT_STARTAUTO:
    if(deviceController != NULL)
    {
        char* filePath = "flightplan.mavlink";
        enum type {flightPlan, MapMyHouse};
        enum type mavType = flightPlan;
         
        deviceController->common->sendMavlinkStart(deviceController->common, filePath, (eARCOMMANDS_COMMON_MAVLINK_START_TYPE)mavType);
        IHM_PrintLog(ihm, "Starting Autonomous Flight", offset);
    }
    break;

#3

Here’s the mavlink file :

QGC WPL 120
0	0	3	22	0.000000	0.000000	0.000000	0.000000	48.847252	2.357799	1.300000	1

Don’t know if that’s what I’m supposed to get.
From what I can see, the main difference between your code and mine is in the way the type (flightplan/mapmyhouse) is set. Could the way I did it be the issue?


#4

I’d agree that your way of implementation might be the problem. According to the API your “flightPlan” argument should be of type enum. In your posted code I’m unsure of how you’ve defined flightPlan but I suspect that might be giving you your issues :wink:


#5

Hi,

Your drone needs to be calibrated and to know its own gps position.

This is starting the calibration process, not telling the drone it is calibrated. So please remove this command from your code. To see if your drone is calibrated, you can use FreeFlight.

Another problem is that you are not actually sending the mavlink file on the drone. Please use any ftp client (or libARDataTransfer) to put the file at the root of the ftp using port 61.

You can look through this thread. A lot of information is given, even though it is not using the same language.


#6

Still having several difficulties.
I tried to use libARDataTransfer to upload the mavlink file, but was unable to make it work. So I used filezilla to upload it manually to the flghtplan folder, but even then the flight did not start.
So I then used freeflight to calibrate the drone, but was still unable to launch the flightplan.
Is there anything I’m missing? Here’s my code :

void onInputEvent (eIHM_INPUT_EVENT event, void *customData)
{
    // Manage IHM input events
    ARCONTROLLER_Device_t *deviceController = (ARCONTROLLER_Device_t *)customData;
    eARCONTROLLER_ERROR error = ARCONTROLLER_OK;
    char * mavLinkFilePath;

	eARDATATRANSFER_ERROR result = ARDATATRANSFER_OK;
	eARUTILS_ERROR ftpError = ARUTILS_OK;
	//enum type {flightPlan, MapMyHouse};
    //enum type mavType = flightPlan;	//defines the file type   as FlightPlan (as opposed to MapMyHouse)
    eARCOMMANDS_COMMON_MAVLINKSTATE_MAVLINKFILEPLAYINGSTATECHANGED_TYPE mavType = ARCOMMANDS_COMMON_MAVLINKSTATE_MAVLINKFILEPLAYINGSTATECHANGED_TYPE_FLIGHTPLAN;
	eARDATATRANSFER_UPLOADER_RESUME resume = ARDATATRANSFER_UPLOADER_RESUME_FALSE;
	ARUTILS_Manager_t *ftpManager;
	ARDATATRANSFER_Manager_t *transferManager;
	ARDATATRANSFER_Uploader_ProgressCallback_t *progressCallBack;
	ARDATATRANSFER_Uploader_CompletionCallback_t *completionCallBack;
	int progressArg = 0;
	int completionArg = 0;
       
       switch (event)
       {
        case IHM_INPUT_START_MULTIPLE_WAYPOINT_FLIGHTPLAN:
    	//create a flightplan file with a single waypoint
    	mavLinkFilePath = createMultipleWaypointMavlinkFile( 48.847251, 2.357799, 1.30, 0, 0, 48.847074, 2.357520,1.30, 0,48.847039, 2.357979,1.30, 0, "flightplan.mavlink"); 
    	
    	//datatransfer manager
    	transferManager =  ARDATATRANSFER_Manager_New (&result);
    	//ftp manager
    	ftpManager =  ARUTILS_Manager_New(&ftpError);
    	
    	
    	//progressCallback
    	progressCallBack = FTPProgress;
    	//completionCallBack
    	completionCallBack = FTPCompletion;
    	
    	//FTP uploader for mavlink file
    	ARDATATRANSFER_Uploader_New (&transferManager, &ftpManager, "flightplan.mavlink", mavLinkFilePath, progressCallBack, &progressArg, completionCallBack, &completionArg, resume);
    	
    	
    	    	
    	ARDATATRANSFER_Uploader_ThreadRun (transferManager);
    	
    	
    	//start flightplan (mavlink)
		deviceController->common->sendMavlinkStart(deviceController->common, mavLinkFilePath, (eARCOMMANDS_COMMON_MAVLINK_START_TYPE)mavType);
		IHM_PrintInfo(ihm, "Starting Autonomous Flight");
    	break;

I’ll be honest I’m starting to get a little lost. I’ve read the other thread you posted Djavan, and it gave me some good pointers, but nothing I tried worked :confused:
Also, is there any way to calibrate the drone without using freeflight? Idealy I’d like my app to function enirely on it’s own.


#7

Hello.

Have you managed to solve your problem? Because I’m encountering exactly the same one.
Just to be sure, I’ve checked the error codes given by MavlinkPlayErrorStateChanged and everything is ok.


#8

The transfer needs to be done before sending the command that starts the flightPlan.

This code extract just start the file transfer but does not wait to complete before sending the command.