int drone_init(void* userdata) { drone_userdata = userdata; C_RESULT res; drone_doRunArdrone = 1; res = ardrone_tool_setup_com(NULL); if (SUCCEED(res)) { char ipAddress[256] = "192.168.1.1"; ardrone_tool_init(ipAddress, strlen(ipAddress), NULL); drone_doRun = 1; drone_targetEmergency = 1; drone_navdataCallback = NULL; drone_videoCallback = NULL; drone_atCommands = 0; START_THREAD(drone_main_thread, NULL); START_THREAD(drone_video_stage_thread, NULL); return 1; } else { drone_doRunArdrone = 0; } return 0; }
/*--------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------*/ C_RESULT ardrone_tool_init(int argc, char **argv) { C_RESULT res; //Fill structure AT codec and built the library AT commands. ardrone_at_init( wifi_ardrone_ip, strlen( wifi_ardrone_ip) ); // Init subsystems ardrone_timer_reset(&ardrone_tool_timer); ardrone_tool_input_init(); ardrone_control_init(); ardrone_navdata_client_init(); // Init custom tool res = ardrone_tool_init_custom(argc, argv); //Opens a connection to AT port. ardrone_at_open(); START_THREAD(navdata_update, 0); START_THREAD(ardrone_control, 0); ardrone_tool_configure(); // Send start up configuration ardrone_at_set_pmode( MiscVar[0] ); ardrone_at_set_ui_misc( MiscVar[0], MiscVar[1], MiscVar[2], MiscVar[3] ); return res; }
/* The delegate object calls this method during initialization of an ARDrone application */ C_RESULT ardrone_tool_init_custom(int argc, char **argv) { /* Registering for a new device of game controller */ //ardrone_tool_input_add( &gamepad ); //ardrone_tool_input_add( &ps3pad ); /* Start all threads of your application */ START_THREAD( video_stage, NULL ); START_THREAD( main_application_thread , NULL ); return C_OK; }
C_RESULT ardrone_tool_init( const char* ardrone_ip, size_t n, AT_CODEC_FUNCTIONS_PTRS *ptrs, const char *appname, const char *usrname) { // Initalize mutex and condition vp_os_mutex_init(&ardrone_tool_mutex); ardrone_tool_in_pause = FALSE; // Initialize ardrone_control_config structures; ardrone_tool_reset_configuration(); // ardrone_control_config_default initialisation. Sould not be modified after that ! vp_os_memcpy ((void *)&ardrone_control_config_default, (const void *)&ardrone_control_config, sizeof (ardrone_control_config_default)); // initialization of application defined default values vp_os_memcpy ((void *)&ardrone_application_default_config, (const void *)&ardrone_control_config, sizeof (ardrone_application_default_config)); //Fill structure AT codec and built the library AT commands. if( ptrs != NULL ) ardrone_at_init_with_funcs( ardrone_ip, n, ptrs ); else ardrone_at_init( ardrone_ip, n ); // Save appname/appid for reconnections if (NULL != appname) { ardrone_gen_appid (appname, __SDK_VERSION__, app_id, app_name, sizeof (app_name)); } // Save usrname/usrid for reconnections if (NULL != usrname) { ardrone_gen_usrid (usrname, usr_id, usr_name, sizeof (usr_name)); } // Create pseudorandom session id ardrone_gen_sessionid (ses_id, ses_name, sizeof (ses_name)); // Init subsystems ardrone_timer_reset(&ardrone_tool_timer); ardrone_timer_update(&ardrone_tool_timer); ardrone_tool_input_init(); ardrone_control_init(); ardrone_tool_configuration_init(); ardrone_navdata_client_init(); //Opens a connection to AT port. ardrone_at_open(); START_THREAD(navdata_update, 0); START_THREAD(ardrone_control, 0); // Send start up configuration ardrone_at_set_pmode( MiscVar[0] ); ardrone_at_set_ui_misc( MiscVar[0], MiscVar[1], MiscVar[2], MiscVar[3] ); return C_OK; }
int main(int argc, char **argv) { START_THREAD(escaper, NO_PARAM); START_THREAD(app, argv); JOIN_THREAD(escaper); JOIN_THREAD(app); return EXIT_SUCCESS; }
C_RESULT ardrone_tool_init_custom(int argc, char **argv) { /* Registering for a new device of game controller */ /* Start all threads of your application */ //control_data = (control_data_t *) malloc (sizeof(control_data_t); vp_os_mutex_init( &control_data_lock ); START_THREAD( video_stage, NULL ); START_THREAD( ardrone_control, NULL ); START_THREAD( thread1, NULL ); return C_OK; }
/* The delegate object calls this method during initialization of an ARDrone application */ C_RESULT ardrone_tool_init_custom() { /* Registering for a new device of game controller */ // ardrone_tool_input_add( &gamepad ); /* Start all threads of your application */ START_THREAD( video_stage, NULL ); init_gui(argc_cpy, argv_cpy); /* Creating the GUI */ START_THREAD(gui, NULL); /* Starting the GUI thread */ return C_OK; }
C_RESULT ardrone_tool_init_custom(int argc, char **argv) { /* Registering for a new device of game controller */ /* Start all threads of your application */ //control_data = (control_data_t *) malloc (sizeof(control_data_t); end_all_threads = 0; global_video_feed = NULL; START_THREAD( video_stage, NULL ); START_THREAD( ardrone_control, NULL ); START_THREAD( comm_control, NULL ); START_THREAD( control_system, NULL ); return C_OK; }
int main(int argc, char **argv) { START_THREAD(app, argv); JOIN_THREAD(app); return EXIT_SUCCESS; }
DEFINE_THREAD_ROUTINE(mobile_main, data) { C_RESULT res = C_FAIL; vp_com_wifi_config_t *config = NULL; mobile_main_param_t *param = (mobile_main_param_t *)data; ardroneEngineCallback callback = param->callback; vp_os_memset(drone_address, 0x0, sizeof(drone_address)); // TODO(johnb): Make this autodetect based on network interfaces while(((config = (vp_com_wifi_config_t *)wifi_config()) != NULL) && (strcmp(config->itfName, WIFI_ITFNAME) != 0)) { PRINT("Wait WIFI connection !\n"); vp_os_delay(250); } // Get drone_address vp_os_memcpy(drone_address, config->server, strlen(config->server)); PRINT("Drone address %s\n", drone_address); // Get iphone_mac_address get_iphone_mac_address(config->itfName); PRINT("Iphone MAC Address %s\n", iphone_mac_address); res = ardrone_tool_setup_com( NULL ); if( FAILED(res) ) { PRINT("Wifi initialization failed. It means either:\n"); PRINT("\t* you're not root (it's mandatory because you can set up wifi connection only as root)\n"); PRINT("\t* wifi device is not present (on your pc or on your card)\n"); PRINT("\t* you set the wrong name for wifi interface (for example rausb0 instead of wlan0) \n"); PRINT("\t* ap is not up (reboot card or remove wifi usb dongle)\n"); PRINT("\t* wifi device has no antenna\n"); } else { START_THREAD(video_stage, NULL); res = ardrone_tool_init(drone_address, strlen(drone_address), NULL, param->appName, param->usrName); callback(ARDRONE_ENGINE_INIT_OK); ardrone_tool_set_refresh_time(1000 / kAPS); while( SUCCEED(res) && bContinue == TRUE ) { ardrone_tool_update(); } JOIN_THREAD(video_stage); res = ardrone_tool_shutdown(); } vp_os_free (data); return (THREAD_RET)res; }
int main(int argc, char **argv) { if(argc != 2) { PRINT("You must specify a filename.\n"); return EXIT_FAILURE; } START_THREAD(escaper, NO_PARAM); START_THREAD(app, argv); JOIN_THREAD(escaper); JOIN_THREAD(app); return EXIT_SUCCESS; }
void ardroneEngineStart ( ardroneEngineCallback callback ) { #ifdef DEBUG_THREAD PRINT( "%s\n", __FUNCTION__ ); #endif video_stage_init(); START_THREAD( mobile_main, callback); }
void background_upload_file(LwqqClient* lc,LwqqMsgOffFile* file,LWQQ_PROGRESS file_trans_on_progress,PurpleXfer* xfer) { void** data = s_malloc(sizeof(void*)*4); data[0] = lc; data[1] = file; data[2] = file_trans_on_progress; data[3] = xfer; START_THREAD(_background_upload_file,data); }
/* The delegate object calls this method during initialization of an ARDrone application */ C_RESULT ardrone_tool_init_custom(void) { /* Registering for a new device of game controller */ // ardrone_tool_input_add( &gamepad ); /* Start all threads of your application */ START_THREAD( video_stage, NULL ); return C_OK; }
DEFINE_THREAD_ROUTINE(mobile_main, data) { C_RESULT res = C_FAIL; char drone_address[64]; unsigned long theAddr; ardroneEngineCallback callback = (ardroneEngineCallback)data; vp_os_memset(drone_address, 0x0, sizeof(drone_address)); while((theAddr = deviceIPAddress(WIFI_ITFNAME, iphone_mac_address)) == LOCALHOST) { PRINT("Wait WIFI connection !\n"); vp_os_delay(250); } struct in_addr drone_addr; drone_addr.s_addr = htonl( ntohl((in_addr_t)theAddr) - 1 ); vp_os_memcpy(drone_address, inet_ntoa(drone_addr), strlen(inet_ntoa(drone_addr))); PRINT("Drone address %s\n", drone_address); PRINT("Iphone MAC Address %s\n", iphone_mac_address); res = ardrone_tool_setup_com( NULL ); if( FAILED(res) ) { PRINT("Wifi initialization failed. It means either:\n"); PRINT("\t* you're not root (it's mandatory because you can set up wifi connection only as root)\n"); PRINT("\t* wifi device is not present (on your pc or on your card)\n"); PRINT("\t* you set the wrong name for wifi interface (for example rausb0 instead of wlan0) \n"); PRINT("\t* ap is not up (reboot card or remove wifi usb dongle)\n"); PRINT("\t* wifi device has no antenna\n"); } else { res = ardrone_tool_init(drone_address, strlen(drone_address), NULL); callback(ARDRONE_ENGINE_INIT_OK); if(SUCCEED(res)) { START_THREAD(video_stage, NULL); res = ardrone_tool_set_refresh_time(1000 / kAPS); while( SUCCEED(res) && bContinue == TRUE ) { res = ardrone_tool_update(); } JOIN_THREAD(video_stage); } res = ardrone_tool_shutdown(); } return (THREAD_RET)0; }
/* The delegate object calls this method during initialization of an ARDrone application */ C_RESULT ardrone_tool_init_custom(int argc, char **argv) { /* Create GUI */ init_gui(argc, argv); /* Creating the GUI */ START_THREAD(gui, NULL); /* Starting the GUI thread */ /* Registering for a new device of game controller */ ardrone_tool_input_add( &gamepad ); /* Cambia camara ZAP_VIDEO_CHANNEL channel = ZAP_CHANNEL_HORI some channel, ex: ZAP_CHANNEL_LARGE_HORI_SMALL_VERT; ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_channel, &channel, NULL);*/ /* Start all threads of your application */ START_THREAD( video_stage, NULL ); return C_OK; }
void appInit(void) { __android_log_print( ANDROID_LOG_INFO, "ARDrone", "Enter in appInit\n" ); // video rendering video_init(); // int status; // get_drone_ip(); gAppAlive = 1; START_THREAD( mobile_main, NULL); }
/*-------------------------------------------------------------------- The delegate object calls this method during initialization of an ARDrone application --------------------------------------------------------------------*/ C_RESULT ardrone_tool_init_custom(int argc, char **argv) { /* Change the console title */ vp_os_mutex_init(&consoleMutex); system("cls"); SetConsoleTitle(TEXT("Parrot A.R. Drone SDK Demo for Windows")); //CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&HmiStart,NULL,0,0); //CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&HmiStart2,NULL,0,0); /* Registering for a new device of game controller */ ardrone_tool_input_add( &dx_keyboard ); ardrone_tool_input_add( &dx_gamepad ); /* Start all threads of your application */ START_THREAD( directx_renderer_thread , NULL); START_THREAD( video_stage, NULL ); return C_OK; }
DEFINE_THREAD_ROUTINE(mobile_main, data) { __android_log_print( ANDROID_LOG_INFO, "ARDrone", "Enter in mobile_main thread\n" ); C_RESULT res = C_OK; char drone_address[24]; vp_os_memset(drone_address, 0x0, sizeof(drone_address)); sprintf(drone_address, WIFI_ARDRONE_IP); res = ardrone_tool_setup_com( NULL ); if( FAILED(res) ) { __android_log_print( ANDROID_LOG_INFO, "ARDrone", "Setup com failed\n" ); INFO("Wifi initialization failed. It means either:\n"); INFO("\t* you're not root (it's mandatory because you can set up wifi connection only as root)\n"); INFO("\t* wifi device is not present (on your pc or on your card)\n"); INFO("\t* you set the wrong name for wifi interface (for example rausb0 instead of wlan0) \n"); INFO("\t* ap is not up (reboot card or remove wifi usb dongle)\n"); INFO("\t* wifi device has no antenna\n"); } else { START_THREAD(video_stage, NULL); __android_log_print( ANDROID_LOG_INFO, "ARDrone", "Processing ardrone_tool_init\n" ); res = ardrone_tool_init(drone_address, strlen(drone_address), NULL); control_ack_init(); control_ack_configure_navdata_demo( FALSE ); if(SUCCEED(res)) { res = ardrone_tool_set_refresh_time(25); while( SUCCEED(res) && bContinue == TRUE ) { res = ardrone_tool_update(); } } JOIN_THREAD(video_stage); res = ardrone_tool_shutdown(); } __android_log_print( ANDROID_LOG_INFO, "ARDrone", "Exit mobile_main thread\n" ); return (THREAD_RET)0; }
void ardroneEngineStart ( ardroneEngineCallback callback, const char *appName, const char *usrName ) { #ifdef DEBUG_THREAD PRINT( "%s\n", __FUNCTION__ ); #endif video_stage_init(); mobile_main_param_t *param = vp_os_malloc (sizeof (mobile_main_param_t)); if (NULL != param) { param->callback = callback; strcpy(param->appName, appName); strcpy(param->usrName, usrName); START_THREAD( mobile_main, param); } }
C_RESULT ardrone_tool_init(int argc, char **argv) { C_RESULT res; ardrone_at_init( wifi_ardrone_ip, strlen( wifi_ardrone_ip) ); ardrone_timer_reset(&ardrone_tool_timer); ardrone_control_init(); ardrone_navdata_client_init(); res = ardrone_tool_init_custom(argc, argv); ardrone_at_open(); START_THREAD(ardrone_control, 0); ardrone_tool_configure(); ardrone_at_set_pmode( MiscVar[0] ); ardrone_at_set_ui_misc( MiscVar[0], MiscVar[1], MiscVar[2], MiscVar[3] ); return res; }
C_RESULT display_stage_open (display_stage_cfg_t *cfg) { // Check that we use RGB565 if (2 != cfg->bpp) { // If that's not the case, then don't display anything cfg->paramsOK = FALSE; } else { // Else, start GTK thread and window cfg->paramsOK = TRUE; cfg->frameBuffer = NULL; cfg->fbSize = 0; START_THREAD (gtk, cfg); } return C_OK; }
void parrot_ardrone_notify_start(JNIEnv* env, jobject obj, ardroneEngineCallback callback, const char *appName, const char *userName, const char* rootdir, const char* flightdir, int flight_storing_size, academy_download_new_media academy_download_callback_func, VIDEO_RECORDING_CAPABILITY recordingCapability) { video_stage_init(); video_recorder_init(); mobile_main_param_t *param = vp_os_malloc(sizeof(mobile_main_param_t)); if(param==NULL){ LOGII("paramisnull"); } if (NULL != param) { param->obj = (*env)->NewGlobalRef(env, obj); param->callback = callback; vp_os_memset(¶m->app_name, 0, STRING_BUFFER_LENGTH); vp_os_memset(¶m->user_name, 0, STRING_BUFFER_LENGTH); vp_os_memset(¶m->root_dir, 0, STRING_BUFFER_LENGTH); vp_os_memset(¶m->flight_dir, 0, STRING_BUFFER_LENGTH); strncpy(param->app_name, appName, STRING_BUFFER_LENGTH); strncpy(param->user_name, userName, STRING_BUFFER_LENGTH); strncpy(param->root_dir, rootdir, STRING_BUFFER_LENGTH); strncpy(param->flight_dir, flightdir, STRING_BUFFER_LENGTH); param->flight_storing_size = flight_storing_size; param->academy_download_callback_func = academy_download_callback_func; ctrldata.recordingCapability = recordingCapability; LOGII("startsuccess"); START_THREAD(app_main, param); } }
void BleMainWindow::onEncodeStart() { // m_imageProcessThread = new BleImageProcessThread(this); // m_imageProcessWidget->setProcessThread(m_imageProcessThread); // QSize si = MOption::instance()->option("res", "encoder").toSize(); // int fps = MOption::instance()->option("fps", "encoder").toInt(); // m_imageProcessThread->setResolution(si.width(), si.height()); // m_imageProcessThread->setInternal(1000 / fps); m_encoderThread = new BleEncoderThread(this); m_encoderThread->init(); m_audioCaptureThread = new BleAudioCapture; int audioSampleRate = MOption::instance()->option("sample_rate", "audio").toInt(); int audioChannels = -1; QString audioChannelsStr = MOption::instance()->option("channels", "audio").toString(); if (audioChannelsStr == "Mono") { audioChannels = 1; } else if (audioChannelsStr == "Stereo") { audioChannels = 2; } BleAssert(audioChannels != -1); int audioBitrate = MOption::instance()->option("bitrate", "audio").toInt() * 1000; int devID = MOption::instance()->option("dev_id", "audio").toInt(); int ret = m_audioCaptureThread->startCapture(audioBitrate, audioSampleRate, audioChannels, devID); if (ret != BLE_SUCESS) { QjtMessageBox::critical(this, tr("error"), tr("start audio capture error.")); } if (!m_sendThread) { m_sendThread = new BleRtmpSendThread(this); connect(m_sendThread, SIGNAL(status(int,int,int,qint64)) , this, SLOT(onStatus(int,int,int,qint64))); START_THREAD(m_sendThread); }
void bdbuf_test4_1_main() { bdbuf_test_msg msg; TEST_START("Test 4.1"); START_THREAD(1, bdbuf_test4_1_thread1); START_THREAD(2, bdbuf_test4_1_thread2); /* * Step 1: * Call rtems_bdbuf_read(#N) in thread #1. * Wait for read request in disk driver. */ WAIT_DRV_MSG(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* Wait for return from rtems_bdbuf_read(#N) function. */ WAIT_THREAD_SYNC(1); /* * Step 2: * Call rtems_bdbuf_read(#N) in thread #2. */ CONTINUE_THREAD(2); /* Make sure that thread #2 blocks */ CHECK_THREAD_BLOCKED(2); TEST_CHECK_RESULT("2"); /* * Step 3: * Call rtems_bdbuf_sync (#N) in thread #1. */ CONTINUE_THREAD(1); /* * Setp 4: * Wait for Write request to device driver. */ WAIT_DRV_MSG_WR(&msg); /* Check that both threads are blocked right now */ CHECK_THREAD_BLOCKED(1); CHECK_THREAD_BLOCKED(2); /* Send Write complete notification */ SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* * Step 5: * Check that rtems_bdbuf_sync(#N) call is unlocked. */ WAIT_THREAD_SYNC(1); TEST_CHECK_RESULT("5"); /* * Step 6: * Check that rtems_bdbuf_read(#N) call in thread #2 is unlocked. */ WAIT_THREAD_SYNC(2); /* * Step 7: * Release buffer in thread #2 */ CONTINUE_THREAD(2); /* * Exit from thread #1. */ CONTINUE_THREAD(1); TEST_END(); }
void bdbuf_test3_3_main() { bdbuf_test_msg msg; TEST_START("Test 3.3"); /* * Create working threads. */ SET_THREAD_PRIORITY(2, LOW); SET_THREAD_PRIORITY(3, HIGH); START_THREAD(1, bdbuf_test3_3_thread1); START_THREAD(2, bdbuf_test3_3_thread2); START_THREAD(3, bdbuf_test3_3_thread3); /* * Start thread #1: it will read buffer #N1. * Driver is asked to read this buffer. */ WAIT_DRV_MSG(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); WAIT_THREAD_SYNC(1); /* * Block thread #2 and thread #3 on get buffers #N2 and #N3 * correspondingly (bdbuf librbary has no buffers available). */ CONTINUE_THREAD(2); CONTINUE_THREAD(3); /* Make sure threads managed to block on the buffers get. */ CHECK_THREAD_BLOCKED(2); CHECK_THREAD_BLOCKED(3); /* * Step 4: * Thread #1 release buffer. */ CONTINUE_THREAD(1); /* Wait for read request in the driver (for thread #2) */ WAIT_DRV_MSG(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* Check that there is no read request for another block */ CHECK_NO_DRV_MSG(); /* * Check that thread #2 unblocked after this. */ WAIT_THREAD_SYNC(2); TEST_CHECK_RESULT("5"); /* Thread #3 is still in blocked state */ CHECK_THREAD_BLOCKED(3); /* Release buffer in thread #2 */ CONTINUE_THREAD(2); /* Wait for read request in the driver (for thread #3) */ WAIT_DRV_MSG(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* Wait for thread #3 to be unblocked */ WAIT_THREAD_SYNC(3); /* Release buffer in thread #3 */ CONTINUE_THREAD(3); CHECK_NO_DRV_MSG(); TEST_END(); }
void bdbuf_test3_1_main() { bdbuf_test_msg msg; TEST_START("Test 3.1"); START_THREAD(1, bdbuf_test3_1_thread1); START_THREAD(2, bdbuf_test3_1_thread2); /* * Step 1-3: * Wait for sync from thread #1. * Thread #1 switch a buffer for #N into ACCESS_MODIFIED state. */ WAIT_THREAD_SYNC(1); TEST_CHECK_RESULT("3"); /* * Step 4: * Thread #2 calls get() function and blocks * (there no buffers available in bdbuf library). */ CONTINUE_THREAD(2); /* Make sure thread #2 managed to block on the buffer. */ CHECK_THREAD_BLOCKED(2); /* * Step 6: * Thread #1 release buffer. */ CONTINUE_THREAD(1); /* * Buffer released in thread #1 was in MODIFIED state, so * there will be a request for disk write */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* * Check that thread #2 unblocked after this. */ WAIT_THREAD_SYNC(2); TEST_CHECK_RESULT("5"); /* * Release buffer in thread #2 */ CONTINUE_THREAD(2); /* * Buffer released in thread #2 switched to MODIFIED state, so * there will be a request for disk write */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); TEST_END(); }
C_RESULT ardrone_tool_init_custom(void) { /** * Set application default configuration * * In this example, we use the AR.FreeFlight configuration : * - Demo navdata rate (15Hz) * - Useful additionnal navdata packets enabled (detection, games, video record, wifi quality estimation ...) * - Adaptive video enabled (bitrate_ctrl_mode) -> video bitrate will change according to the available bandwidth */ ardrone_application_default_config.navdata_demo = TRUE; //use this -> NAVDATA_OPTION_FULL_MASK //or coment the line below if detection doesn't work ardrone_application_default_config.navdata_options = NAVDATA_OPTION_FULL_MASK;//(NAVDATA_OPTION_MASK(NAVDATA_DEMO_TAG) | NAVDATA_OPTION_MASK(NAVDATA_VISION_DETECT_TAG) | NAVDATA_OPTION_MASK(NAVDATA_GAMES_TAG) | NAVDATA_OPTION_MASK(NAVDATA_MAGNETO_TAG) | NAVDATA_OPTION_MASK(NAVDATA_HDVIDEO_STREAM_TAG) | NAVDATA_OPTION_MASK(NAVDATA_WIFI_TAG)); if (IS_ARDRONE2){ ardrone_application_default_config.video_codec = drone2Codec; } else { ardrone_application_default_config.video_codec = drone1Codec; } ardrone_application_default_config.video_channel = videoChannel; ardrone_application_default_config.bitrate_ctrl_mode = 1; /** * Define the number of video stages we'll add before/after decoding */ #define EXAMPLE_PRE_STAGES 1 #define EXAMPLE_POST_STAGES 1 /** * Allocate useful structures : * - index counter * - thread param structure and its substructures */ uint8_t stages_index = 0; specific_parameters_t *params = (specific_parameters_t *)vp_os_calloc (1, sizeof (specific_parameters_t)); specific_stages_t *example_pre_stages = (specific_stages_t *)vp_os_calloc (1, sizeof (specific_stages_t)); specific_stages_t *example_post_stages = (specific_stages_t *)vp_os_calloc (1, sizeof (specific_stages_t)); vp_api_picture_t *in_picture = (vp_api_picture_t *)vp_os_calloc (1, sizeof (vp_api_picture_t)); vp_api_picture_t *out_picture = (vp_api_picture_t *)vp_os_calloc (1, sizeof (vp_api_picture_t)); /** * Fill the vp_api_pictures used for video decodig * --> out_picture->format is mandatory for AR.Drone 1 and 2. Other lines are only necessary for AR.Drone 1 video decoding */ in_picture->width = 640; // Drone 1 only : Must be greater than the drone 1 picture size (320) in_picture->height = 360; // Drone 1 only : Must be greater that the drone 1 picture size (240) out_picture->framerate = 20; // Drone 1 only, must be equal to drone target FPS out_picture->format = PIX_FMT_RGB24; // MANDATORY ! Only RGB24, RGB565 are supported out_picture->width = in_picture->width; out_picture->height = in_picture->height; // Alloc Y, CB, CR bufs according to target format uint32_t bpp = 0; switch (out_picture->format) { case PIX_FMT_RGB24: // One buffer, three bytes per pixel bpp = 3; out_picture->y_buf = vp_os_malloc ( out_picture->width * out_picture->height * bpp ); out_picture->cr_buf = NULL; out_picture->cb_buf = NULL; out_picture->y_line_size = out_picture->width * bpp; out_picture->cb_line_size = 0; out_picture->cr_line_size = 0; break; case PIX_FMT_RGB565: // One buffer, two bytes per pixel bpp = 2; out_picture->y_buf = vp_os_malloc ( out_picture->width * out_picture->height * bpp ); out_picture->cr_buf = NULL; out_picture->cb_buf = NULL; out_picture->y_line_size = out_picture->width * bpp; out_picture->cb_line_size = 0; out_picture->cr_line_size = 0; break; default: fprintf (stderr, "Wrong video format, must be either PIX_FMT_RGB565 or PIX_FMT_RGB24\n"); exit (-1); break; } /** * Allocate the stage lists * * - "pre" stages are called before video decoding is done * -> A pre stage get the encoded video frame (including PaVE header for AR.Drone 2 frames) as input * -> A pre stage MUST NOT modify these data, and MUST pass it to the next stage * - Typical "pre" stage : Encoded video recording for AR.Drone 1 (recording for AR.Drone 2 is handled differently) * * - "post" stages are called after video decoding * -> The first post stage will get the decoded video frame as its input * --> Video frame format depend on out_picture->format value (RGB24 / RGB565) * -> A post stage CAN modify the data, as ardrone_tool won't process it afterwards * -> All following post stages will use the output of the previous stage as their inputs * - Typical "post" stage : Display the decoded frame */ example_pre_stages->stages_list = (vp_api_io_stage_t *)vp_os_calloc (EXAMPLE_PRE_STAGES, sizeof (vp_api_io_stage_t)); example_post_stages->stages_list = (vp_api_io_stage_t *)vp_os_calloc (EXAMPLE_POST_STAGES, sizeof (vp_api_io_stage_t)); /** * Fill the PRE stage list * - name and type are debug infos only * - cfg is the pointer passed as "cfg" in all the stages calls * - funcs is the pointer to the stage functions */ stages_index = 0; vp_os_memset (&precfg, 0, sizeof (pre_stage_cfg_t)); strncpy (precfg.outputName, encodedFileName, 255); example_pre_stages->stages_list[stages_index].name = "Encoded Dumper"; // Debug info example_pre_stages->stages_list[stages_index].type = VP_API_FILTER_DECODER; // Debug info example_pre_stages->stages_list[stages_index].cfg = &precfg; example_pre_stages->stages_list[stages_index++].funcs = pre_stage_funcs; example_pre_stages->length = stages_index; /** * Fill the POST stage list * - name and type are debug infos only * - cfg is the pointer passed as "cfg" in all the stages calls * - funcs is the pointer to the stage functions */ stages_index = 0; vp_os_memset (&dispCfg, 0, sizeof (display_stage_cfg_t)); dispCfg.bpp = bpp; dispCfg.decoder_info = in_picture; example_post_stages->stages_list[stages_index].name = "Decoded display"; // Debug info example_post_stages->stages_list[stages_index].type = VP_API_OUTPUT_SDL; // Debug info example_post_stages->stages_list[stages_index].cfg = &dispCfg; example_post_stages->stages_list[stages_index++].funcs = display_stage_funcs; example_post_stages->length = stages_index; /** * Fill thread params for the ardrone_tool video thread * - in_pic / out_pic are reference to our in_picture / out_picture * - pre/post stages lists are references to our stages lists * - needSetPriority and priority are used to control the video thread priority * -> if needSetPriority is set to 1, the thread will try to set its priority to "priority" * -> if needSetPriority is set to 0, the thread will keep its default priority (best on PC) */ params->in_pic = in_picture; params->out_pic = out_picture; params->pre_processing_stages_list = example_pre_stages; params->post_processing_stages_list = example_post_stages; params->needSetPriority = 0; params->priority = 0; //set the tag detection ENEMY_COLORS_TYPE enemyColors = ARDRONE_DETECTION_COLOR_ORANGE_BLUE; ARDRONE_TOOL_CONFIGURATION_ADDEVENT (enemy_colors, &enemyColors, NULL); CAD_TYPE detectType = CAD_TYPE_MULTIPLE_DETECTION_MODE; ARDRONE_TOOL_CONFIGURATION_ADDEVENT (detect_type, &detectType, NULL); uint32_t detectH = TAG_TYPE_MASK (TAG_TYPE_SHELL_TAG_V2); ARDRONE_TOOL_CONFIGURATION_ADDEVENT (detections_select_h, &detectH, NULL); /** * Start the video thread (and the video recorder thread for AR.Drone 2) */ START_THREAD(video_stage, params); START_THREAD (video_recorder, NULL); video_stage_init(); if (2 <= ARDRONE_VERSION ()) { START_THREAD (video_recorder, NULL); video_recorder_init (); } video_stage_resume_thread(); //King of the Hill threads START_THREAD(wiimote_logic, NULL); START_THREAD(drone_logic, NULL); START_THREAD(score_logic, NULL); return C_OK; }
void bdbuf_test1_2_main() { bdbuf_test_msg msg; TEST_START("Test 1.2"); START_THREAD(1, bdbuf_test1_2_thread1); START_THREAD(2, bdbuf_test1_2_thread2); /* * Step 1: * Thread #1 calls rtems_bdbuf_read() and we block * this thread on data transfer operation. */ WAIT_DRV_MSG(&msg); /* * Step 2: * Thread #2 calls rtems_bdbuf_read() for the same * block number, as the result it shall block waiting * on buffer state change. */ CONTINUE_THREAD(2); /* Make sure thread #2 managed to block on the buffer. */ CHECK_THREAD_BLOCKED(2); /* * Step 3: * Unblock thread #1 by reporting data transfer result. */ SEND_DRV_MSG(0, 0, RTEMS_IO_ERROR, EFAULT); /* * Wait for sync from thread #1. */ WAIT_THREAD_SYNC(1); CONTINUE_THREAD(1); TEST_CHECK_RESULT("3"); /* * Step 4: * For thread #2 bdbuf shall try to re-read data. * As the result we will get read call to device driver. */ WAIT_DRV_MSG(&msg); /* Check that thread #2 is still blocked */ CHECK_THREAD_BLOCKED(2); /* * Step 5: * Report an error again from the driver. */ SEND_DRV_MSG(0, 0, RTEMS_IO_ERROR, EFAULT); /* * Wait for sync from thread #2. */ WAIT_THREAD_SYNC(2); CONTINUE_THREAD(2); TEST_CHECK_RESULT("5"); TEST_END(); }
void bdbuf_test3_2_main() { bdbuf_test_msg msg; TEST_START("Test 3.2"); /* * Create working threads. */ SET_THREAD_PRIORITY(2, LOW); SET_THREAD_PRIORITY(3, HIGH); START_THREAD(1, bdbuf_test3_2_thread1); START_THREAD(2, bdbuf_test3_2_thread2); START_THREAD(3, bdbuf_test3_2_thread3); /* * Start thread #1: it will read buffer #N1. * Driver is asked to read this buffer. */ WAIT_DRV_MSG(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); WAIT_THREAD_SYNC(1); /* * Block thread #2 and thread #3 on get buffers #N1 and #N2 * correspondingly. */ CONTINUE_THREAD(2); CONTINUE_THREAD(3); /* Make sure threads managed to block on the buffers get. */ CHECK_THREAD_BLOCKED(2); CHECK_THREAD_BLOCKED(3); /* * Step 4: * Thread #1 release buffer. */ CONTINUE_THREAD(1); /* * Check that thread #2 unblocked after this. */ WAIT_THREAD_SYNC(2); TEST_CHECK_RESULT("5"); CHECK_THREAD_BLOCKED(3); /* Release buffer in thread #2 */ CONTINUE_THREAD(2); /* wait for driver message to flush it onto a disk */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* Wait for thread #3 to be unblocked */ WAIT_THREAD_SYNC(3); /* Release buffer in thread #3 */ CONTINUE_THREAD(3); /* wait for driver message to flush it onto a disk */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); TEST_END(); }