本文整理汇总了C++中ArRobot::addPacketHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ ArRobot::addPacketHandler方法的具体用法?C++ ArRobot::addPacketHandler怎么用?C++ ArRobot::addPacketHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArRobot
的用法示例。
在下文中一共展示了ArRobot::addPacketHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
ArRobot robot;
Aria::init();
ArSimpleConnector connector(&argc, argv);
if (!Aria::parseArgs())
{
Aria::logOptions();
Aria::shutdown();
return 1;
}
if (!connector.connectRobot(&robot))
{
ArLog::log(ArLog::Normal, "robotPacketHandlerTest: Could not connect to robot... exiting");
return 2;
}
ArLog::log(ArLog::Normal, "robotPacketHandlerTest: Connected.");
robot.addPacketHandler(new ArGlobalRetFunctor1<bool, ArRobotPacket*>(&testcb), ArListPos::FIRST);
robot.run(true);
return 0;
}
示例2: 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
//.........这里部分代码省略.........