850ded377d695d839c69d9ed940e75ac41018951
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Linux / sdk_demo / Sources / ardrone_testing_tool.c
1 /**
2  * @file main.c
3  * @author sylvain.gaeremynck@parrot.com
4  * @date 2009/07/01
5  */
6 #include <ardrone_testing_tool.h>
7
8 //ARDroneLib
9 #include <ardrone_tool/ardrone_time.h>
10 #include <ardrone_tool/Navdata/ardrone_navdata_client.h>
11 #include <ardrone_tool/Control/ardrone_control.h>
12 #include <ardrone_tool/UI/ardrone_input.h>
13
14 //Common
15 #include <config.h>
16 #include <ardrone_api.h>
17
18 //VP_SDK
19 #include <ATcodec/ATcodec_api.h>
20 #include <VP_Os/vp_os_print.h>
21 #include <VP_Api/vp_api_thread_helper.h>
22 #include <VP_Os/vp_os_signal.h>
23
24 //Local project
25 #include <UI/gamepad.h>
26 #include <Video/video_stage.h>
27
28 static int32_t exit_ihm_program = 1;
29
30 /* Implementing Custom methods for the main function of an ARDrone application */
31
32 /* The delegate object calls this method during initialization of an ARDrone application */
33 C_RESULT ardrone_tool_init_custom(int argc, char **argv)
34 {
35   /* Registering for a new device of game controller */
36   ardrone_tool_input_add( &gamepad );
37
38   /* Start all threads of your application */
39   START_THREAD( video_stage, NULL );
40   
41   return C_OK;
42 }
43
44 /* The delegate object calls this method when the event loop exit */
45 C_RESULT ardrone_tool_shutdown_custom()
46 {
47   /* Relinquish all threads of your application */
48   JOIN_THREAD( video_stage );
49
50   /* Unregistering for the current device */
51   ardrone_tool_input_remove( &gamepad );
52
53   return C_OK;
54 }
55
56 /* The event loop calls this method for the exit condition */
57 bool_t ardrone_tool_exit()
58 {
59   return exit_ihm_program == 0;
60 }
61
62 C_RESULT signal_exit()
63 {
64   exit_ihm_program = 0;
65
66   return C_OK;
67 }
68
69 /* Implementing thread table in which you add routines of your application and those provided by the SDK */
70 BEGIN_THREAD_TABLE
71   THREAD_TABLE_ENTRY( ardrone_control, 20 )
72   THREAD_TABLE_ENTRY( navdata_update, 20 )
73   THREAD_TABLE_ENTRY( video_stage, 20 )
74 END_THREAD_TABLE
75