Go to the documentation of this file.00001
00017 #include <FlightController.hpp>
00018
00019 #include <iostream>
00020 #include <chrono>
00021
00022
00023 int main(int argc, char *argv[]) {
00024 const std::string device = (argc>1) ? std::string(argv[1]) : "/dev/ttyUSB0";
00025 const uint baudrate = (argc>2) ? std::stoul(argv[2]) : 115200;
00026
00027 std::chrono::high_resolution_clock::time_point start, end;
00028 bool feature_changed = false;
00029 start:
00030 fcu::FlightController fcu(device, baudrate);
00031
00032
00033
00034 start = std::chrono::high_resolution_clock::now();
00035 fcu.initialise();
00036 end = std::chrono::high_resolution_clock::now();
00037 std::cout<<"ready after: "<<std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count()<<" ms"<<std::endl;
00038
00039
00040 if(fcu.isFirmwareCleanflight()) {
00041 if(fcu.enableRxMSP()==1) {
00042 std::cout<<"RX_MSP enabled, restart"<<std::endl;
00043 feature_changed = true;
00044 goto start;
00045 }
00046
00047 if(feature_changed) {
00048
00049 std::this_thread::sleep_for(std::chrono::seconds(5));
00050 }
00051 }
00052
00053 std::cout<<"Armed? "<<fcu.isArmed()<<std::endl;
00054
00055
00056 std::cout<<"Arming..."<<std::endl;
00057 start = std::chrono::high_resolution_clock::now();
00058 fcu.arm_block();
00059 end = std::chrono::high_resolution_clock::now();
00060
00061 if(fcu.isArmed()) {
00062 std::cout<<"armed after: "<<std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count()<<" ms"<<std::endl;
00063 }
00064
00065
00066 std::cout<<"Disarming..."<<std::endl;
00067 start = std::chrono::high_resolution_clock::now();
00068 fcu.disarm_block();
00069 end = std::chrono::high_resolution_clock::now();
00070
00071 if(!fcu.isArmed()) {
00072 std::cout<<"disarmed after: "<<std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count()<<" ms"<<std::endl;
00073 }
00074 }