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
Diff: distanceRegulation.h
- Branch:
- DistanceRegulation
- Revision:
- 35:b09e19c855f6
- Parent:
- 34:5dca557e982f
- Child:
- 36:ed8b7b7b6cfa
--- a/distanceRegulation.h Sun Feb 25 18:32:13 2018 +0000 +++ b/distanceRegulation.h Sat Mar 03 15:38:10 2018 +0000 @@ -39,12 +39,17 @@ _groundDistance->setSetPoint(_groundSetPoint); } else{ + pc.printf("P %f \n\r", _P); + pc.printf("I %f \n\r", _I); + pc.printf("D %f \n\r", _D); + pc.printf("setpoint %f \n\r", _groundSetPoint); + pc.printf("bias %f \n\r", _bias); _groundDistance->resetError(); //pc.printf("PID tunings changed \n\r"); _groundDistance->setTunings(_P, _I, _D); _groundDistance->setSetPoint(_groundSetPoint); _groundDistance->setOutputLimits(_groundPidMinOutput, _groundPidMaxOutput); - _groundDistance->setBias(_bias); + //_groundDistance->setBias(_bias); } } @@ -59,15 +64,14 @@ distance1 = _sonic->getDistan1(); //distance2 = _sonic->getDistan2(); - //pc.printf("%d \n\r", distance1); + pc.printf("%d \n\r", distance1); //pc.printf("distance2: %d \n\r", distance2); _groundDistance->setProcessValue(distance1); groundDistancePIDValue = _groundDistance->compute(); - //groundDistancePIDValue += _bias; - + pc.printf("pid value %f \n\r", groundDistancePIDValue); //Update PWM values - regulatedThrottle = channels[THROTTLE] + groundDistancePIDValue; + regulatedThrottle = channels[THROTTLE] + _bias + groundDistancePIDValue; if(channels[AUX2] < 1500){ channels[THROTTLE] = 1010; } @@ -77,9 +81,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]);