int main(int argc, char **argv)
{
    Aria::init();
    ArClientBase client;
    std::string host;


    ArArgumentParser parser(&argc, argv);
    ArClientSimpleConnector clientConnector(&parser);

    parser.loadDefaultArguments();

    /* Check for -help, and unhandled arguments: */
    if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
    {
        clientConnector.logOptions();
        exit(0);
    }


    /* Connect our client object to the remote server: */
    if (!clientConnector.connectClient(&client))
    {
        if (client.wasRejected())
            printf("Server rejected connection, exiting\n");
        else
            printf("Could not connect to server, exiting\n");
        exit(1);
    }


    client.addHandler("getCameraModeListCam1",
                      new ArGlobalFunctor1<ArNetPacket *>(&getCameraModeList));

    client.requestOnce("getCameraModeListCam1");

    ArNetPacket sending;

    // This does the look at goal mode
    sending.empty();
    sending.strToBuf("lookAtGoal");
    client.requestOnce("setCameraModeCam1", &sending);

    // This does the look at point mode (at 0 0);

    sending.empty();
    sending.strToBuf("lookAtPoint");
    sending.byte4ToBuf(1157);
    sending.byte4ToBuf(-15786);
    client.requestOnce("setCameraModeCam1", &sending);

    while (Aria::getRunning() && client.isConnected())
    {
        client.loopOnce();
        ArUtil::sleep(1000);
    }
    Aria::shutdown();
    return 0;

};
int main(int argc, char **argv)
{
  Aria::init();
  ArLog::init(ArLog::StdOut, ArLog::Normal);
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();

  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }
  
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 
  client.setRobotName(client.getHost());  // include server hostname in log messages
  client.runAsync();
  ArUtil::sleep(500);
  client.logDataList();
  Aria::shutdown();
  return 0;
}
int main(int argc, char **argv)
{
  Aria::init();
  ArClientBase client;
  ArArgumentParser parser(&argc, argv);

  /* This will be used to connect our client to the server. 
   * It will get the hostname from the -host command line argument: */
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -host, -help, ARIA arguments, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    Aria::exit(0);
  }

  
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    Aria::exit(1);
  } 

  printf("Connected to server.\n");

  client.setRobotName(client.getHost()); // include server name in log messages

  client.runAsync();

 
  ArClientHandlerRobotUpdate updates(&client);
  updates.requestUpdates();

  while (client.getRunningWithLock())
  {
    updates.lock();
    printf("Mode:%s  Status:%s  Pos:%.0f,%.0f,%.0f  Vel:%.0f,%.0f,%.0f  Bat:%.1f  \r",
		updates.getMode(),
		updates.getStatus(),
		updates.getX(), updates.getY(), updates.getTh(),
		updates.getVel(), updates.getLatVel(), updates.getRotVel(),
		updates.getVoltage()
	);
	updates.unlock();
    ArUtil::sleep(1000);
  }

  /* The client stopped running, due to disconnection from the server, general
   * Aria shutdown, or some other reason. */
  client.disconnect();
  Aria::exit(0);
  return 0;
}
int main(int argc, char **argv)
{
	ros::init(argc, argv, "ariaClientDriverNode");	//ROS Initialization


	Aria::init();										//Aria Initialization
	ArClientBase client;								//setup client
	ArArgumentParser parser(&argc, argv);				//command line argument handler
	ArClientSimpleConnector clientConnector(&parser);	//connect to Arserver

	parser.loadDefaultArguments();
	if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
	{
		Aria::logOptions();
		exit(0);
	}

	if (!clientConnector.connectClient(&client))
	{
		if (client.wasRejected())
			printf("Server '%s' rejected connection, exiting\n", client.getHost());
		else
			printf("Could not connect to server '%s', exiting\n", client.getHost());
		exit(1);
	}
	printf("Connected to server.\n");

	client.setRobotName(client.getHost()); // include server name in log messages
	ArKeyHandler keyHandler;
	Aria::setKeyHandler(&keyHandler);
	ArGlobalFunctor escapeCB(&escape);
	keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);
	client.runAsync();

	if(!client.dataExists("ratioDrive") )
		printf("Warning: server does not have ratioDrive command, can not use drive commands!\n");
	else
		printf("Keys are:\nUP: Forward\nDOWN: Backward\nLEFT: Turn Left\nRIGHT: Turn Right\n");
	printf("s: Enable safe drive mode (if supported).\nu: Disable safe drive mode (if supported).\nl: list all data requests on server\n\nDrive commands use 'ratioDrive'.\nt: logs the network tracking tersely\nv: logs the network tracking verbosely\nr: resets the network tracking\n\n");


	AriaClientDriver ariaClientDriver(&client,&keyHandler,"");

	//while (ros::ok() && client.getRunningWithLock()) //the main loop
	while (client.getRunningWithLock()) //the main loop
	{
		keyHandler.checkKeys();  //addthis if teleop from node required
		ariaClientDriver.controlloop();
		//Input output handling callback threads implemented in ariaClientDriver Class
		ArUtil::sleep(100);	//noneed

	}

	client.disconnect();
	Aria::shutdown();
	return 0;
}
int main(int argc, char **argv)
{
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();

  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }

  if (parser.getArgc() < 4 || parser.getArgc() > 6)
  {
    printf("usage: %s <x> <y> <th> <optional:xyspread> <optional:thspread>", argv[0]);
    exit(1);
  }

  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 
  client.runAsync();

  ArNetPacket sending;
  // put in the arguments (you can see what they are from doing -lcl on clientDemo)
  sending.byte4ToBuf(atoi(parser.getArg(1)));
  sending.byte4ToBuf(atoi(parser.getArg(2)));
  sending.byte4ToBuf(atoi(parser.getArg(3)));
  if (parser.getArgc() > 4)
    sending.uByte4ToBuf(atoi(parser.getArg(4)));
  if (parser.getArgc() > 5)
    sending.uByte4ToBuf(atoi(parser.getArg(5)));
  // send the packet
  client.requestOnce("localizeToPose", &sending);

  // you have to give the client some time to send the command
  ArUtil::sleep(500);
  

  Aria::shutdown();
  return 0;
}
Exemple #6
0
int main(int argc, char **argv)
{
  Aria::init();

  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }

  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  printf("Connected to server.\n");


  /* Create a key handler and also tell Aria about it */
  ArKeyHandler keyHandler;
  Aria::setKeyHandler(&keyHandler);

  /* Global escape-key handler to shut everythnig down */
  ArGlobalFunctor escapeCB(&escape);
  keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);

  client.runAsync();

  while (client.getRunningWithLock())
  {
    keyHandler.checkKeys();
    ArUtil::sleep(100);
  }

  Aria::shutdown();
  return 0;
}
int main(int argc, char **argv)
{
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();

  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }
  
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 
  client.runAsync();

  ArNetPacket sending;
  // We have to tell it what section we're sending
  sending.strToBuf("Section");
  // The map is in the files section
  sending.strToBuf("Files");
  // The parameter name
  sending.strToBuf("Map");
  // The value of the parameter
  sending.strToBuf("entire2.map");

  // you could put in however many of these you want... 

  client.requestOnce("setConfig", &sending);

  // you have to give the client some time to send the command
  ArUtil::sleep(500);
  

  Aria::shutdown();
  return 0;
}
int main(int argc, char **argv)
{

  std::string hostname;
  ArGlobalFunctor1<ArNetPacket *> drawingCB(&drawing);
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);



  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  
  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }

  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  printf("Connected to server.\n");

  client.addHandler("listDrawings", &drawingCB);
  client.requestOnce("listDrawings");
  
  client.runAsync();
  while (client.getRunningWithLock())
  {
    ArUtil::sleep(1);
    //printf("%d ms since last data\n", client.getLastPacketReceived().mSecSince());
  }
  Aria::shutdown();
  return 0;

}
int main(int argc, char **argv)
{
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();

  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }
  
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 
  client.runAsync();

  ArNetPacket sending;
  // We have to tell it what route we want to patrol
  sending.strToBuf("hallways");
  // tell it how much many times we want to patrol (<= 0 == forever)
  sending.byte4ToBuf(0);

  client.requestOnce("patrolRouteCount", &sending);

  // note that there's also another call (patrol) that just has it always
  // patrol forever but this gives you more options and is only
  // slightly more complicated (just give it that byte4)

  // you have to give the client some time to send the command
  ArUtil::sleep(500);
  

  Aria::shutdown();
  return 0;
}
int main(int argc, char **argv)
{
  Aria::init();
  ArClientBase client;
  std::string host;
  

  ArArgumentParser parser(&argc, argv);
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }

  
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server rejected connection, exiting\n");
    else
      printf("Could not connect to server, exiting\n");
    exit(1);
  } 

  
  client.requestOnce("reloadConfig");


  ArTime start;
  start.setToNow();
  while (Aria::getRunning() && client.isConnected())
  {
    client.loopOnce();
    ArUtil::sleep(ArMath::random() % 10000);
    client.requestOnce("reloadConfig");
  }
  Aria::shutdown();
  return 0;
}
int main(int argc, char **argv)
{

  Aria::init();
  ArLog::init(ArLog::StdOut, ArLog::Normal);
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();

  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }
  
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  ArGlobalFunctor1<ArNetPacket *> getModeDataListCB(&getModeDataList);
  ArGlobalFunctor1<ArNetPacket *> getModeInfoCB(&getModeInfo);
  client.addHandler("getModeDataList", &getModeDataListCB);
  client.requestOnce("getModeDataList");
  client.addHandler("getModeInfo", &getModeInfoCB);
  client.request("getModeInfo", -1);

  client.runAsync();
  while (client.getRunningWithLock())
  {
    ArUtil::sleep(1);
    //printf("%d ms since last data\n", client.getLastPacketReceived().mSecSince());
  }
  Aria::shutdown();
  return 0;

}
int main(int argc, char **argv)
{
  Aria::init();
  ArGlobalFunctor1<ArNetPacket *> clientListHandlerCB(&clientListHandler);
  ArGlobalFunctor1<ArNetPacket *> clientAddedHandlerCB(&clientAddedHandler);
  ArGlobalFunctor1<ArNetPacket *> clientRemovedHandlerCB(&clientRemovedHandler);
  ArNetPacket packet;

  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }

  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  printf("Connected to server.\n");

  client.addHandler("clientList", &clientListHandlerCB);
  client.requestOnce("clientList");
  client.addHandler("clientRemoved", &clientRemovedHandlerCB);
  client.request("clientRemoved", -1);
  client.addHandler("clientAdded", &clientAddedHandlerCB);
  client.request("clientAdded", -1);
  client.run();
  Aria::shutdown();
  return 0;
}
int main(int argc, char **argv)
{
  Aria::init();
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);
  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {    
    Aria::logOptions();
    return 1;
  }

  if (!clientConnector.connectClient(&client))
  {
    if(client.wasRejected())
      ArLog::log(ArLog::Terse, "Error, server '%s' rejected connection. Exiting.", client.getHost());
    else
      ArLog::log(ArLog::Terse, "Error, could not connect to server '%s'. Exiting.", client.getHost());
    return 2;
  }

  client.setRobotName(client.getHost());  // include server hostname in log messages

  client.runAsync();

  PtzCameraExample example(&client);
  if(!example.init())
    return 1;

  example.run();


  Aria::shutdown();
  return 0;
}
Exemple #14
0
int main(int argc, char **argv)
{
  Aria::init();
  ArClientBase client;
  ArArgumentParser parser(&argc, argv);

  /* This will be used to connect our client to the server. 
   * It will get the hostname from the -host command line argument: */
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -host, -help, ARIA arguments, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    Aria::exit(0);
  }

  
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    Aria::exit(1);
  } 

  printf("Connected to server.\n");
  client.setRobotName(client.getHost()); // include server name in log messages
  client.runAsync();
  ArNetPacket request;
