New version of quadcopter software written to OO principles
Dependencies: mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS
main.cpp@4:9ffbf9101992, 2015-05-08 (annotated)
- Committer:
- joe4465
- Date:
- Fri May 08 09:07:38 2015 +0000
- Revision:
- 4:9ffbf9101992
- Parent:
- 2:969dfa4f2436
End of FYP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joe4465 | 0:c6a85bb2a827 | 1 | #include "mbed.h" |
joe4465 | 0:c6a85bb2a827 | 2 | #include "Global.h" |
joe4465 | 0:c6a85bb2a827 | 3 | #include "MODSERIAL.h" |
joe4465 | 0:c6a85bb2a827 | 4 | #include "Status.h" |
joe4465 | 0:c6a85bb2a827 | 5 | #include "Sensors.h" |
joe4465 | 0:c6a85bb2a827 | 6 | #include "BaseStation.h" |
joe4465 | 0:c6a85bb2a827 | 7 | #include "Rc.h" |
joe4465 | 0:c6a85bb2a827 | 8 | #include "FlightController.h" |
joe4465 | 0:c6a85bb2a827 | 9 | #include "NavigationController.h" |
joe4465 | 2:969dfa4f2436 | 10 | #include "ConfigFileWrapper.h" |
joe4465 | 0:c6a85bb2a827 | 11 | |
joe4465 | 2:969dfa4f2436 | 12 | //Debug serial |
joe4465 | 0:c6a85bb2a827 | 13 | MODSERIAL _debug(USBTX, USBRX); |
joe4465 | 0:c6a85bb2a827 | 14 | |
joe4465 | 2:969dfa4f2436 | 15 | //Unused analog pins, set to DigitalOut to remove noise. |
joe4465 | 0:c6a85bb2a827 | 16 | DigitalOut _spare1(p16); |
joe4465 | 0:c6a85bb2a827 | 17 | DigitalOut _spare2(p17); |
joe4465 | 0:c6a85bb2a827 | 18 | DigitalOut _spare3(p18); |
joe4465 | 0:c6a85bb2a827 | 19 | DigitalOut _spare4(p19); |
joe4465 | 2:969dfa4f2436 | 20 | |
joe4465 | 0:c6a85bb2a827 | 21 | int main() |
joe4465 | 0:c6a85bb2a827 | 22 | { |
joe4465 | 2:969dfa4f2436 | 23 | _debug.baud(115200); |
joe4465 | 0:c6a85bb2a827 | 24 | |
joe4465 | 0:c6a85bb2a827 | 25 | DEBUG("\r\n"); |
joe4465 | 0:c6a85bb2a827 | 26 | DEBUG("********************************************************************************\r\n"); |
joe4465 | 0:c6a85bb2a827 | 27 | DEBUG("Starting Setup\r\n"); |
joe4465 | 0:c6a85bb2a827 | 28 | DEBUG("********************************************************************************\r\n"); |
joe4465 | 0:c6a85bb2a827 | 29 | |
joe4465 | 2:969dfa4f2436 | 30 | ConfigFileWrapper _configFileWrapper = ConfigFileWrapper(); // No update |
joe4465 | 2:969dfa4f2436 | 31 | Thread::wait(100); |
joe4465 | 2:969dfa4f2436 | 32 | Status _status = Status(); // 10 Hz called from main |
joe4465 | 2:969dfa4f2436 | 33 | Thread::wait(100); |
joe4465 | 2:969dfa4f2436 | 34 | Sensors _sensors = Sensors(_status, _configFileWrapper, p13, p14, p28, p27, p15); // 50Hz called from navigation controller |
joe4465 | 2:969dfa4f2436 | 35 | Thread::wait(100); |
joe4465 | 2:969dfa4f2436 | 36 | Rc _rc = Rc(_status, p8); // 50Hz called from navigation controller |
joe4465 | 2:969dfa4f2436 | 37 | Thread::wait(100); |
joe4465 | 2:969dfa4f2436 | 38 | NavigationController _navigationController = NavigationController(_status, _sensors, _rc, _configFileWrapper); // 50Hz internal thread |
joe4465 | 2:969dfa4f2436 | 39 | Thread::wait(100); |
joe4465 | 2:969dfa4f2436 | 40 | FlightController _flightController = FlightController(_status, _sensors, _navigationController, _configFileWrapper, p21, p22, p23, p24); // 500Hz internal thread |
joe4465 | 2:969dfa4f2436 | 41 | Thread::wait(100); |
joe4465 | 2:969dfa4f2436 | 42 | BaseStation _baseStation = BaseStation(_status, _rc, _sensors, _navigationController, _flightController, _configFileWrapper, p9, p10); // 5Hz internal thread |
joe4465 | 2:969dfa4f2436 | 43 | Thread::wait(100); |
joe4465 | 0:c6a85bb2a827 | 44 | |
joe4465 | 2:969dfa4f2436 | 45 | //Thread::wait(10000); |
joe4465 | 0:c6a85bb2a827 | 46 | |
joe4465 | 0:c6a85bb2a827 | 47 | DEBUG("********************************************************************************\r\n"); |
joe4465 | 0:c6a85bb2a827 | 48 | DEBUG("Finished Setup\r\n"); |
joe4465 | 0:c6a85bb2a827 | 49 | DEBUG("********************************************************************************\r\n"); |
joe4465 | 2:969dfa4f2436 | 50 | |
joe4465 | 2:969dfa4f2436 | 51 | _status.setInitialised(true); |
joe4465 | 2:969dfa4f2436 | 52 | |
joe4465 | 2:969dfa4f2436 | 53 | osThreadSetPriority(osThreadGetId(), osPriorityNormal); |
joe4465 | 2:969dfa4f2436 | 54 | while(true) |
joe4465 | 2:969dfa4f2436 | 55 | { |
joe4465 | 2:969dfa4f2436 | 56 | _status.update(); |
joe4465 | 2:969dfa4f2436 | 57 | Thread::wait(100); |
joe4465 | 2:969dfa4f2436 | 58 | } |
joe4465 | 0:c6a85bb2a827 | 59 | } |