ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Linux / sdk_demo / Sources / Navdata / navdata.c
diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/Linux/sdk_demo/Sources/Navdata/navdata.c b/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/Linux/sdk_demo/Sources/Navdata/navdata.c
new file mode 100644 (file)
index 0000000..e1f1692
--- /dev/null
@@ -0,0 +1,40 @@
+#include <ardrone_tool/Navdata/ardrone_navdata_client.h>
+
+#include <Navdata/navdata.h>
+#include <stdio.h>
+
+/* Initialization local variables before event loop  */
+inline C_RESULT demo_navdata_client_init( void* data )
+{
+  return C_OK;
+}
+
+/* Receving navdata during the event loop */
+inline C_RESULT demo_navdata_client_process( const navdata_unpacked_t* const navdata )
+{
+       const navdata_demo_t*nd = &navdata->navdata_demo;
+
+       printf("=====================\nNavdata for flight demonstrations =====================\n\n");
+
+       printf("Control state : %i\n",nd->ctrl_state);
+       printf("Battery level : %i mV\n",nd->vbat_flying_percentage);
+       printf("Orientation   : [Theta] %4.3f  [Phi] %4.3f  [Psi] %4.3f\n",nd->theta,nd->phi,nd->psi);
+       printf("Altitude      : %i\n",nd->altitude);
+       printf("Speed         : [vX] %4.3f  [vY] %4.3f  [vZPsi] %4.3f\n",nd->theta,nd->phi,nd->psi);
+
+       printf("\033[8A");
+
+  return C_OK;
+}
+
+/* Relinquish the local resources after the event loop exit */
+inline C_RESULT demo_navdata_client_release( void )
+{
+  return C_OK;
+}
+
+/* Registering to navdata client */
+BEGIN_NAVDATA_HANDLER_TABLE
+  NAVDATA_HANDLER_TABLE_ENTRY(demo_navdata_client_init, demo_navdata_client_process, demo_navdata_client_release, NULL)
+END_NAVDATA_HANDLER_TABLE
+