Regenerating PPM signal based on distances from ultrasonic sensors, ESP8266 for connectin via wifi. Autonomous quadcopter behaviour, autonomou height holding. Flying direction based on front and back ultrasonic sensors.

Dependencies:   ConfigFile HCSR04 PID PPM2 mbed-rtos mbed

Branch:
DistanceRegulation
Revision:
36:ed8b7b7b6cfa
Parent:
35:b09e19c855f6
Child:
38:801fee0330e2
--- a/distanceRegulation.h	Sat Mar 03 15:38:10 2018 +0000
+++ b/distanceRegulation.h	Sun Mar 04 15:17:38 2018 +0000
@@ -24,7 +24,7 @@
     //pc.printf("Flight controller task started\r\n");
     
     uint16_t channels[CHANNELS];
-    int distance1=0;
+    float distance1=0;
     int distance2=0;
     float groundDistancePIDValue;
     int regulatedThrottle;
@@ -64,11 +64,19 @@
         
         distance1 = _sonic->getDistan1();
         //distance2 = _sonic->getDistan2();
-        pc.printf("%d \n\r", distance1);
+        //pc.printf("%f \n\r", distance1);
+        //float p = _groundDistance->getPParam();
+        //float i = _groundDistance->getIParam();
+        //float d = _groundDistance->getDParam();
+        //float max = _groundDistance->getInMax();
+        //pc.printf("%f \n\r", max);
+        //pc.printf("%f \n\r", p);
+        //pc.printf("%f \n\r", i);
+        //pc.printf("%f \n\r", d);
         //pc.printf("distance2: %d \n\r", distance2);
         _groundDistance->setProcessValue(distance1);
         groundDistancePIDValue = _groundDistance->compute();
-        pc.printf("pid value %f \n\r", groundDistancePIDValue);
+        //pc.printf("pid value %f \n\r", groundDistancePIDValue);
         
         //Update PWM values
         regulatedThrottle = channels[THROTTLE] + _bias + groundDistancePIDValue;
@@ -81,9 +89,9 @@
             regulatedThrottle = 1010;
         
         
-        pc.printf("channel throttle pid value: %f \n\r", groundDistancePIDValue); 
-        pc.printf("channel throttle original value: %d \n\r", channels[THROTTLE]);
-        pc.printf("channel throttle final value: %d \n\r", regulatedThrottle);
+        //pc.printf("channel throttle pid value: %f \n\r", groundDistancePIDValue); 
+        //pc.printf("channel throttle original value: %d \n\r", channels[THROTTLE]);
+        //pc.printf("channel throttle final value: %d \n\r", regulatedThrottle);
         
         // Generate  regulated PWM
         _roll->pulsewidth_us(    channels[ROLL]);