当前位置: 首页>>代码示例>>C++>>正文


C++ ArClientBase类代码示例

本文整理汇总了C++中ArClientBase的典型用法代码示例。如果您正苦于以下问题:C++ ArClientBase类的具体用法?C++ ArClientBase怎么用?C++ ArClientBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArClientBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
  char* host = "localhost";
  if(argc > 1)
    host = argv[1];
  Aria::init();
  ArClientBase client;
  ArGlobalFunctor escapeCB(&escape);
  ArKeyHandler keyHandler;
  Aria::setKeyHandler(&keyHandler);


  printf("Connecting to standaloneServerDemo at %s:%d...\n", host, 7272);
  if (!client.blockingConnect(host, 7272))
  {
    printf("Could not connect to server, exiting\n");
    exit(1);
  } 
  InputHandler inputHandler(&client, &keyHandler);
  OutputHandler outputHandler(&client);
  keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);
  client.runAsync();
  while (client.getRunningWithLock())
  {
    keyHandler.checkKeys();
    ArUtil::sleep(1);
  }
  keyHandler.restore();
  Aria::shutdown();
  return 0;
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:31,代码来源:standaloneClientDemo.cpp

示例2: main

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;
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:57,代码来源:ariaClientDriverNodesim3.cpp

示例3: main

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;
}
开发者ID:YGskty,项目名称:avoid_side_Aria,代码行数:60,代码来源:robotUpdateExample.cpp

示例4: main

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;
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:32,代码来源:clientCommandLister.cpp

示例5: main

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;

};
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:60,代码来源:cameraModeClient.cpp

示例6: ArClientHandlerCamera

 ArClientHandlerCamera(ArClientBase *client, const char *cameraName) : 
   name(cameraName), myClient(client), request(client, cameraName) ,
   myCameraInfoReplyFunc(this, &ArClientHandlerCamera::handleCameraInfoReply),
   myCameraDataReplyFunc(this, &ArClientHandlerCamera::handleCameraDataReply)
 {
   myClient->addHandler((std::string("getCameraInfo")+name).c_str(), &myCameraInfoReplyFunc);
   myClient->addHandler((std::string("getCameraData")+name).c_str(), &myCameraDataReplyFunc);
 }
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:8,代码来源:ptzCameraClientExample.cpp

示例7: main

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;

}
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:44,代码来源:modeInfoClient.cpp

示例8: drawing

void drawing(ArNetPacket *packet)
{
  int numDrawings;
  int i;
  char name[512];
  char shape[512];
  long primary, size, layer, secondary;
  unsigned long refresh;
  numDrawings = packet->bufToByte4();
  ArLog::log(ArLog::Normal, "There are %d drawings", numDrawings);
  for (i = 0; i < numDrawings; i++)
  {
    packet->bufToStr(name, sizeof(name));
    packet->bufToStr(shape, sizeof(shape));
    primary = packet->bufToByte4();
    size = packet->bufToByte4();
    layer = packet->bufToByte4();
    refresh = packet->bufToByte4();
    secondary = packet->bufToByte4();
    ArLog::log(ArLog::Normal, "name %-20s shape %-20s", name, shape);
    ArLog::log(ArLog::Normal, 
	       "\tprimary %08x size %2d layer %2d refresh %4u secondary %08x",
	       primary, size, layer, refresh, secondary);
    client.addHandler(name, &drawingDataCB);
    client.request(name, refresh);
  }
  
}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:28,代码来源:infoDrawingClient.cpp

示例9: init

