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-27
Revision:
11:002927b2675d
Parent:
9:86a5af9935b1
Child:
12:18b31682dfe9
Child:
25:69190c222dbf

File content as of revision 11:002927b2675d:

#include "mbed.h"
#include "rtos.h"
#include "hardware.h"
#include "Server.h"
#include "PpmRegen.h"
#include "distanceRegulation.h"
#include "hcsr04.h"
#include "PID.h"
#include "ConfigFile.h"

//TEMP


//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");
}