本文整理汇总了C++中ArClientBase::runAsync方法的典型用法代码示例。如果您正苦于以下问题:C++ ArClientBase::runAsync方法的具体用法?C++ ArClientBase::runAsync怎么用?C++ ArClientBase::runAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArClientBase
的用法示例。
在下文中一共展示了ArClientBase::runAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: main
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;
}
示例6: main
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;
}
示例7: main
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;
}
示例8: main
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;
}
示例9: main
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;
}
示例10: 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;
}
示例11: main
int main(int argc, char **argv)
{
ArClientBase client;
ArGlobalFunctor1<ArNetPacket *> testCB(&test);
Aria::init();
//ArLog::init(ArLog::StdOut, ArLog::Verbose);
ArTime startTime;
startTime.setToNow();
if (!client.blockingConnect("localhost", 7273))
{
printf("Could not connect to server, exiting\n");
exit(1);
}
printf("Took %ld msec to connect\n", startTime.mSecSince());
client.runAsync();
client.lock();
client.addHandler("test", &testCB);
client.addHandler("test2", &testCB);
client.addHandler("test3", &testCB);
client.logDataList();
client.requestOnce("test");
client.request("test2", 100);
client.request("test3", -1);
client.unlock();
ArUtil::sleep(1000);
printf("Changing speed\n");
client.lock();
client.request("test2", 300);
client.unlock();
ArUtil::sleep(1000);
client.lock();
client.requestStop("test2");
client.unlock();
ArUtil::sleep(1000);
client.lock();
client.disconnect();
client.unlock();
ArUtil::sleep(50);
exit(0);
}
示例12: 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;
}
示例13: 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;
}
示例14: main
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;
}
示例15: main
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;
}