New version of quadcopter software written to OO principles

Dependencies:   mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Global.h"
00003 #include "MODSERIAL.h"
00004 #include "Status.h"
00005 #include "Sensors.h"
00006 #include "BaseStation.h"
00007 #include "Rc.h"
00008 #include "FlightController.h"
00009 #include "NavigationController.h"
00010 #include "ConfigFileWrapper.h"
00011 
00012 //Debug serial
00013 MODSERIAL                           _debug(USBTX, USBRX);
00014 
00015 //Unused analog pins, set to DigitalOut to remove noise.
00016 DigitalOut                          _spare1(p16);
00017 DigitalOut                          _spare2(p17);
00018 DigitalOut                          _spare3(p18);
00019 DigitalOut                          _spare4(p19);
00020   
00021 int main()
00022 {
00023     _debug.baud(115200);
00024     
00025     DEBUG("\r\n");  
00026     DEBUG("********************************************************************************\r\n");
00027     DEBUG("Starting Setup\r\n");
00028     DEBUG("********************************************************************************\r\n");
00029     
00030     ConfigFileWrapper _configFileWrapper = ConfigFileWrapper(); // No update
00031     Thread::wait(100); 
00032     Status _status = Status(); // 10 Hz called from main
00033     Thread::wait(100); 
00034     Sensors _sensors = Sensors(_status, _configFileWrapper, p13, p14, p28, p27, p15); // 50Hz called from navigation controller
00035     Thread::wait(100); 
00036     Rc _rc = Rc(_status, p8); // 50Hz called from navigation controller
00037     Thread::wait(100); 
00038     NavigationController _navigationController = NavigationController(_status, _sensors, _rc, _configFileWrapper); // 50Hz internal thread
00039     Thread::wait(100); 
00040     FlightController _flightController = FlightController(_status, _sensors, _navigationController, _configFileWrapper, p21, p22, p23, p24); // 500Hz internal thread
00041     Thread::wait(100); 
00042     BaseStation _baseStation = BaseStation(_status, _rc, _sensors, _navigationController, _flightController, _configFileWrapper, p9, p10); // 5Hz internal thread
00043     Thread::wait(100); 
00044     
00045     //Thread::wait(10000); 
00046     
00047     DEBUG("********************************************************************************\r\n");
00048     DEBUG("Finished Setup\r\n");
00049     DEBUG("********************************************************************************\r\n"); 
00050     
00051     _status.setInitialised(true);
00052     
00053     osThreadSetPriority(osThreadGetId(), osPriorityNormal);
00054     while(true)
00055     {
00056         _status.update();
00057         Thread::wait(100);   
00058     }
00059 }