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  switch (ch) {
25  // case values must match long_options
26  case 'h': // hostname
27  gHostname = optarg;
28  break;
29  case 'n': // number of robots
30  gPop = atoi(optarg);
31  break;
32  case 'p': // port
33  gPort = atoi(optarg);
34  break;
35  case 'i': // index
36  gIndex = atoi(optarg);
37  break;
38  case 'd': // debug
39  gDebug = atoi(optarg);
40  break;
41  case 'u': // update rate
42  gFrequency = atoi(optarg);
43  break;
44  case 'm': // datamode
45  gDataMode = atoi(optarg);
46  break;
47  case 'l': // datamode
48  gUseLaser = true;
49  break;
50  case '?': // help
51  case ':':
52  default: // unknown
53  print_usage(argc, argv);
54  exit(-1);
55  }
56  }
57 
58  return (0);
59 } // end parse_args
60 
61 void print_usage(int argc, char **argv)
62 {
63  using namespace std;
64  cerr << "USAGE: " << *argv << " [options]" << endl << endl;
65  cerr << "Where [options] can be:" << endl;
66  cerr << " -h <hostname> : hostname to connect to (default: " << PlayerCc::PLAYER_HOSTNAME << ")"
67  << endl;
68  cerr << " -p <port> : port where Player will listen (default: " << PlayerCc::PLAYER_PORTNUM
69  << ")" << endl;
70  cerr << " -i <index> : device index (default: 0)" << endl;
71  cerr << " -n <number of robots> : population size (default: " << 1 << ")" << endl;
72  cerr << " -d <level> : debug message level (0 = none -- 9 = all)" << endl;
73  cerr << " -u <rate> : set server update rate to <rate> in Hz" << endl;
74  cerr << " -l : Use laser if applicable" << endl;
75  cerr << " -m <datamode> : set server data delivery mode" << endl;
76  cerr << " PLAYER_DATAMODE_PUSH = " << PLAYER_DATAMODE_PUSH << endl;
77  cerr << " PLAYER_DATAMODE_PULL = " << PLAYER_DATAMODE_PULL << endl;
78  /* cerr << " PLAYER_DATAMODE_PUSH_ALL = "
79  << PLAYER_DATAMODE_PUSH_ALL << endl;
80  cerr << " PLAYER_DATAMODE_PULL_ALL = "
81  << PLAYER_DATAMODE_PULL_ALL << endl;
82  cerr << " PLAYER_DATAMODE_PUSH_NEW = "
83  << PLAYER_DATAMODE_PUSH_NEW << endl;
84  cerr << " PLAYER_DATAMODE_PULL_NEW = "
85  << PLAYER_DATAMODE_PULL_NEW << endl;
86  cerr << " PLAYER_DATAMODE_ASYNC = "
87  << PLAYER_DATAMODE_ASYNC << endl;*/
88 } // 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:61
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 Feb 28 2022 23:48:55