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:
38:801fee0330e2
Parent:
36:ed8b7b7b6cfa
Child:
39:93d8aa47f4ce
--- a/distanceRegulation.h	Fri Mar 23 14:29:09 2018 +0000
+++ b/distanceRegulation.h	Fri Mar 23 14:45:52 2018 +0000
@@ -28,6 +28,7 @@
     int distance2=0;
     float groundDistancePIDValue;
     int regulatedThrottle;
+    int regulatedRoll = 0;
     
     //PID SETUP
     if(_configChanges){
@@ -93,8 +94,14 @@
         //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]);
+        // goAhead for ROLL
+        if(_goAhead == true){
+            _roll->pulsewidth_us(    REGULATED_ROLL);
+        }
+        else{
+            _roll->pulsewidth_us(    channels[ROLL]);
+        }
+        
         _pitch->pulsewidth_us(   channels[PITCH]);
         _yaw->pulsewidth_us(     channels[YAW]);
         _throttle->pulsewidth_us(regulatedThrottle);