3 #include <boost/program_options.hpp> 4 #include <crazyflie_cpp/Crazyflie.h> 6 int main(
int argc,
char **argv)
10 std::string defaultUri(
"radio://0/80/2M/E7E7E7E7E7");
11 std::string parameter;
13 namespace po = boost::program_options;
15 po::options_description desc(
"Allowed options");
17 (
"help",
"produce help message")
18 (
"parameter", po::value<std::string>(¶meter)->required(),
"parameter name")
19 (
"valUint8", po::value<int>(),
"value (uint8)")
20 (
"valInt8", po::value<int>(),
"value (int8)")
21 (
"valUint16", po::value<uint16_t>(),
"value (uint16)")
22 (
"valInt16", po::value<int16_t>(),
"value (int16)")
23 (
"valUint32", po::value<uint32_t>(),
"value (uint32)")
24 (
"valInt32", po::value<int32_t>(),
"value (int32)")
25 (
"valFloat", po::value<float>(),
"value (float)")
26 (
"uri", po::value<std::string>(&uri)->default_value(defaultUri),
"unique ressource identifier")
32 po::store(po::parse_command_line(argc, argv, desc), vm);
35 if (vm.count(
"help")) {
36 std::cout << desc <<
"\n";
42 std::cerr << e.what() << std::endl << std::endl;
43 std::cerr << desc << std::endl;
51 auto pos = parameter.find(
".");
52 const char*
group = parameter.substr(0, pos).c_str();
53 const char*
name = parameter.substr(pos+1).c_str();
55 if (vm.count(
"valUint8")) {
57 }
else if (vm.count(
"valInt8")) {
59 }
else if (vm.count(
"valUint16")) {
61 }
else if (vm.count(
"valInt16")) {
63 }
else if (vm.count(
"valUint32")) {
65 }
else if (vm.count(
"valInt32")) {
67 }
else if (vm.count(
"valFloat")) {
70 std::cerr <<
"Required to use one of the --val* arguments!" << std::endl << std::endl;
71 std::cerr << desc << std::endl;
77 catch(std::exception& e)
79 std::cerr << e.what() << std::endl;
int main(int argc, char **argv)
void setParamByName(const char *group, const char *name, const T &value)