int main(int argc, char *argv[]) { 
  
  int i,j;
  IPC_RETURN_TYPE ret;

  if (argc < 3 || carmen_find_param("-help") || 
      carmen_find_param("--help") || carmen_find_param("-h")) {

    fprintf(stderr,"\n%s is used to connect serveral carmen-simulators\n", argv[0]);
    fprintf(stderr,"so that the individual robots can see each other.\n\n");
    fprintf(stderr,"Usage: %s [centralhost of 1st simulator] [...] [n-th simulator]\n", argv[0]);
    fprintf(stderr,"(e.g. %s localhost localhost:1382 locahost:1383)\n", argv[0]);
    exit(0);
  }

  for (i=1; i<argc; i++) {
    for (j=1; j<argc; j++) {
      if (i != j) {
	ret = IPC_connectModule(argv[0], argv[j]); 
	
	if (ret != IPC_OK) {
	  carmen_die("Error: could not connect to central on: %s\n", argv[j]);
	}
	
	carmen_simulator_connect_robots(argv[i]); 
      }
    }
  }
  fprintf(stderr,"simulators are now successly connected!\n");
  return 0; 
}
Ejemplo n.º 2
0
char *
carmen_process_param_directory(char *lvalue, carmen_usage_func usage)
{
  struct stat buf;
  char *arg;

  if (carmen_find_param(lvalue) > 0)
    {
      if (carmen_find_param_pair(lvalue) == 0)
	{
	  usage("Option '%s' requires argument: should be on/off.\n", lvalue);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      arg = carmen_param_pair(lvalue);
      if (stat(arg, &buf) < 0)
	{
	  usage("Option '%s', file %s not available: %s\n", lvalue, arg, strerror(errno));
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      if (!S_ISDIR(buf.st_mode))
	{
	  usage("Option '%s' requires directorny name. %s is not a directory.\n", lvalue, arg);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      return arg;
    }
  return NULL;
}
Ejemplo n.º 3
0
double
carmen_process_param_double(char *lvalue, carmen_usage_func usage, double *return_value)
{
  char *endptr;
  char *arg;

  if (carmen_find_param(lvalue) > 0)
    {
      if (carmen_find_param_pair(lvalue) == 0)
	{
	  if(usage != NULL)
	    usage("Option '%s' requires argument: should be a double.\n",
		  lvalue);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      arg = carmen_param_pair(lvalue);
      *return_value = (double)strtod(arg, &endptr);
      if (endptr == arg)
	{
	  if(usage != NULL)
	    usage("Bad argument to %s: %s, should be a double.\n",
		  lvalue, arg);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      return 1;
    }
  return 0;
}
Ejemplo n.º 4
0
int
carmen_process_param_int(char *lvalue, carmen_usage_func usage, int *return_value)
{
  char *endptr;
  char *arg;

  if(carmen_find_param(lvalue) > 0)
    {
      if (carmen_find_param_pair(lvalue) == 0)
	{
	  if(usage != NULL)
	    usage("Option '%s' requires argument: should be an integer.\n",
		  lvalue);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      arg = carmen_param_pair(lvalue);
      *return_value = strtol(arg, &endptr, 0);
      if (endptr == arg)
	{
	  if(usage != NULL)
	    usage("Bad argument to int: %s, should be an integer.\n", arg);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      return 1;
    }
  return 0;
}
Ejemplo n.º 5
0
int
carmen_find_param_pair(const char *lvalue)
{
  if(carmen_find_param(lvalue) &&
     carmen_param_pair(lvalue) != NULL)
    return 1;
  else
    return 0;
}
Ejemplo n.º 6
0
char *
carmen_process_param_string(char *lvalue, carmen_usage_func usage)
{
  char *arg;

  if (carmen_find_param(lvalue) > 0)
    {
      if (carmen_find_param_pair(lvalue) == 0)
	{
	  usage("Option '%s' requires argument: should be a string.\n", lvalue);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      arg = carmen_param_pair(lvalue);
      return arg;
    }
  return NULL;
}
Ejemplo n.º 7
0
int
carmen_process_param_onoff(char *lvalue, carmen_usage_func usage, int *return_value)
{
  char *arg;

  if (carmen_find_param(lvalue) > 0)
    {
      if (carmen_find_param_pair(lvalue) == 0)
	{
	  usage("Option '%s' requires argument: should be on/off.\n", lvalue);
	  // In case the user provided a usage that doesn't exit.
	  exit(-1);
	}
      arg = carmen_param_pair(lvalue);
      if (strcmp(arg, "on") == 0)
	*return_value = 1;
      else if (strcmp(arg, "off") == 0)
	*return_value = 0;
      else
	usage("Bad argument to %s: %s, should be on/off.\n", lvalue, arg);
      return 1;
    }
  return 0;
}