Esempio n. 1
0
int main(int argc, char **argv)
{
  Aria::init();
  ArGlobalFunctor2<ArServerClient *, ArNetPacket *> testCB(&testFunction);
  ArServerBase server;
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArNetPacket packet;

  server.addData("test", "some wierd test", &testCB, "none", "none");
  server.addData("test2", "another wierd test", &testCB, "none", "none");
  server.addData("test3", "yet another wierd test", &testCB, "none", "none");
  if (!server.open(7273))
  {
    printf("Could not open server port\n");
    exit(1);
  }
  server.runAsync();
  while (server.getRunningWithLock())
  {
    ArUtil::sleep(1000);
    server.broadcastPacketTcp(&packet, "test3");
  }
  Aria::shutdown();
  return 0;
}
int main(int argc, char **argv)
{
  Aria::init();
  ArServerBase server;
  
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArConfig *config;
  config = Aria::getConfig();

  ArRobotP3DX dx;
  //dx.writeFile("dx.txt");
  *Aria::getConfig() = dx;
  //Aria::getConfig()->writeFile("dxcopy.txt");

  if (!server.open(7272))
  {
    printf("Could not open server port\n");
    exit(1);
  }

  ArServerHandlerConfig configHandler(&server, Aria::getConfig());
  server.run();
  
  Aria::shutdown();

  return 0;
}
int main(int argc, char **argv)
{
  Aria::init();
  ArServerBase server;
  
  ArConfig *config;
  config = Aria::getConfig();
  std::string section;
  char joy[512];
  sprintf(joy, "Joy");
  section = "section1";
  config->addParam(ArConfigArg("int", new int, "fun int", 0), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("bool", new bool, "fun bool"), section.c_str(), ArPriority::IMPORTANT);
  config->addParam(ArConfigArg("string", joy, "fun string", sizeof(joy)), section.c_str(), ArPriority::TRIVIAL);
  section = "section8";
  config->addParam(ArConfigArg("int", new int, "fun int", 0), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("doubleFOUR", (double).4, "fun double", 0.0, 1.0), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("double three", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("double two", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("double one", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("bool", new bool, "fun bool"), section.c_str(), ArPriority::IMPORTANT);
  config->addParam(ArConfigArg("string", joy, "fun string", sizeof(joy)), section.c_str(), ArPriority::TRIVIAL);
  section = "some section";
  config->setSectionComment("some section", "this is a random section with 4 ints");
  config->addParam(ArConfigArg("int1", new int, "fun int"), section.c_str(), ArPriority::TRIVIAL);
  config->addParam(ArConfigArg("int2", new int, "fun int", -1, 1200), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("int3", new int, "fun int"), section.c_str(), ArPriority::IMPORTANT);
  config->addParam(ArConfigArg("int4", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("int4", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("int1", new int, "fun int"), section.c_str(), ArPriority::TRIVIAL);
  section = "another section";
  config->setSectionComment("another section", "this is another section with 1 of each type");
  config->addParam(ArConfigArg("inta", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("doublea", new double, "fun double"), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("boola", new bool, "fun bool"), section.c_str(), ArPriority::NORMAL);
  config->addParam(ArConfigArg("stringa", new char[512], "fun string", 512), section.c_str(), ArPriority::NORMAL);

  if (!server.open(7272))
  {
    printf("Could not open server port\n");
    exit(1);
  }
  config->setBaseDirectory("./");
  config->writeFile("default.txt");
  config->parseFile("modified.txt");
  config->writeFile("modifiedModified.txt");
  ArServerHandlerConfig configHandler(&server, Aria::getConfig(), 
				      "default.txt");
  
  server.run();
  
  Aria::shutdown();

  return 0;
}
Esempio n. 4
0
int main(int argc, char **argv)
{
  Aria::init();
  
  ArServerBase robotServer;
  if (!robotServer.open(5000))
  {
    printf("Could not open robot server port\n");
    Aria::exit(1);
  }

  ArServerBase clientServer;
  if (!clientServer.open(7272))
  {
    printf("Could not open robot server port\n");
    Aria::exit(1);
  }

  ArCentralManager switchManager(&robotServer, &clientServer);

  switchManager.addForwarderAddedCallback(
	  new ArGlobalFunctor1<ArCentralForwarder *>(&forwarderAdded), 
	  100);
  switchManager.addForwarderRemovedCallback(
	  new ArGlobalFunctor1<ArCentralForwarder *>(&forwarderRemoved), 
	  100);

  // Start a small handler to monitor communication between the server and 
  // client.
  ArServerHandlerCommMonitor commMonitor(&clientServer);

  ArServerHandlerCommands commands(&clientServer);
  commands.setPrefix("CentralServer");

  ArServerSimpleServerCommands serverCommands(&commands, &clientServer, 
					      false);
  commands.addCommand(
	  "NetworkLogConnections", "Logs the connections to the central server, and to all the forwarded connections",
	  new ArFunctorC<ArCentralManager>
	  (&switchManager, &ArCentralManager::logConnections));

  clientServer.runAsync();
  robotServer.run();
  Aria::exit(0);
}
int main(int argc, char **argv)
{
  Aria::init();
  ArServerBase server;
  if (!server.open(7272))
  {
    printf("Could not open server port\n");
    exit(1);
  }
  server.run();
  return 0;
}
Esempio n. 6
0
int main(int argc, char **argv)
{
  Aria::init();
  ArServerBase server;

  if (!server.open(7272))
  {
    printf("Could not open server port\n");
    exit(1);
  }

  ArServerFileLister fileLister(&server, ".");
  ArServerFileToClient fileToClient(&server, ".");
  ArServerFileFromClient fileFromClient(&server, ".", "/tmp");
  ArServerDeleteFileOnServer fileDeleter(&server, ".");
  server.run();
}
Esempio n. 7
0
int main(int argc, char **argv)
{
  Aria::init();
  ArServerBase server;
  ArGlobalFunctor2<ArServerClient *, ArNetPacket *> sendEmptyCB(&sendEmpty);
  if (!server.open(7272))
  {
    printf("Could not open server port\n");
    exit(1);
  }

  ArServerInfoDrawings drawing(&server);

  ArDrawingData arrows("polyarrow", ArColor(0, 0, 255), 5, 50);
  ArDrawingData dots("polydots", ArColor(0, 255, 0), 12, 50);
  drawing.addDrawing(&arrows, "arrows", &sendEmptyCB);
  drawing.addDrawing(&dots, "dots", &sendEmptyCB);
  server.run();

}
Esempio n. 8
0
int main(int argc, char **argv)
{
    Aria::init();
    //ArLog::init(ArLog::StdOut, ArLog::Verbose);
    // robot
    ArRobot robot;
    /// our server
    ArServerBase server;

    // set up our parser
    ArArgumentParser parser(&argc, argv);
    // set up our simple connector
    ArSimpleConnector simpleConnector(&parser);

    // set up a gyro
    ArAnalogGyro gyro(&robot);

    // load the default arguments
    parser.loadDefaultArguments();

    // parse the command line... fail and print the help if the parsing fails
    // or if the help was requested
    if (!simpleConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
    {
        simpleConnector.logOptions();
        exit(1);
    }

    if (!server.loadUserInfo("userServerTest.userInfo"))
    {
        printf("Could not load user info, exiting\n");
        exit(1);
    }

    server.logUsers();

    // first open the server up
    if (!server.open(7272))
    {
        printf("Could not open server port\n");
        exit(1);
    }

    // sonar, must be added to the robot
    ArSonarDevice sonarDev;
    // add the sonar to the robot
    robot.addRangeDevice(&sonarDev);

    ArIRs irs;
    robot.addRangeDevice(&irs);

    ArBumpers bumpers;
    robot.addRangeDevice(&bumpers);

    // a laser in case one is used
    ArSick sick(361, 180);
    // add the laser to the robot
    robot.addRangeDevice(&sick);




    // attach stuff to the server
    ArServerInfoRobot serverInfoRobot(&server, &robot);
    ArServerInfoSensor serverInfoSensor(&server, &robot);
    ArServerInfoDrawings drawings(&server);
    drawings.addRobotsRangeDevices(&robot);

    // ways of moving the robot
    ArServerModeStop modeStop(&server, &robot);
    ArServerModeDrive modeDrive(&server, &robot);
    ArServerModeRatioDrive modeRatioDrive(&server, &robot);
    ArServerModeWander modeWander(&server, &robot);
    modeStop.addAsDefaultMode();
    modeStop.activate();

    // set up the simple commands
    ArServerHandlerCommands commands(&server);
    // add the commands for the microcontroller
    ArServerSimpleComUC uCCommands(&commands, &robot);
    // add the commands for logging
    ArServerSimpleComMovementLogging loggingCommands(&commands, &robot);
    // add the commands for the gyro
    ArServerSimpleComGyro gyroCommands(&commands, &robot, &gyro);

    // add the commands to enable and disable safe driving to the simple commands
    modeDrive.addControlCommands(&commands);

    // Forward any video if we have some to forward.. this will forward
    // from SAV or ACTS, you can find both on our website
    // http://robots.activmedia.com, ACTS is for color tracking and is
    // charged for but SAV just does software A/V transmitting and is
    // free to all our customers... just run ACTS or SAV before you
    // start this program and this class here will forward video from it
    // to MobileEyes
    ArHybridForwarderVideo videoForwarder(&server, "localhost", 7070);

    // make a camera to use in case we have video
    ArPTZ *camera = NULL;
    ArServerHandlerCamera *handlerCamera = NULL;
    // if we have video then set up a camera
    if (videoForwarder.isForwardingVideo())
    {
        bool invertedCamera = false;
        camera = new ArVCC4(&robot,	invertedCamera,
                            ArVCC4::COMM_UNKNOWN, true, true);
        camera->init();
        handlerCamera = new ArServerHandlerCamera(&server, &robot, camera);
    }

    server.logCommandGroups();
    server.logCommandGroupsToFile("userServerTest.commandGroups");

    // now let it spin off in its own thread
    server.runAsync();

    // set up the robot for connecting
    if (!simpleConnector.connectRobot(&robot))
    {
        printf("Could not connect to robot... exiting\n");
        Aria::shutdown();
        return 1;
    }

    // set up the laser before handing it to the laser mode
    simpleConnector.setupLaser(&sick);

    robot.enableMotors();
    // start the robot running, true so that if we lose connection the run stops
    robot.runAsync(true);

    sick.runAsync();

    // connect the laser if it was requested
    if (!simpleConnector.connectLaser(&sick))
    {
        printf("Could not connect to laser... exiting\n");
        Aria::shutdown();
        return 1;
    }

    robot.waitForRunExit();
    // now exit
    Aria::shutdown();
    exit(0);
}
Esempio n. 9
0
int
main(int argc, char *argv[])
{
  // Initialize location of Aria, Arnl and their args.
  Aria::init();
  Arnl::init();

  // The robot object
  ArRobot robot;
#ifndef SONARNL
  // The laser object
  ArSick sick(181, 361);
#endif

  // Parse them command line arguments.
  ArArgumentParser parser(&argc, argv);

  // Set up our simpleConnector
  ArSimpleConnector simpleConnector(&parser);

  // Load default arguments for this computer
  parser.loadDefaultArguments();

  // Parse its arguments for the simple connector.
  simpleConnector.parseArgs();

  // sonar, must be added to the robot, for teleop and wander
  ArSonarDevice sonarDev;
  // add the sonar to the robot
  robot.addRangeDevice(&sonarDev);

  ArMap arMap;
#ifndef SONARNL
  // Initialize the localization
  ArLocalizationTask locTask(&robot, &sick, &arMap);
  // Make the path task
  ArPathPlanningTask pathTask(&robot, &sick, &sonarDev, &arMap);
#else
  // Initialize the localization
  ArSonarLocalizationTask locTask(&robot, &sonarDev, &arMap);
  // Make the path task
  ArPathPlanningTask pathTask(&robot, NULL, &sonarDev, &arMap);
#endif


  // Stop the robot as soon as localization fails.
  ArFunctor1C<ArPathPlanningTask, int>
  locaFailed(&pathTask, &ArPathPlanningTask::trackingFailed);
  locTask.addFailedLocalizationCB(&locaFailed);

  // Read in param files.
  Aria::getConfig()->useArgumentParser(&parser);
  if (!Aria::getConfig()->parseFile(Arnl::getTypicalParamFileName()))
  {
    printf("Trouble loading configuration file, exiting\n");
    exit(1);
  }
  // Warn about unknown params.
  if (!parser.checkHelpAndWarnUnparsed())
  {
    printf("\nUsage: %s -map mapfilename\n\n", argv[0]);
    simpleConnector.logOptions();
    exit(2);
  }

  // Our server
  ArServerBase server;

  // First open the server up
  if (!server.open(7272))
  {
    printf("Could not open server port\n");
    exit(1);
  }

  // Connect the robot
  if (!simpleConnector.connectRobot(&robot))
  {
    printf("Could not connect to robot... exiting\n");
    Aria::shutdown();
    return 1;
  }

  robot.com2Bytes(31, 14, 0);
  robot.com2Bytes(31, 15, 0);
  ArUtil::sleep(100);
  robot.com2Bytes(31, 14, 1);
  robot.com2Bytes(31, 15, 1);
  robot.enableMotors();
  robot.clearDirectMotion();

#ifndef SONARNL
  // Set up the laser before handing it to the laser mode
  simpleConnector.setupLaser(&sick);

  // Add the laser to the robot
  robot.addRangeDevice(&sick);
#endif

  // Start the robot thread.
  robot.runAsync(true);

#ifndef SONARNL
  // Start the laser thread.
  sick.runAsync();

  // Connect the laser
  if (!sick.blockingConnect())
  {
    printf("Couldn't connect to sick, exiting\n");
    Aria::shutdown();
    return 1;
  }
#endif

  ArUtil::sleep(300);

  // If you want to set the number of samples change the line below
  locTask.setNumSamples(2000);
  // Localize the robot to home
  if(locTask.localizeRobotAtHomeBlocking())
  {
    printf("Successfully localized at home.\n");
  }
  else
  {
    printf("WARNING: Unable to localize at home position!\n");
  }


  robot.lock();
  // attach stuff to the server
  ArServerInfoRobot serverInfoRobot(&server, &robot);
  ArServerInfoSensor serverInfoSensor(&server, &robot);
  ArServerInfoPath serverInfoPath(&server, &robot, &pathTask);
  ArServerInfoLocalization serverInfoLocalization(&server, &robot, &locTask);

#ifndef SONARNL
  // Set it up to handle maps.
  ArServerHandlerMap serverMap(&server, &arMap, ArServerHandlerMap::POINTS);
#else
  ArServerHandlerMap serverMap(&server, &arMap, ArServerHandlerMap::LINES);
#endif

  // Set up a service that allows the client to monitor the communication
  // between the robot and the client.
  //
  ArServerHandlerCommMonitor serverCommMonitor(&server);


  //ArServerModeGoto modeGoto(&server, &robot, &pathTask);
  //ArServerModeStop modeStop(&server, &robot);
  //ArServerModeDrive modeDrive(&server, &robot);

  SimpleTask simpleTask(&robot, &pathTask);

  robot.unlock();
  // Read in param files.
  Aria::getConfig()->parseFile(Arnl::getTypicalParamFileName());

  // Now let it spin off in its own thread
  server.run();
  exit(0);

}