14.01.2013 Views

A.R.Drone Developer Guide - Abstract

A.R.Drone Developer Guide - Abstract

A.R.Drone Developer Guide - Abstract

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

24<br />

Listing 5.4: Example of navdata management function<br />

/* Receving navdata during the event loop */<br />

inline C_RESULT demo_navdata_client_process( const navdata_unpacked_t* const<br />

navdata )<br />

{<br />

const navdata_demo_t* const nd = &navdata->navdata_demo;<br />

}<br />

printf("Navdata for flight demonstrations\n");<br />

printf("Control state : %s\n",ctrl_state_str(nd->ctrl_state));<br />

printf("Battery level : %i/100\n",nd->vbat_flying_percentage);<br />

printf("Orientation : [Theta] %f [Phi] %f [Psi] %f\n",nd->theta,nd->phi,nd<br />

->psi);<br />

printf("Altitude : %i\n",nd->altitude);<br />

printf("Speed : [vX] %f [vY] %f\n",nd->vx,nd->vy);<br />

printf("\033[6A"); // Ansi escape code to go up 6 lines<br />

return C_OK;<br />

5.4 Command line parsing for a particular application<br />

The user can implement functions to add arguments to the default command line. Functions<br />

are defined in file :<br />

• ardrone_tool_display_cmd_line_custom (Not mandatory): Displays help for particular<br />

commands.<br />

• ardrone_tool_check_argc_custom (Not mandatory) : Checks the number of arguments.<br />

• ardrone_tool_parse_cmd_line_custom (Not mandatory): Checks a particular line command.<br />

5.5 Thread management in the application<br />

In the preceding section, we showed how the AR<strong>Drone</strong> application was initialized and how<br />

it manages the Navdata and control events. In addition to those aspects of the application<br />

creation, there are also smaller details that need to be considered before building a final application.<br />

It’s the responsibility of the user to manage the threads. To do so, we must declare a thread<br />

table with MACRO defined in vp_api_thread_helper.h file. Listing 5.5 shows how to declare a<br />

threads table.<br />

The threads navdata_update and ardrone_control do not need to be launched and released;<br />

this is done by the AR<strong>Drone</strong>Main for all other threads, you must use the MACRO named<br />

START_THREAD and JOIN_THREAD.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!