args.h
Go to the documentation of this file.
1 #include <libplayerc++/playerc++.h>
2 #include <iostream>
3 #include <unistd.h>
4 
5 std::string gHostname(PlayerCc::PLAYER_HOSTNAME);
6 uint gPort(PlayerCc::PLAYER_PORTNUM);
7 uint gIndex(0);
8 uint gDebug(0);
9 uint gFrequency(10); // Hz
10 uint gDataMode(PLAYER_DATAMODE_PUSH);
11 bool gUseLaser(false);
12 uint gPop(1);
13 
14 void print_usage(int argc, char** argv);
15 
16 int parse_args(int argc, char** argv)
17 {
18  // set the flags
19  const char* optflags = "h:p:i:n:d:u:lm:";
20  int ch;
21 
22  // use getopt to parse the flags
23  while(-1 != (ch = getopt(argc, argv, optflags)))
24  {
25  switch(ch)
26  {
27  // case values must match long_options
28  case 'h': // hostname
29  gHostname = optarg;
30  break;
31  case 'n': // number of robots
32  gPop = atoi(optarg);
33  break;
34  case 'p': // port
35  gPort = atoi(optarg);
36  break;
37  case 'i': // index
38  gIndex = atoi(optarg);
39  break;
40  case 'd': // debug
41  gDebug = atoi(optarg);
42  break;
43  case 'u': // update rate
44  gFrequency = atoi(optarg);
45  break;
46  case 'm': // datamode
47  gDataMode = atoi(optarg);
48  break;
49  case 'l': // datamode
50  gUseLaser = true;
51  break;
52  case '?': // help
53  case ':':
54  default: // unknown
55  print_usage(argc, argv);
56  exit (-1);
57  }
58  }
59 
60  return (0);
61 } // end parse_args
62 
63 void print_usage(int argc, char** argv)
64 {
65  using namespace std;
66  cerr << "USAGE: " << *argv << " [options]" << endl << endl;
67  cerr << "Where [options] can be:" << endl;
68  cerr << " -h <hostname> : hostname to connect to (default: "
69  << PlayerCc::PLAYER_HOSTNAME << ")" << endl;
70  cerr << " -p <port> : port where Player will listen (default: "
71  << PlayerCc::PLAYER_PORTNUM << ")" << endl;
72  cerr << " -i <index> : device index (default: 0)"
73  << endl;
74  cerr << " -n <number of robots> : population size (default: "
75  << 1 << ")" << endl;
76  cerr << " -d <level> : debug message level (0 = none -- 9 = all)"
77  << endl;
78  cerr << " -u <rate> : set server update rate to <rate> in Hz"
79  << endl;
80  cerr << " -l : Use laser if applicable"
81  << endl;
82  cerr << " -m <datamode> : set server data delivery mode"
83  << endl;
84  cerr << " PLAYER_DATAMODE_PUSH = "
85  << PLAYER_DATAMODE_PUSH << endl;
86  cerr << " PLAYER_DATAMODE_PULL = "
87  << PLAYER_DATAMODE_PULL << endl;
88 /* cerr << " PLAYER_DATAMODE_PUSH_ALL = "
89  << PLAYER_DATAMODE_PUSH_ALL << endl;
90  cerr << " PLAYER_DATAMODE_PULL_ALL = "
91  << PLAYER_DATAMODE_PULL_ALL << endl;
92  cerr << " PLAYER_DATAMODE_PUSH_NEW = "
93  << PLAYER_DATAMODE_PUSH_NEW << endl;
94  cerr << " PLAYER_DATAMODE_PULL_NEW = "
95  << PLAYER_DATAMODE_PULL_NEW << endl;
96  cerr << " PLAYER_DATAMODE_ASYNC = "
97  << PLAYER_DATAMODE_ASYNC << endl;*/
98 } // end print_usage
int parse_args(int argc, char **argv)
Definition: args.h:16
uint gFrequency(10)
bool gUseLaser(false)
uint gPort(PlayerCc::PLAYER_PORTNUM)
uint gDataMode(PLAYER_DATAMODE_PUSH)
uint gPop(1)
static int argc
void print_usage(int argc, char **argv)
Definition: args.h:63
static char * argv
uint gDebug(0)
std::string gHostname(PlayerCc::PLAYER_HOSTNAME)
uint gIndex(0)


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 Mon Jun 10 2019 15:06:09