getParam.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include <boost/program_options.hpp>
4 #include <crazyflie_cpp/Crazyflie.h>
5 
6 int main(int argc, char **argv)
7 {
8 
9  std::string uri;
10  std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
11 
12  namespace po = boost::program_options;
13 
14  po::options_description desc("Allowed options");
15  desc.add_options()
16  ("help", "produce help message")
17  ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
18  ;
19 
20  try
21  {
22  po::variables_map vm;
23  po::store(po::parse_command_line(argc, argv, desc), vm);
24  po::notify(vm);
25 
26  if (vm.count("help")) {
27  std::cout << desc << "\n";
28  return 0;
29  }
30  }
31  catch(po::error& e)
32  {
33  std::cerr << e.what() << std::endl << std::endl;
34  std::cerr << desc << std::endl;
35  return 1;
36  }
37 
38  try
39  {
40  Crazyflie cf(uri);
41  cf.requestParamToc();
42 
43  std::for_each(cf.paramsBegin(), cf.paramsEnd(),
44  [](const Crazyflie::ParamTocEntry& entry)
45  {
46  std::cout << entry.group << "." << entry.name << " (";
47  switch (entry.type) {
49  std::cout << "uint8";
50  break;
52  std::cout << "int8";
53  break;
55  std::cout << "uint16";
56  break;
58  std::cout << "int16";
59  break;
61  std::cout << "uint32";
62  break;
64  std::cout << "int32";
65  break;
67  std::cout << "float";
68  break;
69  }
70  if (entry.readonly) {
71  std::cout << ", readonly";
72  }
73  std::cout << ")";
74  std::cout << std::endl;
75  }
76  );
77 
78  return 0;
79  }
80  catch(std::exception& e)
81  {
82  std::cerr << e.what() << std::endl;
83  return 1;
84  }
85 }
uint8_t error
void requestParamToc(bool forceNoCache=false)
Definition: Crazyflie.cpp:696
std::vector< ParamTocEntry >::const_iterator paramsBegin() const
std::vector< ParamTocEntry >::const_iterator paramsEnd() const
int main(int argc, char **argv)
Definition: getParam.cpp:6


crazyflie_tools
Author(s): Wolfgang Hoenig
autogenerated on Mon Sep 28 2020 03:40:15