//  request.
//  client.requestOnceByCommand(ArCommands::ENABLE, )


  ArClientHandlerRobotUpdate updates(&client);
//  client.requestOnce("enableMotor");

  ArGlobalFunctor1<ArNetPacket*> enableCB(&enable);
  ArGlobalFunctor1<ArNetPacket *> getFileCB(&netGetFile);
  ArGlobalFunctor1<ArNetPacket*> recieveDataCB(&recieveData);

  client.addHandler("requestEnableMotor", &enableCB);
  client.addHandler("handleCheckObjectData", &recieveDataCB);
  //client.addHandler("getFile", &getFileCB);

  client.requestOnce("requestEnableMotor");
  client.request("handleCheckObjectData", 10);
  updates.requestUpdates();
  if (checkObject)
	client.requestOnceWithString("getFile", "./image/ball.jpg");
  ArPose pose;
  namedWindow("image", 0);
  while (client.getRunningWithLock())
  {

	  //client.requestOnce("sendData");

	  if (checkObject) {
	//	  if (!a) {
			  cout <<"OK"<<endl;
		//	  client.requestOnceWithString("getFile", "./image/ball.jpg");
			  client.addHandler("getFile", &getFileCB);
//			  client.remHandler("getFile", &getFileCB);
		  //}	else {
			  //client.remHandler("getFile", &getFileCB);
		  //}
		  Mat image;
		  image = imread("./image/ball.jpg", CV_LOAD_IMAGE_COLOR);
		  
		  imshow("image", image);
		  char c = (char)waitKey(10);
		  if( c == 27 )
			break;
	  }

    ArUtil::sleep(200);
  }

