args.h
Go to the documentation of this file.
00001 #include <libplayerc++/playerc++.h>
00002 #include <iostream>
00003 #include <unistd.h>
00004 
00005 std::string  gHostname(PlayerCc::PLAYER_HOSTNAME);
00006 uint         gPort(PlayerCc::PLAYER_PORTNUM);
00007 uint         gIndex(0);
00008 uint         gDebug(0);
00009 uint         gFrequency(10); // Hz
00010 uint         gDataMode(PLAYER_DATAMODE_PUSH);
00011 bool         gUseLaser(false);
00012 uint         gPop(1);
00013 
00014 void print_usage(int argc, char** argv);
00015 
00016 int parse_args(int argc, char** argv)
00017 {
00018   // set the flags
00019   const char* optflags = "h:p:i:n:d:u:lm:";
00020   int ch;
00021 
00022   // use getopt to parse the flags
00023   while(-1 != (ch = getopt(argc, argv, optflags)))
00024   {
00025     switch(ch)
00026     {
00027       // case values must match long_options
00028       case 'h': // hostname
00029           gHostname = optarg;
00030           break;
00031       case 'n': // number of robots
00032           gPop = atoi(optarg);
00033           break;
00034       case 'p': // port
00035           gPort = atoi(optarg);
00036           break;
00037       case 'i': // index
00038           gIndex = atoi(optarg);
00039           break;
00040       case 'd': // debug
00041           gDebug = atoi(optarg);
00042           break;
00043       case 'u': // update rate
00044           gFrequency = atoi(optarg);
00045           break;
00046       case 'm': // datamode
00047           gDataMode = atoi(optarg);
00048           break;
00049       case 'l': // datamode
00050           gUseLaser = true;
00051           break;
00052       case '?': // help
00053       case ':':
00054       default:  // unknown
00055         print_usage(argc, argv);
00056         exit (-1);
00057     }
00058   }
00059 
00060   return (0);
00061 } // end parse_args
00062 
00063 void print_usage(int argc, char** argv)
00064 {
00065   using namespace std;
00066   cerr << "USAGE:  " << *argv << " [options]" << endl << endl;
00067   cerr << "Where [options] can be:" << endl;
00068   cerr << "  -h <hostname>  : hostname to connect to (default: "
00069        << PlayerCc::PLAYER_HOSTNAME << ")" << endl;
00070   cerr << "  -p <port>      : port where Player will listen (default: "
00071        << PlayerCc::PLAYER_PORTNUM << ")" << endl;
00072   cerr << "  -i <index>     : device index (default: 0)"
00073        << endl;
00074   cerr << "  -n <number of robots>      : population size (default: "
00075        << 1 << ")" << endl;
00076   cerr << "  -d <level>     : debug message level (0 = none -- 9 = all)"
00077        << endl;
00078   cerr << "  -u <rate>      : set server update rate to <rate> in Hz"
00079        << endl;
00080   cerr << "  -l      : Use laser if applicable"
00081        << endl;
00082   cerr << "  -m <datamode>  : set server data delivery mode"
00083        << endl;
00084   cerr << "                      PLAYER_DATAMODE_PUSH = "
00085        << PLAYER_DATAMODE_PUSH << endl;
00086   cerr << "                      PLAYER_DATAMODE_PULL = "
00087        << PLAYER_DATAMODE_PULL << endl;
00088 /*  cerr << "                      PLAYER_DATAMODE_PUSH_ALL = "
00089        << PLAYER_DATAMODE_PUSH_ALL << endl;
00090   cerr << "                      PLAYER_DATAMODE_PULL_ALL = "
00091        << PLAYER_DATAMODE_PULL_ALL << endl;
00092   cerr << "                      PLAYER_DATAMODE_PUSH_NEW = "
00093        << PLAYER_DATAMODE_PUSH_NEW << endl;
00094   cerr << "                      PLAYER_DATAMODE_PULL_NEW = "
00095        << PLAYER_DATAMODE_PULL_NEW << endl;
00096   cerr << "                      PLAYER_DATAMODE_ASYNC    = "
00097        << PLAYER_DATAMODE_ASYNC << endl;*/
00098 } // end print_usage


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Thu Aug 27 2015 15:20:57