listParams.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.requestParamToc();
00042 
00043      std::for_each(cf.paramsBegin(), cf.paramsEnd(),
00044       [](const Crazyflie::ParamTocEntry& entry)
00045       {
00046         std::cout << entry.group << "." << entry.name << " (";
00047         switch (entry.type) {
00048         case Crazyflie::ParamTypeUint8:
00049           std::cout << "uint8";
00050           break;
00051         case Crazyflie::ParamTypeInt8:
00052           std::cout << "int8";
00053           break;
00054         case Crazyflie::ParamTypeUint16:
00055           std::cout << "uint16";
00056           break;
00057         case Crazyflie::ParamTypeInt16:
00058           std::cout << "int16";
00059           break;
00060         case Crazyflie::ParamTypeUint32:
00061           std::cout << "uint32";
00062           break;
00063         case Crazyflie::ParamTypeInt32:
00064           std::cout << "int32";
00065           break;
00066         case Crazyflie::ParamTypeFloat:
00067           std::cout << "float";
00068           break;
00069         }
00070         if (entry.readonly) {
00071           std::cout << ", readonly";
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