本文整理汇总了C++中ArServerBase::run方法的典型用法代码示例。如果您正苦于以下问题:C++ ArServerBase::run方法的具体用法?C++ ArServerBase::run怎么用?C++ ArServerBase::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArServerBase
的用法示例。
在下文中一共展示了ArServerBase::run方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
Aria::init();
ArServerBase server;
//ArLog::init(ArLog::StdOut, ArLog::Verbose);
ArConfig *config;
config = Aria::getConfig();
ArRobotP3DX dx;
//dx.writeFile("dx.txt");
*Aria::getConfig() = dx;
//Aria::getConfig()->writeFile("dxcopy.txt");
if (!server.open(7272))
{
printf("Could not open server port\n");
exit(1);
}
ArServerHandlerConfig configHandler(&server, Aria::getConfig());
server.run();
Aria::shutdown();
return 0;
}
示例2: main
int main(int argc, char **argv)
{
Aria::init();
ArServerBase server;
if (!server.open(7272))
{
printf("Could not open server port\n");
exit(1);
}
ArServerHandlerCommands commands(&server);
commands.addCommand("Function1", "Call the function that is number 1!",
new ArGlobalFunctor(&function1));
commands.addCommand("Function2", "Second function to call",
new ArGlobalFunctor(&function2));
commands.addCommand("Function3", "Tree climb",
new ArGlobalFunctor(&function3));
commands.addStringCommand("StringFunction4",
"Print a string in function 4",
new ArGlobalFunctor1<
ArArgumentBuilder *>(&function4));
commands.addStringCommand("StringFunction5",
"Prints a string given (5)",
new ArGlobalFunctor1<
ArArgumentBuilder *>(&function5));
commands.addStringCommand("StringFunction6",
"Print out a value for function 6",
new ArGlobalFunctor1<
ArArgumentBuilder *>(&function6));
server.run();
}
示例3: main
int main(int argc, char **argv)
{
Aria::init();
ArServerBase server;
ArConfig *config;
config = Aria::getConfig();
std::string section;
char joy[512];
sprintf(joy, "Joy");
section = "section1";
config->addParam(ArConfigArg("int", new int, "fun int", 0), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("bool", new bool, "fun bool"), section.c_str(), ArPriority::IMPORTANT);
config->addParam(ArConfigArg("string", joy, "fun string", sizeof(joy)), section.c_str(), ArPriority::TRIVIAL);
section = "section8";
config->addParam(ArConfigArg("int", new int, "fun int", 0), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("doubleFOUR", (double).4, "fun double", 0.0, 1.0), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("double three", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("double two", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("double one", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("bool", new bool, "fun bool"), section.c_str(), ArPriority::IMPORTANT);
config->addParam(ArConfigArg("string", joy, "fun string", sizeof(joy)), section.c_str(), ArPriority::TRIVIAL);
section = "some section";
config->setSectionComment("some section", "this is a random section with 4 ints");
config->addParam(ArConfigArg("int1", new int, "fun int"), section.c_str(), ArPriority::TRIVIAL);
config->addParam(ArConfigArg("int2", new int, "fun int", -1, 1200), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("int3", new int, "fun int"), section.c_str(), ArPriority::IMPORTANT);
config->addParam(ArConfigArg("int4", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("int4", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("int1", new int, "fun int"), section.c_str(), ArPriority::TRIVIAL);
section = "another section";
config->setSectionComment("another section", "this is another section with 1 of each type");
config->addParam(ArConfigArg("inta", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("doublea", new double, "fun double"), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("boola", new bool, "fun bool"), section.c_str(), ArPriority::NORMAL);
config->addParam(ArConfigArg("stringa", new char[512], "fun string", 512), section.c_str(), ArPriority::NORMAL);
if (!server.open(7272))
{
printf("Could not open server port\n");
exit(1);
}
config->setBaseDirectory("./");
config->writeFile("default.txt");
config->parseFile("modified.txt");
config->writeFile("modifiedModified.txt");
ArServerHandlerConfig configHandler(&server, Aria::getConfig(),
"default.txt");
server.run();
Aria::shutdown();
return 0;
}
示例4: main
int main(int argc, char **argv)
{
Aria::init();
ArServerBase server;
if (!server.open(7272))
{
printf("Could not open server port\n");
exit(1);
}
server.run();
return 0;
}
示例5: main
int main(int argc, char **argv)
{
Aria::init();
ArServerBase server;
if (!server.open(7272))
{
printf("Could not open server port\n");
exit(1);
}
ArServerFileLister fileLister(&server, ".");
ArServerFileToClient fileToClient(&server, ".");
ArServerFileFromClient fileFromClient(&server, ".", "/tmp");
ArServerDeleteFileOnServer fileDeleter(&server, ".");
server.run();
}
示例6: main
int main(int argc, char **argv)
{
Aria::init();
ArServerBase robotServer;
if (!robotServer.open(5000))
{
printf("Could not open robot server port\n");
Aria::exit(1);
}
ArServerBase clientServer;
if (!clientServer.open(7272))
{
printf("Could not open robot server port\n");
Aria::exit(1);
}
ArCentralManager switchManager(&robotServer, &clientServer);
switchManager.addForwarderAddedCallback(
new ArGlobalFunctor1<ArCentralForwarder *>(&forwarderAdded),
100);
switchManager.addForwarderRemovedCallback(
new ArGlobalFunctor1<ArCentralForwarder *>(&forwarderRemoved),
100);
// Start a small handler to monitor communication between the server and
// client.
ArServerHandlerCommMonitor commMonitor(&clientServer);
ArServerHandlerCommands commands(&clientServer);
commands.setPrefix("CentralServer");
ArServerSimpleServerCommands serverCommands(&commands, &clientServer,
false);
commands.addCommand(
"NetworkLogConnections", "Logs the connections to the central server, and to all the forwarded connections",
new ArFunctorC<ArCentralManager>
(&switchManager, &ArCentralManager::logConnections));
clientServer.runAsync();
robotServer.run();
Aria::exit(0);
}
示例7: main
int main(int argc, char **argv)
{
Aria::init();
ArServerBase server;
ArGlobalFunctor2<ArServerClient *, ArNetPacket *> sendEmptyCB(&sendEmpty);
if (!server.open(7272))
{
printf("Could not open server port\n");
exit(1);
}
ArServerInfoDrawings drawing(&server);
ArDrawingData arrows("polyarrow", ArColor(0, 0, 255), 5, 50);
ArDrawingData dots("polydots", ArColor(0, 255, 0), 12, 50);
drawing.addDrawing(&arrows, "arrows", &sendEmptyCB);
drawing.addDrawing(&dots, "dots", &sendEmptyCB);
server.run();
}
示例8: sick
//.........这里部分代码省略.........
// Our server
ArServerBase server;
// First open the server up
if (!server.open(7272))
{
printf("Could not open server port\n");
exit(1);
}
// Connect the robot
if (!simpleConnector.connectRobot(&robot))
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
return 1;
}
robot.com2Bytes(31, 14, 0);
robot.com2Bytes(31, 15, 0);
ArUtil::sleep(100);
robot.com2Bytes(31, 14, 1);
robot.com2Bytes(31, 15, 1);
robot.enableMotors();
robot.clearDirectMotion();
#ifndef SONARNL
// Set up the laser before handing it to the laser mode
simpleConnector.setupLaser(&sick);
// Add the laser to the robot
robot.addRangeDevice(&sick);
#endif
// Start the robot thread.
robot.runAsync(true);
#ifndef SONARNL
// Start the laser thread.
sick.runAsync();
// Connect the laser
if (!sick.blockingConnect())
{
printf("Couldn't connect to sick, exiting\n");
Aria::shutdown();
return 1;
}
#endif
ArUtil::sleep(300);
// If you want to set the number of samples change the line below
locTask.setNumSamples(2000);
// Localize the robot to home
if(locTask.localizeRobotAtHomeBlocking())
{
printf("Successfully localized at home.\n");
}
else
{
printf("WARNING: Unable to localize at home position!\n");
}
robot.lock();
// attach stuff to the server
ArServerInfoRobot serverInfoRobot(&server, &robot);
ArServerInfoSensor serverInfoSensor(&server, &robot);
ArServerInfoPath serverInfoPath(&server, &robot, &pathTask);
ArServerInfoLocalization serverInfoLocalization(&server, &robot, &locTask);
#ifndef SONARNL
// Set it up to handle maps.
ArServerHandlerMap serverMap(&server, &arMap, ArServerHandlerMap::POINTS);
#else
ArServerHandlerMap serverMap(&server, &arMap, ArServerHandlerMap::LINES);
#endif
// Set up a service that allows the client to monitor the communication
// between the robot and the client.
//
ArServerHandlerCommMonitor serverCommMonitor(&server);
//ArServerModeGoto modeGoto(&server, &robot, &pathTask);
//ArServerModeStop modeStop(&server, &robot);
//ArServerModeDrive modeDrive(&server, &robot);
SimpleTask simpleTask(&robot, &pathTask);
robot.unlock();
// Read in param files.
Aria::getConfig()->parseFile(Arnl::getTypicalParamFileName());
// Now let it spin off in its own thread
server.run();
exit(0);
}