console.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <chrono>
3 #include <thread>
4 
5 #include <boost/program_options.hpp>
6 #include <crazyflie_cpp/Crazyflie.h>
7 
8 void onConsoleData(const char* msg)
9 {
10  std::cout << msg;
11 }
12 
13 int main(int argc, char **argv)
14 {
15 
16  std::string uri;
17  std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
18 
19  namespace po = boost::program_options;
20 
21  po::options_description desc("Allowed options");
22  desc.add_options()
23  ("help", "produce help message")
24  ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
25  ;
26 
27  try
28  {
29  po::variables_map vm;
30  po::store(po::parse_command_line(argc, argv, desc), vm);
31  po::notify(vm);
32 
33  if (vm.count("help")) {
34  std::cout << desc << "\n";
35  return 0;
36  }
37  }
38  catch(po::error& e)
39  {
40  std::cerr << e.what() << std::endl << std::endl;
41  std::cerr << desc << std::endl;
42  return 1;
43  }
44 
45  try
46  {
48  // cf.logReset();
49  // cf.requestLogToc();
50 
51  // std::unique_ptr<LogBlock<struct log> > logBlock;
52  // std::function<void(uint32_t, struct log*)> cb = std::bind(&onLogData, std::placeholders::_1, std::placeholders::_2);
53 
54  // logBlock.reset(new LogBlock<struct log>(
55  // &cf,{
56  // {"acc", "x"},
57  // {"acc", "y"},
58  // {"acc", "z"},
59  // {"gyro", "x"},
60  // {"gyro", "y"},
61  // {"gyro", "z"}
62  // }, cb));
63 
64  // std::cout << "t,accx,accy,accz,gyrox,gyroy,gyroz" << std::endl;
65 
66  // logBlock->start(1); // 10ms
67 
68  while (true) {
69  cf.sendPing();
70  std::this_thread::sleep_for(std::chrono::milliseconds(10));
71  }
72 
73  return 0;
74  }
75  catch(std::exception& e)
76  {
77  std::cerr << e.what() << std::endl;
78  return 1;
79  }
80 }
uint8_t error
void sendPing()
Definition: Crazyflie.cpp:264
int main(int argc, char **argv)
Definition: console.cpp:13
void onConsoleData(const char *msg)
Definition: console.cpp:8
Logger EmptyLogger
Definition: Crazyflie.cpp:29


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