4 #include <boost/program_options.hpp> 5 #include <crazyflie_cpp/Crazyflie.h> 7 void onLogCustom(uint32_t time_in_ms, std::vector<double>* values,
void* )
9 std::cout << time_in_ms;
10 for (
double v : *values) {
11 std::cout <<
"," << v;
13 std::cout << std::endl;
16 int main(
int argc,
char **argv)
20 std::string defaultUri(
"radio://0/80/2M/E7E7E7E7E7");
21 std::vector<std::string> vars;
24 namespace po = boost::program_options;
26 po::options_description desc(
"Allowed options");
28 (
"help",
"produce help message")
29 (
"var",
po::value<std::vector<std::string>>(&vars)->multitoken(),
"variable names to log")
30 (
"period", po::value<uint32_t>(&period)->default_value(10),
"sampling period in ms")
31 (
"uri", po::value<std::string>(&uri)->default_value(defaultUri),
"unique ressource identifier")
37 po::store(po::parse_command_line(argc, argv, desc), vm);
40 if (vm.count(
"help")) {
41 std::cout << desc <<
"\n";
47 std::cerr << e.what() << std::endl << std::endl;
48 std::cerr << desc << std::endl;
57 std::function<void(uint32_t, std::vector<double>*,
void*)> cb = std::bind(&
onLogCustom, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
59 logBlock.
start(period / 10);
63 std::this_thread::sleep_for(std::chrono::milliseconds(10));
66 catch(std::exception& e)
68 std::cerr << e.what() << std::endl;
void requestLogToc(bool forceNoCache=false)
void onLogCustom(uint32_t time_in_ms, std::vector< double > *values, void *)
void start(uint8_t period)
int main(int argc, char **argv)