本文整理汇总了C++中ArServerBase类的典型用法代码示例。如果您正苦于以下问题:C++ ArServerBase类的具体用法?C++ ArServerBase怎么用?C++ ArServerBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArServerBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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;
}
示例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();
ArGlobalFunctor2<ArServerClient *, ArNetPacket *> testCB(&testFunction);
ArGlobalFunctor2<ArServerClient *, ArNetPacket *> setVelCB(&setVelFunction);
ArServerBase server;
//ArLog::init(ArLog::StdOut, ArLog::Verbose);
ArNetPacket packet;
server.addData("test", "some wierd test", &testCB, "none", "none");
server.addData("test2", "another wierd test", &testCB, "none", "none");
server.addData("test3", "yet another wierd test", &testCB, "none", "none");
server.addData("SetVelRequest", "yet another wierd test", &setVelCB, "none", "none");
if (!server.open(7273))
{
printf("Could not open server port\n");
exit(1);
}
server.runAsync();
while (server.getRunningWithLock())
{
ArUtil::sleep(1000);
server.broadcastPacketTcp(&packet, "test3");
}
Aria::shutdown();
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);
}
server.run();
return 0;
}
示例6: 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();
}
示例7: main
int main(int argc, char *argv[])
{
Aria::init();
ArVideo::init();
ArArgumentParser argParser(&argc, argv);
ArServerBase server;
ArServerSimpleOpener openServer(&argParser);
argParser.loadDefaultArguments();
if(!Aria::parseArgs() || !argParser.checkHelpAndWarnUnparsed()) {
Aria::logOptions();
Aria::exit(-1);
}
if(!openServer.open(&server))
{
std::cout << "error opening ArNetworking server" << std::endl;
Aria::exit(5);
return 5;
}
server.runAsync();
std::cout << "ArNetworking server running on port " << server.getTcpPort() << std::endl;
/* Set up ArNetworking services */
ArVideoRemoteForwarder forwarder(&server, "localhost", 7070);
if(!forwarder.connected())
{
std::cout << "ERror connecting to server localhost:7070" << std::endl;
Aria::exit(1);
}
std::cout << "ArNetworking server running on port " << server.getTcpPort() << std::endl;
while(true) ArUtil::sleep(10000);
Aria::exit(0);
return 0;
}
示例8: 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();
}
示例9: 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);
}
示例10: main
int main(int argc, char **argv)
{
// Initialize Aria and Arnl global information
Aria::init();
Arnl::init();
// You can change default ArLog options in this call, but the settings in the parameter file
// (arnl.p) which is loaded below (Aria::getConfig()->parseFile()) will override the options.
//ArLog::init(ArLog::File, ArLog::Normal, "log.txt", true, true);
// Used to parse the command line arguments.
ArArgumentParser parser(&argc, argv);
// Load default arguments for this computer (from /etc/Aria.args, environment
// variables, and other places)
parser.loadDefaultArguments();
#ifdef ARNL_LASER
// Tell the laser connector to always connect the first laser since
// this program always requires a laser.
parser.addDefaultArgument("-connectLaser");
#endif
// The robot object
ArRobot robot;
// handle messages from robot controller firmware and log the contents
robot.addPacketHandler(new ArGlobalRetFunctor1<bool, ArRobotPacket*>(&handleDebugMessage));
// This object is used to connect to the robot, which can be configured via
// command line arguments.
ArRobotConnector robotConnector(&parser, &robot);
// Connect to the robot
if (!robotConnector.connectRobot())
{
ArLog::log(ArLog::Normal, "Error: Could not connect to robot... exiting");
Aria::exit(3);
}
// Set up where we'll look for files. Arnl::init() set Aria's default
// directory to Arnl's default directory; addDirectories() appends this
// "examples" directory.
char fileDir[1024];
ArUtil::addDirectories(fileDir, sizeof(fileDir), Aria::getDirectory(),
"examples");
// To direct log messages to a file, or to change the log level, use these calls:
//ArLog::init(ArLog::File, ArLog::Normal, "log.txt", true, true);
//ArLog::init(ArLog::File, ArLog::Verbose);
// Add a section to the configuration to change ArLog parameters
ArLog::addToConfig(Aria::getConfig());
// set up a gyro (if the robot is older and its firmware does not
// automatically incorporate gyro corrections, then this object will do it)
ArAnalogGyro gyro(&robot);
// Our networking server
ArServerBase server;
#ifdef ARNL_GPSLOC
// GPS connector.
ArGPSConnector gpsConnector(&parser);
#endif
// Set up our simpleOpener, used to set up the networking server
ArServerSimpleOpener simpleOpener(&parser);
#ifdef ARNL_LASER
// the laser connector
ArLaserConnector laserConnector(&parser, &robot, &robotConnector);
#endif
// used to connect to camera PTZ control
ArPTZConnector ptzConnector(&parser, &robot);
#ifdef ARNL_MULTIROBOT
// Used to connect to a "central server" which can be used as a proxy
// for multiple robot servers, and as a way for them to also communicate with
// each other. (objects implementing some of these inter-robot communication
// features are created below).
// NOTE: If the central server is running on the same host as robot server(s),
// then you must use the -serverPort argument to instruct these robot-control
// server(s) to use different ports than the default 7272, since the central
// server will use that port.
ArClientSwitchManager clientSwitch(&server, &parser);
#endif
// Load default arguments for this computer (from /etc/Aria.args, environment
// variables, and other places)
parser.loadDefaultArguments();
// Parse arguments
//.........这里部分代码省略.........
示例11: main
int main(int argc, char **argv)
{
//----------------------initialized robot server------------------------------------------
Aria::init();
Arnl::init();
ArServerBase server;
//-----------------------------------------------------------------------------------
VCCHandler ptz(&robot); //create keyboard for control vcc50i
G_PTZHandler->reset();
ArUtil::sleep(300);
G_PTZHandler->panSlew(30);
//-----------------------------------------------------------------------------------
argc = 2 ;
argv[0] = "-map";
argv[1] = "map20121111.map";
// Parse the command line arguments.
ArArgumentParser parser(&argc, argv);
// Set up our simpleConnector
ArSimpleConnector simpleConnector(&parser);
// Set up our simpleOpener
ArServerSimpleOpener simpleOpener(&parser);
//*******
// Set up our client for the central server
// ArClientSwitchManager clientSwitch(&server, &parser);
//************
// Load default arguments for this computer (from /etc/Aria.args, environment
// variables, and other places)
// parser.loadDefaultArguments();
// set up a gyro
ArAnalogGyro gyro(&robot);
//gyro.activate();
// Parse arguments for the simple connector.
// if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
// {
// ArLog::log(ArLog::Normal, "\nUsage: %s -map mapfilename\n", argv[0]);
// Aria::logOptions();
// Aria::exit(1);
// }
// The laser object, will be used if we have one
// Add the laser to the robot
robot.addRangeDevice(&sick);
// Sonar, must be added to the robot, used by teleoperation and wander to
// detect obstacles, and for localization if SONARNL
ArSonarDevice sonarDev;
// Add the sonar to the robot
robot.addRangeDevice(&sonarDev);
// Set up where we'll look for files
char fileDir[1024];
ArUtil::addDirectories(fileDir, sizeof(fileDir), "./", "maps");
ArLog::log(ArLog::Normal, "Installation directory is: %s\nMaps directory is: %s\n", Aria::getDirectory(), fileDir);
// Set up the map, this will look for files in the examples
// directory (unless the file name starts with a /, \, or .
// You can take out the 'fileDir' argument to look in the current directory
// instead
ArMap arMap(fileDir);
// set it up to ignore empty file names (otherwise the parseFile
// on the config will fail)
arMap.setIgnoreEmptyFileName(true);
//********************************
//Localization
//********************************
ArLocalizationManager locManager(&robot, &arMap);
ArLog::log(ArLog::Normal, "Creating laser localization task");
ArLocalizationTask locTask (&robot, &sick, &arMap);
locManager.addLocalizationTask(&locTask);
//*******************************
//Path planning
//*******************************
// Make the path task planning task
ArPathPlanningTask pathTask(&robot, &sick, &sonarDev, &arMap);
G_PathPlanning = &pathTask;
//.........这里部分代码省略.........
示例12: main
int main(int argc, char **argv)
{
Aria::init();
ArRobot robot;
ArSonarDevice sonar;
ArSick sick;
robot.addRangeDevice(&sonar);
ArServerBase server;
// Argument parser:
ArArgumentParser parser(&argc, argv);
parser.loadDefaultArguments();
// Connector and server opener:
ArRobotConnector robotConnector(&parser, &robot);
if(!robotConnector.connectRobot())
{
ArLog::log(ArLog::Terse, "popupExample: Could not connect to the robot.");
if(parser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
}
Aria::exit(1);
}
ArLaserConnector laserConnector(&parser, &robot, &robotConnector);
ArServerSimpleOpener simpleOpener(&parser);
// Get command-line and other parameters
if(!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
Aria::exit(1);
}
robot.runAsync(true);
// connect to the laser
if(!laserConnector.connectLasers())
{
ArLog::log(ArLog::Normal, "popupExample: Warning: Could not connect to lasers.");
}
// Open the server
if(!simpleOpener.open(&server))
{
ArLog::log(ArLog::Terse, "popupExample: Error, could not open server.");
return 1;
}
server.runAsync();
ArLog::log(ArLog::Normal, "popupExample: Server running. Press control-C to exit.");
ArLog::log(ArLog::Normal, "popupExample: Each time an obstacle is detected near the robot, a new popup message will be created. Connect with MobileEyes to see them.");
// Sends robot position etc.
ArServerInfoRobot robotInfoServer(&server, &robot);
// This service sends drawings e.g. showing range device positions
ArServerInfoDrawings drawingsServer(&server);
drawingsServer.addRobotsRangeDevices(&robot);
// This service can send messages to clients to display as popup dialogs:
ArServerHandlerPopup popupServer(&server);
// This object contains the robot sensor interpretation task and creates
// popups:
SensorDetectPopup(&robot, &popupServer);
// modes for controlling robot movement
ArServerModeStop modeStop(&server, &robot);
ArServerModeRatioDrive modeRatioDrive(&server, &robot);
ArServerModeWander modeWander(&server, &robot);
modeStop.addAsDefaultMode();
modeStop.activate();
// allow configuration of driving and other settings
ArServerHandlerConfig serverHandlerConfig(&server, Aria::getConfig()); // make a config handler
ArLog::addToConfig(Aria::getConfig()); // let people configure logging
modeRatioDrive.addToConfig(Aria::getConfig(), "Teleop settings"); // able to configure teleop settings
robot.enableMotors();
robot.waitForRunExit();
Aria::exit(0);
}
示例13: main
int main ( int argc, char *argv[] ){
//cout << "running....\n";
try{
// Create the socket
ServerSocket server ( 30000 );
Aria::init();
Arnl::init();
ArRobot robot;
ArArgumentParser parser(&argc, argv);
parser.loadDefaultArguments();
ArSonarDevice sonar;
ArSimpleConnector simpleConnector(&parser);
// Our server for mobile eyes
ArServerBase moServer;
// Set up our simpleOpener
ArServerSimpleOpener simpleOpener(&parser);
parser.loadDefaultArguments();
if (!Aria::parseArgs () || !parser.checkHelpAndWarnUnparsed()){
Aria::logOptions ();
Aria::exit (1);
}
//Add the sonar to the robot
robot.addRangeDevice(&sonar);
// Look for map in the current directory
ArMap arMap;
// set it up to ignore empty file names (otherwise the parseFile
// on the config will fail)
arMap.setIgnoreEmptyFileName (true);
// First open the server
if (!simpleOpener.open(&moServer)){
if (simpleOpener.wasUserFileBad())
ArLog::log(ArLog::Normal, "Bad user file");
else
ArLog::log(ArLog::Normal, "Could not open server port");
exit(2);
}
// Connect to the robot
if (!simpleConnector.connectRobot (&robot)){
ArLog::log (ArLog::Normal, "Could not connect to robot... exiting");
Aria::exit (3);
}
// Create the localization task (it will start its own thread here)
ArSonarLocalizationTask locTask(&robot, &sonar, &arMap);
ArLocalizationManager locManager(&robot, &arMap);
ArLog::log(ArLog::Normal, "Creating sonar localization task");
locManager.addLocalizationTask(&locTask);
// Set the initial pose to the robot's "Home" position from the map, or
// (0,0,0) if none, then let the localization thread take over.
locTask.localizeRobotAtHomeNonBlocking();
//Create the path planning task
ArPathPlanningTask pathTask(&robot,&sonar,&arMap);
ArLog::log(ArLog::Normal, "Robot Server: Connected.");
robot.enableMotors();
robot.clearDirectMotion();
// Start the robot processing cycle running in the background.
// True parameter means that if the connection is lost, then the
// run loop ends.
robot.runAsync(true);
// Read in parameter files.
Aria::getConfig ()->useArgumentParser (&parser);
if (!Aria::getConfig ()->parseFile (Arnl::getTypicalParamFileName ())){
ArLog::log (ArLog::Normal, "Trouble loading configuration file, exiting");
Aria::exit (5);
}
//Create the three states
robot.lock();
Follow follow = Follow(&robot,&sonar);
GoTo goTo(&robot,&pathTask,&arMap);
Search s(&robot,&sonar);
// Bumpers.
ArBumpers bumpers;
robot.addRangeDevice(&bumpers);
pathTask.addRangeDevice(&bumpers, ArPathPlanningTask::CURRENT);
// Forbidden regions from the map
ArForbiddenRangeDevice forbidden(&arMap);
robot.addRangeDevice(&forbidden);
//.........这里部分代码省略.........
示例14: main
int
main(int argc, char *argv[])
{
// Initialize location of Aria, Arnl and their args.
Aria::init();
Arnl::init();
// The robot object
ArRobot robot;
#ifndef SONARNL
// The laser object
ArSick sick(181, 361);
#endif
// Parse them command line arguments.
ArArgumentParser parser(&argc, argv);
// Set up our simpleConnector
ArSimpleConnector simpleConnector(&parser);
// Load default arguments for this computer
parser.loadDefaultArguments();
// Parse its arguments for the simple connector.
simpleConnector.parseArgs();
// sonar, must be added to the robot, for teleop and wander
ArSonarDevice sonarDev;
// add the sonar to the robot
robot.addRangeDevice(&sonarDev);
ArMap arMap;
#ifndef SONARNL
// Initialize the localization
ArLocalizationTask locTask(&robot, &sick, &arMap);
// Make the path task
ArPathPlanningTask pathTask(&robot, &sick, &sonarDev, &arMap);
#else
// Initialize the localization
ArSonarLocalizationTask locTask(&robot, &sonarDev, &arMap);
// Make the path task
ArPathPlanningTask pathTask(&robot, NULL, &sonarDev, &arMap);
#endif
// Stop the robot as soon as localization fails.
ArFunctor1C<ArPathPlanningTask, int>
locaFailed(&pathTask, &ArPathPlanningTask::trackingFailed);
locTask.addFailedLocalizationCB(&locaFailed);
// Read in param files.
Aria::getConfig()->useArgumentParser(&parser);
if (!Aria::getConfig()->parseFile(Arnl::getTypicalParamFileName()))
{
printf("Trouble loading configuration file, exiting\n");
exit(1);
}
// Warn about unknown params.
if (!parser.checkHelpAndWarnUnparsed())
{
printf("\nUsage: %s -map mapfilename\n\n", argv[0]);
simpleConnector.logOptions();
exit(2);
}
// 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.
//.........这里部分代码省略.........
示例15: main
int main(int argc, char **argv)
{
Aria::init();
ArRobot robot;
ArServerBase server;
ArArgumentParser parser(&argc, argv);
ArSimpleConnector simpleConnector(&parser);
ArServerSimpleOpener simpleOpener(&parser);
// parse the command line... fail and print the help if the parsing fails
// or if help was requested
parser.loadDefaultArguments();
if (!simpleConnector.parseArgs() || !simpleOpener.parseArgs() ||
!parser.checkHelpAndWarnUnparsed())
{
simpleConnector.logOptions();
simpleOpener.logOptions();
exit(1);
}
// Set up where we'll look for files such as config file, user/password file,
// etc.
char fileDir[1024];
ArUtil::addDirectories(fileDir, sizeof(fileDir), Aria::getDirectory(),
"ArNetworking/examples");
// first open the server up
if (!simpleOpener.open(&server, fileDir, 240))
{
if (simpleOpener.wasUserFileBad())
printf("Error: Bad user/password/permissions file.\n");
else
printf("Error: Could not open server port. Use -help to see options.\n");
exit(1);
}
// Devices
ArAnalogGyro gyro(&robot);
ArSonarDevice sonarDev;
robot.addRangeDevice(&sonarDev);
ArIRs irs;
robot.addRangeDevice(&irs);
ArBumpers bumpers;
robot.addRangeDevice(&bumpers);
ArSick sick(361, 180);
robot.addRangeDevice(&sick);
ArServerInfoRobot serverInfoRobot(&server, &robot);
ArServerInfoSensor serverInfoSensor(&server, &robot);
// This is the service that provides drawing data to the client.
ArServerInfoDrawings drawings(&server);
// Convenience function that sets up drawings for all the robot's current
// range devices (using default shape and color info)
drawings.addRobotsRangeDevices(&robot);
// Add our custom drawings
drawings.addDrawing(
// shape: color: size: layer:
new ArDrawingData("polyLine", ArColor(255, 0, 0), 2, 49),
"exampleDrawing_Home",
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleHomeDrawingNetCallback)
);
drawings.addDrawing(
new ArDrawingData("polyDots", ArColor(0, 255, 0), 250, 48),
"exampleDrawing_Dots",
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleDotsDrawingNetCallback)
);
drawings.addDrawing(
new ArDrawingData("polySegments", ArColor(0, 0, 0), 4, 52),
"exampleDrawing_XMarksTheSpot",
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleXDrawingNetCallback)
);
drawings.addDrawing(
new ArDrawingData("polyArrows", ArColor(255, 0, 255), 500, 100),
"exampleDrawing_Arrows",
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleArrowsDrawingNetCallback)
);
// modes for moving the robot
ArServerModeStop modeStop(&server, &robot);
ArServerModeDrive modeDrive(&server, &robot);
ArServerModeRatioDrive modeRatioDrive(&server, &robot);
ArServerModeWander modeWander(&server, &robot);
modeStop.addAsDefaultMode();
modeStop.activate();
// Connect to the robot.
if (!simpleConnector.connectRobot(&robot))
//.........这里部分代码省略.........