![](/media/cache/profiles/8158fa3e4de806e614f7ff02e7b22fde.jpg.50x50_q85.png)
New version of quadcopter software written to OO principles
Dependencies: mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS
Diff: main.cpp
- Revision:
- 2:969dfa4f2436
- Parent:
- 0:c6a85bb2a827
--- a/main.cpp Wed Mar 04 18:53:43 2015 +0000 +++ b/main.cpp Wed Apr 01 11:19:21 2015 +0000 @@ -7,69 +7,53 @@ #include "Rc.h" #include "FlightController.h" #include "NavigationController.h" +#include "ConfigFileWrapper.h" +//Debug serial MODSERIAL _debug(USBTX, USBRX); -//Wireless Serial -MODSERIAL _base(p9, p10); - -//GPS Serial -//MODSERIAL _gps(p13, p14); - -//Onboard LED's -//DigitalOut _led1(LED1); -//DigitalOut _led2(LED2); -//DigitalOut _led3(LED3); -//DigitalOut _led4(LED4); - -//MaxBotix Ping sensor -//Timer _maxBotixTimer; -//Sonar _maxBotixSensor(p15, _maxBotixTimer); - -//Lidar -//LidarLite _lidar(p28, p27); - -//Unused analog pins +//Unused analog pins, set to DigitalOut to remove noise. DigitalOut _spare1(p16); DigitalOut _spare2(p17); DigitalOut _spare3(p18); DigitalOut _spare4(p19); - -//Classes -Status _status; -//Sensors *_sensors(_status, p13, p14, p15, p28, p27); -//BaseStation *_baseStation(p9, p10); -Rc _rc; -FlightController _flightController; -//NavigationController *_navigationController; - + int main() { - _base.baud(115200); + _debug.baud(115200); DEBUG("\r\n"); DEBUG("********************************************************************************\r\n"); DEBUG("Starting Setup\r\n"); DEBUG("********************************************************************************\r\n"); - //Set Status - _status.initialise(); - - //Initalise Base Station - - //Initialise RC - _rc.initialise(_status, p8); + ConfigFileWrapper _configFileWrapper = ConfigFileWrapper(); // No update + Thread::wait(100); + Status _status = Status(); // 10 Hz called from main + Thread::wait(100); + Sensors _sensors = Sensors(_status, _configFileWrapper, p13, p14, p28, p27, p15); // 50Hz called from navigation controller + Thread::wait(100); + Rc _rc = Rc(_status, p8); // 50Hz called from navigation controller + Thread::wait(100); + NavigationController _navigationController = NavigationController(_status, _sensors, _rc, _configFileWrapper); // 50Hz internal thread + Thread::wait(100); + FlightController _flightController = FlightController(_status, _sensors, _navigationController, _configFileWrapper, p21, p22, p23, p24); // 500Hz internal thread + Thread::wait(100); + BaseStation _baseStation = BaseStation(_status, _rc, _sensors, _navigationController, _flightController, _configFileWrapper, p9, p10); // 5Hz internal thread + Thread::wait(100); - //Initialise Sensors - - //Initialise Navigation - - //Initialise Flight Controller - _flightController.initialise(_status, _sensors, _navigationController, p21, p22, p23, p24); - - + //Thread::wait(10000); DEBUG("********************************************************************************\r\n"); DEBUG("Finished Setup\r\n"); DEBUG("********************************************************************************\r\n"); + + _status.setInitialised(true); + + osThreadSetPriority(osThreadGetId(), osPriorityNormal); + while(true) + { + _status.update(); + Thread::wait(100); + } }