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);
00048     cf.setConsoleCallback(onConsoleData);
00049     // cf.logReset();
00050     // cf.requestLogToc();
00051 
00052     // std::unique_ptr<LogBlock<struct log> > logBlock;
00053     // std::function<void(uint32_t, struct log*)> cb = std::bind(&onLogData, std::placeholders::_1, std::placeholders::_2);
00054 
00055     // logBlock.reset(new LogBlock<struct log>(
00056     //   &cf,{
00057     //     {"acc", "x"},
00058     //     {"acc", "y"},
00059     //     {"acc", "z"},
00060     //     {"gyro", "x"},
00061     //     {"gyro", "y"},
00062     //     {"gyro", "z"}
00063     //   }, cb));
00064 
00065     // std::cout << "t,accx,accy,accz,gyrox,gyroy,gyroz" << std::endl;
00066 
00067     // logBlock->start(1); // 10ms
00068 
00069     while (true) {
00070       cf.sendPing();
00071       std::this_thread::sleep_for(std::chrono::milliseconds(10));
00072     }
00073 
00074     return 0;
00075   }
00076   catch(std::exception& e)
00077   {
00078     std::cerr << e.what() << std::endl;
00079     return 1;
00080   }
00081 }


crazyflie_tools
Author(s): Wolfgang Hoenig
autogenerated on Sun Oct 8 2017 02:48:04