listLogVariables.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 #include <boost/program_options.hpp>
00004 #include <crazyflie_cpp/Crazyflie.h>
00005 
00006 int main(int argc, char **argv)
00007 {
00008 
00009   std::string uri;
00010   std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
00011 
00012   namespace po = boost::program_options;
00013 
00014   po::options_description desc("Allowed options");
00015   desc.add_options()
00016     ("help", "produce help message")
00017     ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
00018   ;
00019 
00020   try
00021   {
00022     po::variables_map vm;
00023     po::store(po::parse_command_line(argc, argv, desc), vm);
00024     po::notify(vm);
00025 
00026     if (vm.count("help")) {
00027       std::cout << desc << "\n";
00028       return 0;
00029     }
00030   }
00031   catch(po::error& e)
00032   {
00033     std::cerr << e.what() << std::endl << std::endl;
00034     std::cerr << desc << std::endl;
00035     return 1;
00036   }
00037 
00038   try
00039   {
00040     Crazyflie cf(uri);
00041     cf.requestLogToc();
00042 
00043      std::for_each(cf.logVariablesBegin(), cf.logVariablesEnd(),
00044       [](const Crazyflie::LogTocEntry& entry)
00045       {
00046         std::cout << entry.group << "." << entry.name << " (";
00047         switch (entry.type) {
00048         case Crazyflie::LogTypeUint8:
00049           std::cout << "uint8";
00050           break;
00051         case Crazyflie::LogTypeInt8:
00052           std::cout << "int8";
00053           break;
00054         case Crazyflie::LogTypeUint16:
00055           std::cout << "uint16";
00056           break;
00057         case Crazyflie::LogTypeInt16:
00058           std::cout << "int16";
00059           break;
00060         case Crazyflie::LogTypeUint32:
00061           std::cout << "uint32";
00062           break;
00063         case Crazyflie::LogTypeInt32:
00064           std::cout << "int32";
00065           break;
00066         case Crazyflie::LogTypeFloat:
00067           std::cout << "float";
00068           break;
00069         case Crazyflie::LogTypeFP16:
00070           std::cout << "fp16";
00071           break;
00072         }
00073         std::cout << ")";
00074         std::cout << std::endl;
00075       }
00076     );
00077 
00078     return 0;
00079   }
00080   catch(std::exception& e)
00081   {
00082     std::cerr << e.what() << std::endl;
00083     return 1;
00084   }
00085 }


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