ESE350 project, Spring 2016, University of Pennsylvania

Dependencies:   Adafruit9-DOf Receiver mbed-rtos mbed

Revision:
2:c041e434eab6
Parent:
1:b87e95907a18
Child:
3:828e82089564
--- a/main.cpp	Thu Mar 31 20:24:24 2016 +0000
+++ b/main.cpp	Thu Mar 31 20:47:04 2016 +0000
@@ -4,7 +4,6 @@
 #include "Serial_base.h"
 #include "controller.h"
 
-
 DigitalOut myled(LED1);
 Adafruit_9DOF dof = Adafruit_9DOF();
 Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301);
@@ -13,8 +12,6 @@
 
 Serial pc(USBTX, USBRX);
 
-
-
 /* Offsets of gyro at rest */
 float x_offset = 0, y_offset = 0, z_offset = 0;
 
@@ -60,20 +57,14 @@
 
 int main()
 {
-    double F=0;
-    double M_x=0;
-    double M_y=0;
-    double M_z=0;
-
     initSensors();
 
-
-    //double *attitude = (double *) malloc(6 * sizeof(double));
     sensors_event_t accel_event;
     sensors_event_t mag_event;
     sensors_event_t gyro_event;
     sensors_vec_t   orientation;
-
+    
+    control result;
 
     while (1) {
 
@@ -107,12 +98,11 @@
         // get sensor values
 
         // call controller
-        M_x= controller(gyro_event, orientation);
+        controller(gyro_event, orientation, &result);
 
         // plot
 
         //pc.printf("F: %f M_x: %f M_y: %f M_z: %f\n\r",  F, M_x, M_y, M_z);
-        pc.printf("M_x: %f \n\r", M_x);
+        pc.printf("M_x: %f\tM_y: %f\tM_z: %f\tF: %f\n\r", result.M_x, result.M_y, result.M_z, result.F);
     }
-    //free(attitude);
 }