console.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <chrono>
00003 #include <thread>
00004 
00005 #include <boost/program_options.hpp>
00006 #include <crazyflie_cpp/Crazyflie.h>
00007 
00008 void onConsoleData(const char* msg)
00009 {
00010   std::cout << msg;
00011 }
00012 
00013 int main(int argc, char **argv)
00014 {
00015 
00016   std::string uri;
00017   std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
00018 
00019   namespace po = boost::program_options;
00020 
00021   po::options_description desc("Allowed options");
00022   desc.add_options()
00023     ("help", "produce help message")
00024     ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
00025   ;
00026 
00027   try
00028   {
00029     po::variables_map vm;
00030     po::store(po::parse_command_line(argc, argv, desc), vm);
00031     po::notify(vm);
00032 
00033     if (vm.count("help")) {
00034       std::cout << desc << "\n";
00035       return 0;
00036     }
00037   }
00038   catch(po::error& e)
00039   {
00040     std::cerr << e.what() << std::endl << std::endl;
00041     std::cerr << desc << std::endl;
00042     return 1;
00043   }
00044 
00045   try
00046   {
00047     Crazyflie cf(uri, EmptyLogger, onConsoleData);
00048     // cf.logReset();
00049     // cf.requestLogToc();
00050 
00051     // std::unique_ptr<LogBlock<struct log> > logBlock;
00052     // std::function<void(uint32_t, struct log*)> cb = std::bind(&onLogData, std::placeholders::_1, std::placeholders::_2);
00053 
00054     // logBlock.reset(new LogBlock<struct log>(
00055     //   &cf,{
00056     //     {"acc", "x"},
00057     //     {"acc", "y"},
00058     //     {"acc", "z"},
00059     //     {"gyro", "x"},
00060     //     {"gyro", "y"},
00061     //     {"gyro", "z"}
00062     //   }, cb));
00063 
00064     // std::cout << "t,accx,accy,accz,gyrox,gyroy,gyroz" << std::endl;
00065 
00066     // logBlock->start(1); // 10ms
00067 
00068     while (true) {
00069       cf.sendPing();
00070       std::this_thread::sleep_for(std::chrono::milliseconds(10));
00071     }
00072 
00073     return 0;
00074   }
00075   catch(std::exception& e)
00076   {
00077     std::cerr << e.what() << std::endl;
00078     return 1;
00079   }
00080 }


crazyflie_tools
Author(s): Wolfgang Hoenig
autogenerated on Wed Jun 12 2019 19:20:48