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
main.cpp
- Committer:
- edy05
- Date:
- 2017-10-26
- Revision:
- 3:6c9f80f5e865
- Parent:
- 2:d172c9963f87
- Child:
- 6:c81abfa61bce
- Child:
- 8:b5128641d4cf
File content as of revision 3:6c9f80f5e865:
#include "mbed.h" #include "rtos.h" #include "hardware.h" #include "Server.h" #include "PpmRegen.h" #include "distanceRegulation.h" #include "hcsr04.h" #include "PID.h" //VARIABLES uint16_t ppmInChannelsValue[CHANNELS]; volatile uint16_t distance = 0; //FUNCTIONS void print_ppmIn(void); int main(){ // INITIALIZE CLASSES _ppmRegen = new PpmRegen(_interruptPort); _sonic = new HCSR04(p29, p30); _groundDistance = new PID(10, 0, 0, 2); // STARTING THREADS serverThread.start(serverRun); distanceThread.start(distanceRegulationThread); wait(1); while(1){ Thread::wait(osWaitForever); } } void print_ppmIn(){ _ppmRegen->getAllChannels(ppmInChannelsValue); for(uint8_t channel= 0; channel < CHANNELS; channel++){ pc.printf("PPM In Channel %d: %d \n\r", channel, ppmInChannelsValue[channel]); } pc.printf("\n\r"); }