//  client.requestStop("getFile");

  cout <<"Da tim thay qua bong o vi tri pose("<<pose.getX()<<", "<<pose.getY()<<")"<<endl;

  cout <<"Vi tri pose("<<pose.getX()<<", "<<pose.getY()<<")"<<endl;

  /* The client stopped running, due to disconnection from the server, general
   * Aria shutdown, or some other reason. */
  client.disconnect();
  Aria::exit(0);
  return 0;
}
Exemple #15
0
int main(int argc, char **argv)
{
  // Initialize Aria and Arnl global information
 
 /* Aria initialization: */
  Aria::init();

  ArLog::init(ArLog::File, ArLog::Verbose,"c:\\temp\\AmbifluxRobot.log",true);

  ArLog::log(ArLog::Verbose, "Ambiflux Starting");

  // Create the sound queue.
  ArSoundsQueue soundQueue;

  // Set WAV file callbacks 
  soundQueue.setPlayWavFileCallback(ArSoundPlayer::getPlayWavFileCallback());
  soundQueue.setInterruptWavFileCallback(ArSoundPlayer::getStopPlayingCallback());

  // Notifications when the queue goes empty or non-empty.
  soundQueue.addQueueEmptyCallback(new ArGlobalFunctor(&queueNowEmpty));
  soundQueue.addQueueNonemptyCallback(new ArGlobalFunctor(&queueNowNonempty));

  // Run the sound queue in a new thread
  soundQueue.runAsync();
  /* Pool de messages en provenance de la tablette
  Issu de l'implementation d'un modèle producteur/consommateur
  pour les messages entrants. Plusieurs thread y accèdent
  Tread-safe (mutex)*/
  //Pool<Frame> messagePool;
 /* Pool de messages en provenance d'un client TCP
  Issu de l'implementation d'un modèle producteur/consommateur
  pour les messages entrants. Plusieurs thread y accèdent
  Tread-safe (mutex)*/
  /*TODO : A remplacer par tcpReceivedPool */
  //Pool<Frame> tcpMessagePool;

  /* Pool de messages en provenance d'un client TCP
  Issu de l'implementation d'un modèle producteur/consommateur
  pour les messages entrants. Plusieurs thread y accèdent
  Tread-safe (mutex)*/
  Pool<TCPReceivedRequest> tcpReceivedPool;

  /*Create our thread to communicate with iPad
   Server start on port 7171 to receive requests from ipad
   A client is created on port 7474 to request iPad
   */
  //IhmCommunicationThread ihm(7171, &messagePool);

  IhmCommunicationThread ihm(7171, &tcpReceivedPool);
   //On s'abonne à la réception de message par la classe IhmCommunicationThread
  //Todo : A supprimer ?
  //ArGlobalFunctor1<Frame> functMessageReceived(&CallbackIhmReceived);
  //ihm.setCallback(&functMessageReceived);
  ihm.runAsync();

  //soundQueue.play("c:\\temp\\let_me_out.wav");

  

  //while(true);

  /* Create our client object. This is the object which connects with a remote
   * server over the network, and which manages all of our communication with it
   * once connected by sending data "requests".  Requests may be sent once, or
   * may be repeated at any frequency. Requests and replies to requsets contain 
   * payload "packets", into which various data types may be packed (when making a 
   * request), and from which they may also be extracted (when handling a reply). 
   * See the InputHandler and OutputHandler classes above for
   * examples of making requests and reading/writing the data in packets.
   */
  ArClientBase client;

  /* Aria components use this to get options off the command line: */
  ArArgumentParser parser(&argc, argv);

  /* This will be used to connect our client to the server, including
   * various bits of handshaking (e.g. sending a password, retrieving a list
   * of data requests and commands...)
   * It will get the hostname from the -host command line argument: */
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }
  
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  printf("Connected to server.\n");

  client.setRobotName(client.getHost()); // include server name in log messages


  ///* Create a key handler and also tell Aria about it */
  ArKeyHandler keyHandler;
  Aria::setKeyHandler(&keyHandler);

  /* Global escape-key handler to shut everythnig down */
  ArGlobalFunctor escapeCB(&escape);
  keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);

  /* Now that we're connected, we can run the client in a background thread, 
   * sending requests and receiving replies. When a reply to a request arrives,
   * or the server makes a request of the client, a handler functor is invoked. 
   * The handlers for this program are registered with the client by the 
   * InputHandler and OutputHandler classes (in their constructors, above) */
  client.runAsync();

  ///* Create the InputHandler object and request safe-drive mode */
  //InputHandler inputHandler(&client);
  //inputHandler.gotoGoal("215");
  ////inputHandler.safeDrive();
  

