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);
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
00019 const char* optflags = "h:p:i:n:d:u:lm:";
00020 int ch;
00021
00022
00023 while(-1 != (ch = getopt(argc, argv, optflags)))
00024 {
00025 switch(ch)
00026 {
00027
00028 case 'h':
00029 gHostname = optarg;
00030 break;
00031 case 'n':
00032 gPop = atoi(optarg);
00033 break;
00034 case 'p':
00035 gPort = atoi(optarg);
00036 break;
00037 case 'i':
00038 gIndex = atoi(optarg);
00039 break;
00040 case 'd':
00041 gDebug = atoi(optarg);
00042 break;
00043 case 'u':
00044 gFrequency = atoi(optarg);
00045 break;
00046 case 'm':
00047 gDataMode = atoi(optarg);
00048 break;
00049 case 'l':
00050 gUseLaser = true;
00051 break;
00052 case '?':
00053 case ':':
00054 default:
00055 print_usage(argc, argv);
00056 exit (-1);
00057 }
00058 }
00059
00060 return (0);
00061 }
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
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 }