bool PtzCameraExample::init()
{
  // If the server has the "getCameraList" request, then it's using
  // ArServerHandlerCameraCollection, and migth have multiple PTZs/cameras each with
  // its own set of requests. So send a "getCameraList" request, and when its
  // reply is received, the handler will send "getCameraInfo" requests for each.
  // If the server does not have "getCameraList", it only has one PTZ camera, just
  // send "getCameraInfo". The handler for that will send various control
  // commands.
  // If the server does not have "getCameraInfo", then it doesn't provide any
  // access to PTZ cameras.
  if(myClient->dataExists("getCameraList"))
  {
    ArLog::log(ArLog::Normal, "Server may have multiple cameras. Requesting list.");
    myClient->addHandler("getCameraList", &myCameraListReplyFunc);
    myClient->requestOnce("getCameraList");
  }
  else if(myClient->dataExists("getCameraInfo"))
  {
    ArLog::log(ArLog::Normal, "Server does not support multiple cameras. Requesting info for its camera.");
    ArClientHandlerCamera *camClient = new ArClientHandlerCamera(myClient, "");
    camClient->requestUpdates(100);
    mutex.lock();
    myCameras.insert(camClient);
    mutex.unlock();
  }
  else
  {
    ArLog::log(ArLog::Terse, "Error, server does not have any camera control requests. (Was the server run with video features enabled or video forwarding active?)");
    return false;
  }
  return true;
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:33,代码来源:ptzCameraClientExample.cpp

示例10: space

void InputHandler::space(void)
{
  ArNetPacket packet;
  packet.doubleToBuf(0.00001);
  myClient->requestOnce("setVel", &packet);
  myClient->requestOnce("deltaHeading", &packet);
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:7,代码来源:standaloneClientDemo.cpp

示例11:

/** 
 Stop the robot 
*/
JNIEXPORT jint JNICALL Java_com_adept_arandroid_ArjRobot_stop
  (JNIEnv *env, jobject obj)
{
	debugPrint("Stopping robot");
	myClient.requestOnce("stop");
	return 1;
}
开发者ID:Aharobot,项目名称:ArAndroidApp,代码行数:10,代码来源:native_ArjRobot.cpp

示例12: requestPanTiltAbs

bool ArNetCameraRequest::requestPanTiltAbs(double pan, double tilt)
{
  empty();
  byte2ToBuf((ArTypes::Byte2)(pan * 1000.0));
  byte2ToBuf((ArTypes::Byte2)(tilt * 1000.0));
  finalizePacket();
  return myClient->requestOnce(myAbsReqName.c_str(), this);
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:8,代码来源:ptzCameraClientExample.cpp

示例13: main

int main(int argc, char **argv)
{

  std::string hostname;
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);

  if (argc == 1)
    hostname = "localhost";
  else
    hostname = argv[1];
  if (!client.blockingConnect(hostname.c_str(), 7272))
  {
    printf("Could not connect to server, exiting\n");
    exit(1);
  } 

  
  /*
  ArGlobalFunctor1<ArNetPacket *> getDirListingCB(&getDirListing);
  client.addHandler("getDirListing", &getDirListingCB);
  //client.requestOnceWithString("getDirListing", "");

  ArGlobalFunctor1<ArNetPacket *> getFileCB(&netGetFile);
  client.addHandler("getFile", &getFileCB);
  client.requestOnceWithString("getFile", "all.bob");

  ArGlobalFunctor1<ArNetPacket *> netPutFileCB(&netPutFile);
  client.addHandler("putFile", &netPutFileCB);
  putFile("doxygen.conf", "ArGH/DoxYGEN");
  */

  ArGlobalFunctor1<ArNetPacket *> deleteFileCB(&netDeleteFile);
  client.addHandler("deleteFile", &deleteFileCB);
  client.requestOnceWithString("deleteFile", "1/all.bob");

  client.runAsync();

  while (client.getRunningWithLock())
  {
    ArUtil::sleep(1);
  }
  Aria::shutdown();
  return 0;

}
开发者ID:sauver,项目名称:sauver_sys,代码行数:46,代码来源:fileClientRaw.cpp

示例14: drawingData

void drawingData(ArNetPacket *packet)
{
  int x, y;
  int numReadings;
  int i;

  numReadings = packet->bufToByte4();

  if (numReadings == 0)
  {
    printf("No readings for sensor %s\n", client.getName(packet));
  }
  printf("Readings for %s:", client.getName(packet));
  for (i = 0; i < numReadings; i++)
  {
    x = packet->bufToByte4();
    y = packet->bufToByte4();
    printf(" (%d %d)", x, y);
  }
  printf("\n\n");
}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:21,代码来源:infoDrawingClient.cpp

示例15: OutputHandler

/** 
 Initialize the robot connection 
*/
JNIEXPORT jint JNICALL Java_com_adept_arandroid_ArjRobot_initialize
  (JNIEnv *env, jobject obj, jstring host, jint port)
{
	// Get the host ip address
	const char *cHost = env->GetStringUTFChars(host, 0);
	
	// Try to connect
	Aria::init();
  ArLog::setFunctor(new ArGlobalFunctor1<const char*>(ariaLogDebugPrint));
	debugPrintS("Connecting to ", cHost);
	if (!myClient.blockingConnect(cHost, port, true, NULL, NULL, NULL)) {
		debugPrint("Error connecting");
		return -1;
	}
	debugPrint("Connected");
	
	// Run the client connection in a different thread  
	myClient.runAsync();
	
	// Download the map, maybe move this to it's own function later
	debugPrint("getting map");
	myClient.requestOnce("getMapBinary");
	
	// Create the OutputHandler
	myOutputHandler = new OutputHandler(&myClient);
	
	/* Block until the connection is closed.  We will use this time to get
	 * status update information at a regular rate. */
	myShutdown = false;
	while (myClient.getRunningWithLock() && !myShutdown) {
    ArUtil::sleep(100);
    myServerStatus = myOutputHandler->getServerStatus();
    myOutputHandler->getRobotStatus(myRobotStatus);
  }
  debugPrint("Shutting down Aria");
  myClient.disconnect();
  Aria::shutdown();
  return 0;
}
开发者ID:Aharobot,项目名称:ArAndroidApp,代码行数:42,代码来源:native_ArjRobot.cpp


注:本文中的ArClientBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。