23 #include <utils/system/argparser.h>
25 #include "refbox_state_sender.h"
26 #include "refbox_state_writer.h"
42 using namespace fawkes;
45 print_usage(
const char *program_name)
47 printf(
"Usage: %s [-d] -l league -t team -g goal_color [hosts]\n"
48 " -d Turn on debug mode (prints to stdout)\n"
49 " -b Use blackboard writer instead of world info sender\n"
50 " -l league Define league, may be one of\n"
51 " midsize, msl2007, msl2008, msl2010, spl\n"
52 " -u Don't use multicast in msl2010\n"
53 " -t team Our team, either cyan or magenta\n"
54 " -g goal_color Our goal color, either blue or yellow\n"
55 " -p port UDP port to send to (default 2806)\n"
56 " -m addr Multicast address to send to (default 224.16.0.1)\n"
57 " -k key Encryption key (default AllemaniACs)\n"
58 " -i iv Encryption initialization vector (default AllemaniACs)\n"
59 " hosts The hosts of the robots; only when -b is used\n",
68 main(
int argc,
char **argv)
72 if ( argp.has_arg(
"h") ) {
77 if ( ! argp.has_arg(
"l") ) {
78 printf(
"You must give a league name.\n\n");
83 if ( ! argp.has_arg(
"t") ) {
84 printf(
"You must give our team color.\n\n");
89 if ( ! argp.has_arg(
"g") ) {
90 printf(
"You must give our goal color.\n\n");
97 const char *addr =
"224.16.0.1";
98 const char *key =
"AllemaniACs";
99 const char *iv =
"AllemaniACs";
100 unsigned short int port = 2806;
102 if ( strcmp(argp.arg(
"t"),
"cyan") == 0 ) {
104 }
else if ( strcmp(argp.arg(
"t"),
"magenta") == 0 ) {
107 printf(
"Invalid team '%s', must be one of 'cyan' and 'magenta'.\n\n", argp.arg(
"t"));
108 print_usage(argv[0]);
112 if ( strcmp(argp.arg(
"g"),
"blue") == 0 ) {
114 }
else if ( strcmp(argp.arg(
"g"),
"yellow") == 0 ) {
117 printf(
"Invalid goal '%s', must be one of 'blue' and 'yellow'.\n\n", argp.arg(
"g"));
118 print_usage(argv[0]);
122 if ( argp.has_arg(
"m") ) {
123 addr = argp.arg(
"m");
126 if ( argp.has_arg(
"k") ) {
130 if ( argp.has_arg(
"i") ) {
134 if ( argp.has_arg(
"p") ) {
135 port = atoi(argp.arg(
"p"));
138 printf(
"Sending to: %s:%u\n"
139 "Key: %s IV: %s\n", addr, port, key, iv);
142 if ( argp.has_arg(
"b") ) {
143 std::vector<const char*> items = argp.items();
144 std::vector<std::string> hosts(items.begin(), items.end());
149 rss->set_team_goal(our_team, our_goal);
151 printf(
"League: %s\n", argp.arg(
"l"));
152 if ( strcmp(argp.arg(
"l"),
"msl2007") == 0 || strcmp(argp.arg(
"l"),
"midsize") == 0 ) {
156 }
else if ( strcmp(argp.arg(
"l"),
"msl2008") == 0 ) {
161 }
else if ( strcmp(argp.arg(
"l"),
"msl2010") == 0 ) {
162 if ( argp.has_arg(
"u") ) {
174 }
else if ( strcmp(argp.arg(
"l"),
"spl") == 0 ) {
178 printf(
"Invalid league name given.\n\n");
179 print_usage(argv[0]);