コード例 #1
0
// --------------------------------------------------------------------------
// ARDrone::open(IP address of AR.Drone)
// Description  : Initialize the AR.Drone.
// Return value : SUCCESS: 1  FAILURE: 0
// --------------------------------------------------------------------------
int ARDrone::open(const char *ardrone_addr)
{
    // Initialize FFmpeg
    av_register_all();
    avformat_network_init();
    av_log_set_level(AV_LOG_QUIET);

    // Save IP address
    strncpy(ip, ardrone_addr, 16);

    // Get version information
    if (!getVersionInfo()) return 0;
    printf("AR.Drone Ver. %d.%d.%d\n", version.major, version.minor, version.revision);

	//// getVersionInfo() takes too long before realising the drone is not connected
	//// it call tcp open, which makes a socket and tries to connect to it
	//// using the connect method, which has too big of a timeout.
	//// making a smaller, 5 sec timeout before checking the verison to see if drone connected.
	//// if not, return 0
	//if (!version.major) {
	//	// create timeout and wait 5 sec
	//	printf("Waiting for drone to connect...\n");
	//	msleep(5000);
	//	// check again
	//	if (!version.major) return 0;
	//}

    // Initialize AT command
    if (!initCommand()) return 0;

    // Initialize Navdata
    if (!initNavdata()) return 0;

    // Initialize Video
    if (!initVideo()) return 0;

    // Wait for updating state
    //msleep(500);

    // Get configurations
    if (!getConfig()) return 0;

    // Reset emergency
    resetWatchDog();
    resetEmergency();

    return 1;
}
コード例 #2
0
ファイル: ardrone.cpp プロジェクト: xxxlong/cvdrone
// --------------------------------------------------------------------------
// ARDrone::open(IP address of AR.Drone)
// Description  : Initialize the AR.Drone.
// Return value : SUCCESS: 1  FAILURE: 0
// --------------------------------------------------------------------------
int ARDrone::open(const char *ardrone_addr)
{
    #if _WIN32
    // Initialize WSA
    WSAData wsaData;
    WSAStartup(MAKEWORD(1,1), &wsaData);
    #endif

    // Initialize FFmpeg
    av_register_all();
    avformat_network_init();
    av_log_set_level(AV_LOG_QUIET);

    // Save IP address
    strncpy(ip, ardrone_addr, 16);

    // Get version information
    if (!getVersionInfo()) return 0;
    printf("AR.Drone Ver. %d.%d.%d\n", version.major, version.minor, version.revision);

    // Get configurations
    if (!getConfig()) return 0;

    // Initialize AT command
    if (!initCommand()) return 0;

    // Initialize Navdata
    if (!initNavdata()) return 0;

    // Initialize Video
    if (!initVideo()) return 0;

    // Wait for updating state
    msleep(500);

    // Reset emergency
    resetWatchDog();
    resetEmergency();

    return 1;
}
コード例 #3
0
ファイル: command.cpp プロジェクト: jackytck/cvdrone
// --------------------------------------------------------------------------
// ARDrone::landing()
// Description  : Land the AR.Drone.
// Return value : NONE
// --------------------------------------------------------------------------
void ARDrone::landing(void)
{
    resetWatchDog();
    resetEmergency();
    sockCommand.sendf("AT*REF=%d,290717696\r", seq++);
}
コード例 #4
0
ファイル: command.cpp プロジェクト: jackytck/cvdrone
// --------------------------------------------------------------------------
// ARDrone::takeoff()
// Description  : Take off the AR.Drone.
// Return value : NONE
// --------------------------------------------------------------------------
void ARDrone::takeoff(void)
{
    resetWatchDog();
    resetEmergency();
    sockCommand.sendf("AT*REF=%d,290718208\r", seq++);
}