Go to the documentation of this file.00001 #include <iostream>
00002 #include <chrono>
00003 #include <thread>
00004
00005 #include <boost/program_options.hpp>
00006 #include <crazyflie_cpp/Crazyflie.h>
00007
00008 struct log {
00009 float pm_vbat;
00010
00011 } __attribute__((packed));
00012
00013 volatile bool g_done = false;
00014
00015 void onLogData(uint32_t time_in_ms, struct log* data)
00016 {
00017 std::cout << data->pm_vbat << std::endl;
00018 g_done = true;
00019 }
00020
00021 int main(int argc, char **argv)
00022 {
00023
00024 std::string uri;
00025 std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
00026
00027 namespace po = boost::program_options;
00028
00029 po::options_description desc("Allowed options");
00030 desc.add_options()
00031 ("help", "produce help message")
00032 ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
00033 ;
00034
00035 try
00036 {
00037 po::variables_map vm;
00038 po::store(po::parse_command_line(argc, argv, desc), vm);
00039 po::notify(vm);
00040
00041 if (vm.count("help")) {
00042 std::cout << desc << "\n";
00043 return 0;
00044 }
00045 }
00046 catch(po::error& e)
00047 {
00048 std::cerr << e.what() << std::endl << std::endl;
00049 std::cerr << desc << std::endl;
00050 return 1;
00051 }
00052
00053 try
00054 {
00055 Crazyflie cf(uri);
00056 std::cout << cf.vbat() << std::endl;
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 return 0;
00076 }
00077 catch(std::exception& e)
00078 {
00079 std::cerr << e.what() << std::endl;
00080 return 1;
00081 }
00082 }