// Mode goto
if(!client.dataExists("gotoGoal") )
      printf("Warning: Pas de mode goto!\n");
  else
    printf("Mode goto accepte");


//ArFunctor1<ArNetPacket*>
//client.addHandler("pathPlannerStatus",);



  /* Create the OutputHandler object. It will begin printing out data from the
   * server. */
  OutputHandler outputHandler(&client);

   //On s'abonne à la réception de message par la classe IhmCommunicationThread
  //Todo : A supprimer ?
  //ArGlobalFunctor1<Frame> functMessageReceived(&CallbackIhmReceived);
  //ihm.setCallback(&functMessageReceived);
  //ihm.runAsync();

  //pour tester IHM
 // ArUtil::sleep(1000);
//  ihm.testCommunication();

	//SRMA object
	string strSRMA = DALRest::getResourceById("9");
	SRMA srma(strSRMA,client, outputHandler, ihm, &soundQueue);

	//Loop du mode Ambiant
	MainLoop myLoop(srma, &tcpReceivedPool);
	myLoop.runAsync();
	
	//Thread loop : TCP commands
	//Produces messages in tcpMessagePool
	//ServerLoop myServerLoop(srma, &tcpReceivedPool);
	//myServerLoop.runAsync();
 
	//Traitement des requetes TCP
	//Consulmes messages in tcpMessagePool
	//TCPRequestsLoop myTCPRequestsLoop(srma, &tcpReceivedPool);
	//myTCPRequestsLoop.runAsync();

 

  /* While the client is still running (getRunningWithLock locks the "running"
   * flag until it returns), check keys on the key handler (which will call
   * our callbacks), then tell the input handler to send drive commands. 
   * Sleep a fraction of a second as well to avoid using
   * too much CPU time, and give other threads time to work.
   */
  while (client.getRunningWithLock())
  {
    //keyHandler.checkKeys();
    //inputHandler.sendInput();
    ArUtil::sleep(100);
  }

  /* The client stopped running, due to disconnection from the server, general
   * Aria shutdown, or some other reason. */
  client.disconnect();
  Aria::shutdown();
  return 0;
}
Exemple #16
0
int main(int argc, char **argv)
{
    std::string hostname;
    Aria::init();
    //ArLog::init(ArLog::StdOut, ArLog::Verbose);
    ArClientBase client;


    ArArgumentParser parser(&argc, argv);

    ArClientSimpleConnector clientConnector(&parser);

    parser.loadDefaultArguments();

    ArClientFileFromClient::SendSpeed speed = ArClientFileFromClient::SPEED_AUTO;


    if (parser.checkArgument("-speed_fast"))
    {
        ArLog::log(ArLog::Normal, "Putting file with speed_fast");
        speed = ArClientFileFromClient::SPEED_FAST;
    }
    else if (parser.checkArgument("-speed_slow"))
    {
        ArLog::log(ArLog::Normal, "Putting file with speed_slow");
        speed = ArClientFileFromClient::SPEED_SLOW;
    }
    else
    {
        ArLog::log(ArLog::Normal, "Putting file with speed_auto");
    }

    bool pauseAfterSend;

    if (parser.checkArgument("-pauseAfterSend"))
    {
        ArLog::log(ArLog::Normal, "Will pause after send");
        pauseAfterSend = true;
    }
    else
    {
        ArLog::log(ArLog::Normal, "Will not pause after send");
        pauseAfterSend = false;
    }

    /* Check for -help, and unhandled arguments: */
    if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed(1) ||
            parser.getArgc() <= 1)
    {
        ArLog::log(ArLog::Normal, "%s <fileName> [-speed_fast] [-speed_slow] [-pauseAfterSend]",
                   argv[0]);
        ArLog::log(ArLog::Normal, "Default send speed is speed_auto");
        ArLog::log(ArLog::Normal, "");
        Aria::logOptions();
        exit(0);
    }

    const char *fileName = parser.getArg(1);



    /* Connect our client object to the remote server: */
    if (!clientConnector.connectClient(&client))
    {
        if (client.wasRejected())
            printf("Server '%s' rejected connection, exiting\n", client.getHost());
        else
            printf("Could not connect to server '%s', exiting\n", client.getHost());
        exit(1);
    }

    fileFromClient = new ArClientFileFromClient(&client);
    fileFromClient->addFileSentCallback(
        new ArGlobalFunctor1<int>(&fileSent));

    client.runAsync();

    done = false;
    if (!fileFromClient->putFileToDirectory(NULL, fileName, fileName,
                                            speed))
    {
        printf("Error before sending file\n");
        Aria::exit(1);
    }

    waitForDone();

    if (pauseAfterSend)
        ArUtil::sleep(10000);

    Aria::exit(0);
    return 255;
}
int main(int argc, char **argv)
{
    std::string hostname;
    Aria::init();
    //ArLog::init(ArLog::StdOut, ArLog::Verbose);
    ArClientBase client;


    ArArgumentParser parser(&argc, argv);

    ArClientSimpleConnector clientConnector(&parser);

    parser.loadDefaultArguments();

    /* Check for -help, and unhandled arguments: */
    if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
    {
        Aria::logOptions();
        exit(0);
    }

    /* Connect our client object to the remote server: */
    if (!clientConnector.connectClient(&client))
    {
        if (client.wasRejected())
            printf("Server '%s' rejected connection, exiting\n", client.getHost());
        else
            printf("Could not connect to server '%s', exiting\n", client.getHost());
        exit(1);
    }

    fileLister = new ArClientFileLister(&client);
    fileLister->addUpdatedCallback(new ArGlobalFunctor1<int>(&updated));

    fileToClient = new ArClientFileToClient(&client);
    fileToClient->addFileReceivedCallback(
        new ArGlobalFunctor1<int>(&fileReceived));

    fileFromClient = new ArClientFileFromClient(&client);
    fileFromClient->addFileSentCallback(
        new ArGlobalFunctor1<int>(&fileSent));

    deleteFileOnServer = new ArClientDeleteFileOnServer(&client);
    deleteFileOnServer->addFileDeletedCallback(
        new ArGlobalFunctor1<int>(&fileDeleted));

    client.runAsync();

    /*
    if (deleteFileOnServer->deleteFileFromDirectory(NULL, "all.bob"))
      waitForDone();
    else
      printf("Error deleting file\n");

    if (deleteFileOnServer->deleteFileFromDirectory("1", "all.bob"))
      waitForDone();
    else
      printf("Error deleting file\n");

    if (deleteFileOnServer->deleteFileFromDirectory("1/3", "all.bob"))
      waitForDone();
    else
      printf("Error deleting file\n");


    if (deleteFileOnServer->deleteFileFromDirectory("fun", "all.bob"))
      waitForDone();
    else
      printf("Error deleting file\n");

    if (deleteFileOnServer->deleteFileFromDirectory("argh", "all.bob"))
      waitForDone();
    else
      printf("Error deleting file\n");
    */

    /*
    done = false;
    if (fileFromClient->putFileToDirectory("argh", "png", "app_logo.png", ArClientFileFromClient::SPEED_SLOW))
      waitForDone();
    else
      printf("Error before sending file\n");
    */
    done = false;
    if (fileFromClient->putFileToDirectory(NULL, "dox", "doxygen.conf", ArClientFileFromClient::SPEED_SLOW))
        waitForDone();
    else
        printf("Error before sending file\n");


    /*
      done = false;
      if (fileFromClient->putFileToDirectory("argh", "png", "app_logo.png")
        waitForDone();
      else
        printf("Error before sending file\n");

      done = false;
      if (fileFromClient->putFileToDirectory(NULL, "dox", "doxygen.conf")
        waitForDone();
      else
        printf("Error before sending file\n");
    */
    /*
      fileLister->changeToTopDir();
      waitForDone();
      fileLister->changeToDir("argh");
      waitForDone();
      fileLister->log(true);

      fileToClient->getFileFromDirectory("argh\\um", "doxygen", "slashes");
      waitForDone();
      fileToClient->getFileFromDirectory("argh", "DOXYGEN.Conf", "blah.um.2");
      waitForDone();
      fileToClient->getFileFromDirectory("argh", "wehlkjadsf", "blah.um.2");
      waitForDone();
      fileToClient->getFileFromDirectory("argh", "1", "blah.um");
      waitForDone();
      fileToClient->getFileFromDirectory(NULL, "1", "blah.um.2");
      waitForDone();
      */
    /*
    fileToClient->getFileFromDirectory(NULL, "all.map", "all.map.2");
    waitForDone();

    fileToClient->getFileFromDirectory(NULL, "um.map", "all.map.2");
    waitForDone();

    fileToClient->getFileFromDirectory(NULL, "all.map", "all.map.3");
    waitForDone();

    fileToClient->getFileFromDirectory(NULL, "configClient.txt", "something");
    waitForDone();

    */

    /*
    fileLister->changeToTopDir();
    waitForDone();
    fileLister->changeToDir("0level");
    waitForDone();
    fileLister->changeToDir("1level");
    waitForDone();
    fileLister->upOneDir();
    waitForDone();
    fileLister->changeToDir("1level2");
    waitForDone();
    */



    Aria::shutdown();
    return 0;

}
Exemple #18
0
void NavigationClient::Main()
{

	std::cout << "Navigation client started" << std::endl;
	int argsNumber;
	argsNumber = 3;
    char *arguments[argsNumber];
    arguments[0]="./arg_test";
    arguments[1]="-host";
    //arguments[2]="10.41.42.1";
    //se puede poner también patrolbot
    arguments[2]="77.7.27.1";

  int robotCase, counter;
	
  ArClientBase client;
  ArPose pose(0, 0, 0);
  ArPose GoToPose(3000.0, 0.0, -90.0);
  ArNetPacket posePacket, directGoToPosePacket;

  ArArgumentParser parser(&argsNumber, arguments);posePacket.empty();
		 
  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();
  
  headingsForBedroom.push_back(45);
  headingsForBedroom.push_back(25);
  headingsForBedroom.push_back(0);
  
 
  headingsForLiving.push_back(-20);
  headingsForLiving.push_back(-55);
  headingsForLiving.push_back(-80);
  headingsForLiving.push_back(-110);
  headingsForLiving.push_back(-140);
  
  openDoor = false;
  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) {
    clientConnector.logOptions();
    exit(0);
  }
  
  printf("Connecting...\n");
  if (!clientConnector.connectClient(&client)) {
    if (client.wasRejected())
      printf("Server rejected connection, exiting\n");
    else
      printf("Could not connect to server, exiting\n");
    
    exit(1);
  } 

  printf("Connected to server.\n");
  client.addHandler("pathPlannerStatus", new ArGlobalFunctor1<ArNetPacket*>(&handlePathPlannerStatus));
  client.addHandler("update", new ArGlobalFunctor1<ArNetPacket*>(&handleRobotUpdate));
  client.addHandler("goalName", new ArGlobalFunctor1<ArNetPacket*>(&handleGoalName));
  client.addHandler("getGoals", new  ArGlobalFunctor1<ArNetPacket*>(&handleGoalList));
  client.addHandler("getSensorCurrent", new ArGlobalFunctor1<ArNetPacket*>(&handleSensorCurrent));
  client.addHandler("getSensorList", new ArGlobalFunctor1<ArNetPacket*>(&handleSensorList));
  client.addHandler("getLocState", new ArGlobalFunctor1<ArNetPacket*>(&handleLocState));

  client.runAsync();

  client.requestOnce("getGoals");
  client.requestOnce("getSensorList");
  client.requestOnceWithString("getSensorCurrent", "lms2xx_1");
  // client.request("pathPlannerStatus", 5000);
  client.request("goalName", 1000);
  client.request("update", 1000);
  client.requestOnce("getLocState");
  
  sleep(2);
  int cont =0;
  while (!openDoor) {
    cont++;
    ArUtil::sleep(2000);
    client.requestOnceWithString("getSensorCurrent", "lms2xx_1");
  }

  printf("*** Door has been OPENED *** \n");
  sleep(2);

  if (client.dataExists("localizeToPose")) {
	  printf(".. Server does have \"localizeToPose\" request.\n");
	  posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_X());
	  posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_Y());
	  posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_Angle());
	  
	  client.requestOnce("localizeToPose", &posePacket);
	  ArUtil::sleep(1500);
  }
  else
	  printf(".. Server doesn't have that request.\n");

  
  for(;;){
		string action = sharedMemory->getInstance().getAction();
			
		if (action=="navigate"){
		    cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl;  
		    navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
                   sharedMemory->getInstance().setAction("turn");
		 
			
		}if (action=="navigateToParty"){
		    cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl;  
		    navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
		    sleep(6);
		    sharedMemory->getInstance().startDownToRotations=false;
		    sharedMemory->getInstance().sintetizer.set_Phrase("If you need something please wave your hand to my bottom kinect");
		    sleep(8);
		    indexHeading=0;
		    sharedMemory->getInstance().setAction("turn");
		   
		}
		else if (action=="navigateBackToEmergency"){
		    
		    cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl;  
		    
		    navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
		     // sharedMemory->sintetizer.set_Phrase("Emergency Situation resolved");
		    sharedMemory->getInstance().setAction("createReport");
			
		}else if (action=="navigateToEntrance"){
		    cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl;  
		    sharedMemory->getInstance().sintetizer.set_Phrase("Do not worry, I have called the ambulance");
			  sleep(2);
		    sharedMemory->getInstance().sintetizer.set_Phrase("Please wait a moment, I willl wait for them");
			  sleep(2);
	  
		    navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
		    sharedMemory->getInstance().setAction("waitForAmbulance");
		}
		else if (action=="navigateCloseTo"){
		    cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl;  
		    navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
	            sharedMemory->getInstance().setAction("requestEmergencyObjects");
			
		}
		else if (action=="navigateToHome"){
		  cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl;  
		  navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
		  sharedMemory->getInstance().setAction("requestCommand");
		}
		else if (action=="navigateToQuestions"){
		  cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl;  
		  navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
		  sharedMemory->getInstance().setAction("requestQuestions");
		}
		else if (action=="navigateToObject"){
		  //solo es utilizado por cocktail Party
		  //Si se quita la indicación de lugar en requestOptions aqui debe mandarse el destino predefinido (kitchen?)
		  cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl;  
		  navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
		  sharedMemory->getInstance().setAction("recognizeObject");
		}
		else if (action=="navigateToObjectCategory"){
		  //considera que la posición de la categoria de un objeto (en pick and place) es la misma posición que la de donde esta el objeto en emergencia.
		  cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl; 
		  //por default ahorita esta dining como el la categoria del objeto
		  navigateTo(sharedMemory->getInstance().getStringDestination(), &client);
		  if (sharedMemory->getInstance().getTestRunning()=="pick and place" || sharedMemory->getInstance().getTestRunning()=="Emergency" )
		    sharedMemory->getInstance().setAction("deliverObject");
		  else
		  sharedMemory->getInstance().setAction("userRecognize");
			
		}else if (action=="navigateToPoint"){
		    
		    cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl;  
		    //TODO verificar que esto limpia el objeto
		    posePacket.empty();
		    posePacket.byte4ToBuf(sharedMemory->getInstance().lastObjective->getObjetivePosition().get_X());
		    posePacket.byte4ToBuf(sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Y());
		    posePacket.byte4ToBuf(sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Angle());
		    cout << "Enviando punto a navegación: "<< sharedMemory->getInstance().lastObjective->getObjetivePosition().get_X() << "," << sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Y() << "," << sharedMemory->getInstance().lastObjective->getObjetivePosition().get_Angle()<<endl;
		    client.requestOnce("gotoPose", &posePacket);
		  
		    sleep(10);
		    printf("Before while Navigation");
		    while (strncmp(textData, "Arrived at", 10) != 0){
			sleep(10);
		    }
		 
		    printf("Navigation ended");
	           if (sharedMemory->getInstance().getTestRunning()=="CocktailParty")
		   sharedMemory->getInstance().setAction("userLearn");
		   else
		   sharedMemory->getInstance().setAction("requestEmergencyObjects");
	
		}else if (action=="navigateForward"){
		  
		  stringstream command;
		  cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl;  
		  command<<"8 " << sharedMemory->getInstance().getGestureDepthPosition();
		  cout<< "******  AVANZA "<<command.str().c_str()<<" mm"<<endl;
		  client.requestOnceWithString("MicroControllerMotionCommand",command.str().c_str());
		  sleep(10);
		  printf("Before while Navigation");
		  while (strncmp(textData, "Stopped", 10) != 0){
			sleep(10);
			
		  }
		  sharedMemory->getInstance().setAction("turn");
		}else if (action=="turn"){
		  
		  int heading=0;
		  stringstream command;
                  cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl;
		  if (sharedMemory->getInstance().startDownToRotations==false){
		    if (sharedMemory->getInstance().getStringDestination()=="bedroom"){
		      cout<<"Entrando BEDROOM 1"<<endl;
		      if (indexHeading < headingsForBedroom.size()){
			heading=headingsForBedroom[indexHeading];
			indexHeading++;
			cout<<"Entrando a If UNO bedroom"<<endl;
		      }else{
			sharedMemory->getInstance().startDownToRotations=true;
			indexHeading=headingsForBedroom.size()-2;
			heading=(-1000);//valor dado para detectar que no se obtuvo un valor válido para el heading, dado que se cambia la forma en como se recorre el arreglo
			cout<<"Entrando a else UNO bedroom"<<endl;
		      }
		    }else {//if (sharedMemory->getInstance().getStringDestination()=="living"){
		      cout<<"Entrando a LIVING 1"<<endl;
		      if (indexHeading < headingsForLiving.size()){
			heading=headingsForLiving[indexHeading];
			indexHeading++;
			cout<<"Entrando a If UNO living"<<endl;
		      }else{
			sharedMemory->getInstance().startDownToRotations=true;
			indexHeading=headingsForLiving.size()-2;//no menos uno porque ya el proceso anterior permition visitar este indice
			heading=(-1000);
			cout<<"Entrando a else UNO Living"<<endl;
		      }
		    }
		    
		  }else{
		    if (sharedMemory->getInstance().getStringDestination()=="bedroom"){
		      cout<<"Entrando BEDROoM 2"<<endl;
		      if (indexHeading >= 0){
			heading=headingsForBedroom[indexHeading];
			indexHeading--;
			cout<<"Entrando a if DOS bedroom"<<endl;
		      }else{
			sharedMemory->getInstance().startDownToRotations=false;
			indexHeading=1;
			heading=(-1000);
			cout<<"Entrando a else DOS bedroom"<<endl;
		      }
		    }else {//if (sharedMemory->getInstance().getStringDestination()=="living"){
		      cout<<"Entrando a LIVING 2"<<endl;
		      if (indexHeading>= 0){
			heading=headingsForLiving[indexHeading];
			indexHeading--;
			cout<<"Entrando a if DOS living"<<endl;
		      }else{
			sharedMemory->getInstance().startDownToRotations=false;
			indexHeading=1;//no 0 porque ya el proceso anterior permitió visitar este indice
			heading=(-1000);
			cout<<"Entrando a else DOS living"<<endl;
		      }
		    }
		  }
		    
		  if (heading>(-1000)){
		    command<<"12 " << heading;
		    cout<< "******  ROTAR "<<command.str().c_str()<<" grades con INDEXHEADING: "<<indexHeading<<"valorArray"<< headingsForLiving[indexHeading]<<endl;
		    client.requestOnceWithString("MicroControllerMotionCommand",command.str().c_str());
		    //sharedMemory->getInstance().sintetizer.set_Phrase("If you need something, please wave your hand to my bottom kinect");
	            sleep(1);
		    cout<<"*INVERSA al hacer el heading: "<< sharedMemory->getInstance().startDownToRotations << endl;
		    sharedMemory->getInstance().setAction("payAttention"); 
		  }
		}else if (action=="navigateToExit"){
		    //éste estado solo llamarlo para terminar la prueba
		    cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl;  
		    navigateTo("Exit", &client);
		   sharedMemory->getInstance().setAction("turnOff");;		
		}
		else if (action=="turnOff"){
                       cout<<"Starting: "<< action << " STATE in NavigationClient"<<endl;  
			//ArUtil::sleep(60000);
			printf("Server disconnected.\n");
			Aria::shutdown();
		}
	
	}
	return ;
  
}
Exemple #19
0
int main(int argc, char **argv)
{
  /* Aria initialization: */
  Aria::init();

  //ArLog::init(ArLog::StdErr, ArLog::Verbose);
 

  /* Create our client object. This is the object which connects with a remote
   * server over the network, and which manages all of our communication with it
   * once connected by sending data "requests".  Requests may be sent once, or
   * may be repeated at any frequency. Requests and replies to requsets contain 
   * payload "packets", into which various data types may be packed (when making a 
   * request), and from which they may also be extracted (when handling a reply). 
   * See the InputHandler and OutputHandler classes above for
   * examples of making requests and reading/writing the data in packets.
   */
  ArClientBase client;

  /* Aria components use this to get options off the command line: */
  ArArgumentParser parser(&argc, argv);

  /* This will be used to connect our client to the server, including
   * various bits of handshaking (e.g. sending a password, retrieving a list
   * of data requests and commands...)
   * It will get the hostname from the -host command line argument: */
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }

  
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  printf("Connected to server.\n");

  client.setRobotName(client.getHost()); // include server name in log messages

  /* Create a key handler and also tell Aria about it */
  ArKeyHandler keyHandler;
  Aria::setKeyHandler(&keyHandler);

  /* Global escape-key handler to shut everythnig down */
  ArGlobalFunctor escapeCB(&escape);
  keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);

  /* Now that we're connected, we can run the client in a background thread, 
   * sending requests and receiving replies. When a reply to a request arrives,
   * or the server makes a request of the client, a handler functor is invoked. 
   * The handlers for this program are registered with the client by the 
   * InputHandler and OutputHandler classes (in their constructors, above) */
  client.runAsync();

  /* Create the InputHandler object and request safe-drive mode */
  InputHandler inputHandler(&client, &keyHandler);
  inputHandler.safeDrive();

  /* Use ArClientBase::dataExists() to see if the "ratioDrive" request is available on the 
   * currently connected server.  */
  if(!client.dataExists("ratioDrive") )
      printf("Warning: server does not have ratioDrive command, can not use drive commands!\n");
  else
    printf("Keys are:\nUP: Forward\nDOWN: Backward\nLEFT: Turn Left\nRIGHT: Turn Right\n");
  printf("s: Enable safe drive mode (if supported).\nu: Disable safe drive mode (if supported).\nl: list all data requests on server\n\nDrive commands use 'ratioDrive'.\nt: logs the network tracking tersely\nv: logs the network tracking verbosely\nr: resets the network tracking\n\n");


  /* Create the OutputHandler object. It will begin printing out data from the
   * server. */
  OutputHandler outputHandler(&client);


  /* Begin capturing keys into the key handler. Callbacks will be called
   * asyncrosously from this main thread when pressed.  */

  /* While the client is still running (getRunningWithLock locks the "running"
   * flag until it returns), check keys on the key handler (which will call
   * our callbacks), then tell the input handler to send drive commands. 
   * Sleep a fraction of a second as well to avoid using
   * too much CPU time, and give other threads time to work.
   */
  while (client.getRunningWithLock())
  {
    keyHandler.checkKeys();
    inputHandler.sendInput();
    ArUtil::sleep(100);
  }

  /* The client stopped running, due to disconnection from the server, general
   * Aria shutdown, or some other reason. */
  client.disconnect();
  Aria::shutdown();
  return 0;
}