waypoint.cxx 1.4 KB
#include <string>
#include <thread>
#include "uav_core.h"
#include "uav_logger.h"
#include "uav_platform.h"
#include "uav_data_type.h"
#include "uav_waypoint.h"
#include "uav_sdk_app_info.h"

static void waypoint_routine(const std::string &kmz_file)
{
    //wait register success
    if(false == wait_register_ready(100)){
        LOG_ERROR("waitHandShakeRegister failed");
        return;
    }

    UAV_Waypoint_Init();

    std::this_thread::sleep_for(std::chrono::seconds(3));
    if(0 != UAV_Waypoint_UploadFile_kmz(kmz_file.c_str()))
    {
        LOG_ERROR("upload kmz file failed!");
        return;
    }
    std::this_thread::sleep_for(std::chrono::seconds(3)); ///< wait a while for kmz file upload success
    if(0 != UAV_Waypoint_Action(UAV_WAYPOINT_ACTION_START, 3000))
    {
        LOG_ERROR("start waypoint failed!");
        return;
    }

    while(1)
    {
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }
}

int main(int argc, char *argv[])
{
    T_AUserInfo usrInfo;

    logger_init(std::string(argv[1]));
    if(false == uav_sdk_app_info_init(&usrInfo)) {
        LOG_ERROR("uav_sdk_app_info_init failed");
        return -1;
    }
    UAV_Core_Init(&usrInfo);
    UAV_Core_SetAlias("waypoint");
    UAV_Network_Init(LOCALHOST_ETHERNET);

    std::string kmz_file = std::string(argv[3]);
    std::thread waypoint(waypoint_routine, kmz_file);
    waypoint.detach();

    return UAV_Core_ApplicationStart();
}