本文整理汇总了C++中ArClientBase::setRobotName方法的典型用法代码示例。如果您正苦于以下问题:C++ ArClientBase::setRobotName方法的具体用法?C++ ArClientBase::setRobotName怎么用?C++ ArClientBase::setRobotName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArClientBase
的用法示例。
在下文中一共展示了ArClientBase::setRobotName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
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;
}
示例3: 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;
}
示例4: 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;
}
示例5: main
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);
}
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
*/
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",);
示例7: 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();
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;
}