本文整理汇总了C++中ArKeyHandler类的典型用法代码示例。如果您正苦于以下问题:C++ ArKeyHandler类的具体用法?C++ ArKeyHandler怎么用?C++ ArKeyHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArKeyHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
// set up our simpleConnector
ArSimpleConnector simpleConnector(&argc, argv);
// robot
ArRobot robot;
// a key handler so we can do our key handling
ArKeyHandler keyHandler;
ArLog::init(ArLog::StdOut,ArLog::Verbose);
// if there are more arguments left then it means we didn't
// understand an option
if (!simpleConnector.parseArgs() || argc > 1)
{
simpleConnector.logOptions();
keyHandler.restore();
exit(1);
}
// mandatory init
Aria::init();
ArLog::init(ArLog::StdOut, ArLog::Terse, NULL, true);
// let the global aria stuff know about it
Aria::setKeyHandler(&keyHandler);
// toss it on the robot
robot.attachKeyHandler(&keyHandler);
// set up the robot for connecting
if (!simpleConnector.connectRobot(&robot))
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
keyHandler.restore();
return 1;
}
// turn on the motors for the velocity response test
robot.comInt(ArCommands::ENABLE, 1);
velTime.setToNow();
// turn off the sonar
robot.comInt(ArCommands::SONAR, 0);
ArGlobalFunctor1<ArRobot *> userTaskCB(&userTask, &robot);
robot.addUserTask("iotest", 100, &userTaskCB);
robot.comInt(ArCommands::IOREQUEST, 1);
requestTime.setToNow();
//start the robot running, true so that if we lose connection the run stops
robot.run(true);
// now exit
Aria::shutdown();
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)
{
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: hardExit
void hardExit(void)
{
ArKeyHandler *keyHandler;
robot->disconnect();
if ((keyHandler = Aria::getKeyHandler()) != NULL)
keyHandler->restore();
else
printf("Could not restore keyboard settings.");
exit(0);
}
示例5: interact
/*!
* Interact with user on the terminal.
*/
void
interact()
{
ArMap* ariamap = advancedptr->myMap;
sleep(1);
advancedptr->getAllGoals(ariamap);
advancedptr->getAllRobotHomes(ariamap);
/// MPL
// lkeyCB();
advancedptr->myLocaTask->localizeRobotAtHomeNonBlocking();
//
// Interact with user using keyboard.
//
ArGlobalFunctor lCB(&lkeyCB);
ArGlobalFunctor pCB(&pkeyCB);
ArGlobalFunctor hCB(&hkeyCB);
ArGlobalFunctor rCB(&rkeyCB);
ArGlobalFunctor qCB(&quitCB);
ArGlobalFunctor escapeCB(&quitCB);
keyHandler.addKeyHandler('l', &lCB);
keyHandler.addKeyHandler('p', &pCB);
keyHandler.addKeyHandler('h', &hCB);
keyHandler.addKeyHandler('r', &rCB);
keyHandler.addKeyHandler('q', &qCB);
keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);
printf("Put robot at RobotHome and press 'l' to localize first.\n\
Press 'p' to move to the next goal\n\
Press 'h' to move to the first home\n\
Press 'r' to move to the goals in order\n\
Press 'q' to quit\n");
while (advancedptr->myLocaTask->getRunning() &&
advancedptr->myPathPlanningTask->getRunning()){
keyHandler.checkKeys();
ArUtil::sleep(250);
advancedptr->myRobot->lock();
ArPose rpose = advancedptr->myRobot->getPose();
double lvel = advancedptr->myRobot->getVel();
double avel = advancedptr->myRobot->getRotVel();
double volts = advancedptr->myRobot->getBatteryVoltage();
advancedptr->myRobot->unlock();
if(advancedptr->myLocaTask->getInitializedFlag()){
printf("\r%5.2f %5.2f %5.2f: %5.2f %5.2f: %4.1f\r",
rpose.getX(), rpose.getY(), rpose.getTh(), lvel, avel, volts);
fflush(stdout);
}
}
}
示例6:
AREXPORT ArMode::~ArMode()
{
ArKeyHandler *keyHandler;
if ((keyHandler = Aria::getKeyHandler()) != NULL)
{
if (myKey != '\0')
keyHandler->remKeyHandler(myKey);
if (myKey2 != '\0')
keyHandler->remKeyHandler(myKey2);
}
if (myRobot != NULL)
myRobot->remUserTask(&myUserTaskCB);
}
开发者ID:eilo,项目名称:Evolucion-Artificial-y-Robotica-Autonoma-en-Robots-Pioneer-P3-DX,代码行数:13,代码来源:ArMode.cpp
示例7: giveUpKeys
AREXPORT void ArRatioInputKeydrive::giveUpKeys(void)
{
ArKeyHandler *keyHandler;
myHaveKeys = false;
if ((keyHandler = Aria::getKeyHandler()) == NULL)
{
ArLog::log(ArLog::Terse,
"ArRatioInputKeydrive::giveUpKeys: There is no key handler, something is probably horribly wrong .");
}
// now that we have one, add our keys as callbacks, print out big
// warning messages if they fail
if (!keyHandler->remKeyHandler(&myUpCB))
ArLog::log(ArLog::Terse, "ArRatioInputKeydrive: The key handler already didn't have a key for up, something is wrong.");
if (!keyHandler->remKeyHandler(&myDownCB))
ArLog::log(ArLog::Terse, "ArRatioInputKeydrive: The key handler already didn't have a key for down, something is wrong.");
if (!keyHandler->remKeyHandler(&myLeftCB))
ArLog::log(ArLog::Terse,
"ArRatioInputKeydrive: The key handler already didn't have a key for left, something is wrong.");
if (!keyHandler->remKeyHandler(&myRightCB))
ArLog::log(ArLog::Terse,
"ArRatioInputKeydrive: The key handler already didn't have a key for right, something is wrong.");
if (!keyHandler->remKeyHandler(&mySpaceCB))
ArLog::log(ArLog::Terse,
"ArRatioInputKeydrive: The key handler didn't have a key for space, something is wrong.");
if (myRobot != NULL && myRobot->hasLatVel())
{
if (!keyHandler->remKeyHandler(&myZCB))
ArLog::log(ArLog::Terse,
"ArRatioInputKeydrive: The key handler didn't have a key for z, something is wrong.");
if (!keyHandler->remKeyHandler(&myXCB))
ArLog::log(ArLog::Terse,
"ArRatioInputKeydrive: The key handler didn't have a key for x, something is wrong.");
}
}
开发者ID:PSU-Robotics-Countess-Quanta,项目名称:Countess-Quanta-Control,代码行数:35,代码来源:ArRatioInputKeydrive.cpp
示例8: 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;
}
示例9: remKeyHandler
void ArMode::remKeyHandler(ArFunctor *functor)
{
ArKeyHandler *keyHandler;
std::string charStr;
// see if there is already a keyhandler, if not something is wrong
// (since constructor should make one if there isn't one yet
if ((keyHandler = Aria::getKeyHandler()) == NULL)
{
ArLog::log(ArLog::Terse,"ArMode '%s'::keyHandler: There should already be a key handler, but there isn't... mode won't work right.", getName());
return;
}
if (!keyHandler->remKeyHandler(functor))
ArLog::log(ArLog::Terse,
"ArMode '%s': The key handler already didn't have the given functor so the mode may not be working right.", getName());
}
开发者ID:eilo,项目名称:Evolucion-Artificial-y-Robotica-Autonoma-en-Robots-Pioneer-P3-DX,代码行数:16,代码来源:ArMode.cpp
示例10: addKeyHandlers
void addKeyHandlers()
{
ArKeyHandler *keyHandler = Aria::getKeyHandler();
if(keyHandler == NULL)
{
keyHandler = new ArKeyHandler();
Aria::setKeyHandler(keyHandler);
robot->attachKeyHandler(keyHandler);
}
//keyHandler->addKeyHandler('g', &myGoCB);
//keyHandler->addKeyHandler('c', &myGoHomeCB);
keyHandler->addKeyHandler('p', &myStartCB);
keyHandler->addKeyHandler('s', &myStopCB);
keyHandler->addKeyHandler('m', &myPrintCB);
}
示例11: takeKeys
AREXPORT void ArRatioInputKeydrive::takeKeys(void)
{
myHaveKeys = true;
ArKeyHandler *keyHandler;
if ((keyHandler = Aria::getKeyHandler()) == NULL)
{
ArLog::log(ArLog::Terse,
"ArRatioInputKeydrive::takeKeys: There is no key handler, keydrive will not work.");
}
// now that we have one, add our keys as callbacks, print out big
// warning messages if they fail
if (!keyHandler->addKeyHandler(ArKeyHandler::UP, &myUpCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for up, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::DOWN, &myDownCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for down, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::LEFT, &myLeftCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for left, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::RIGHT, &myRightCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for right, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::SPACE, &mySpaceCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for space, keydrive will not work correctly.");
if (myRobot != NULL && myRobot->hasLatVel())
{
if (!keyHandler->addKeyHandler('z', &myZCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for z, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler('Z', &myZCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for Z, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler('x', &myXCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for x, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler('X', &myXCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for x, keydrive will not work correctly.");
}
}
开发者ID:PSU-Robotics-Countess-Quanta,项目名称:Countess-Quanta-Control,代码行数:40,代码来源:ArRatioInputKeydrive.cpp
示例12: myActivateCB
/**
@param robot the robot we're attaching to
@param name the name of this mode
@param key the primary key to switch to this mode on... it can be
'\\0' if you don't want to use this
@param key2 an alternative key to switch to this mode on... it can be
'\\0' if you don't want a second alternative key
**/
AREXPORT ArMode::ArMode(ArRobot *robot, const char *name, char key,
char key2) :
myActivateCB(this, &ArMode::activate),
myDeactivateCB(this, &ArMode::deactivate),
myUserTaskCB(this, &ArMode::userTask)
{
ArKeyHandler *keyHandler;
myName = name;
myRobot = robot;
myKey = key;
myKey2 = key2;
// see if there is already a keyhandler, if not make one for ourselves
if ((keyHandler = Aria::getKeyHandler()) == NULL)
{
keyHandler = new ArKeyHandler;
Aria::setKeyHandler(keyHandler);
if (myRobot != NULL)
myRobot->attachKeyHandler(keyHandler);
else
ArLog::log(ArLog::Terse, "ArMode: No robot to attach a keyHandler to, keyHandling won't work... either make your own keyHandler and drive it yourself, make a keyhandler and attach it to a robot, or give this a robot to attach to.");
}
if (ourHelpCB == NULL)
{
ourHelpCB = new ArGlobalFunctor(&ArMode::baseHelp);
if (!keyHandler->addKeyHandler('h', ourHelpCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for 'h', ArMode will not be invoked on an 'h' keypress.");
if (!keyHandler->addKeyHandler('H', ourHelpCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for 'H', ArMode will not be invoked on an 'H' keypress.");
if (!keyHandler->addKeyHandler('?', ourHelpCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for '?', ArMode will not be invoked on an '?' keypress.");
if (!keyHandler->addKeyHandler('/', ourHelpCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for '/', ArMode will not be invoked on an '/' keypress.");
}
// now that we have one, add our keys as callbacks, print out big
// warning messages if they fail
if (myKey != '\0')
if (!keyHandler->addKeyHandler(myKey, &myActivateCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for '%c', ArMode will not work correctly.", myKey);
if (myKey2 != '\0')
if (!keyHandler->addKeyHandler(myKey2, &myActivateCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for '%c', ArMode will not work correctly.", myKey2);
// toss this mode into our list of modes
ourModes.push_front(this);
}
开发者ID:eilo,项目名称:Evolucion-Artificial-y-Robotica-Autonoma-en-Robots-Pioneer-P3-DX,代码行数:58,代码来源:ArMode.cpp
示例13: addKeyHandlers
void addKeyHandlers(ArRobot *robot)
{
ArKeyHandler *keyHandler = Aria::getKeyHandler();
if(keyHandler == NULL)
{
keyHandler = new ArKeyHandler();
Aria::setKeyHandler(keyHandler);
robot->attachKeyHandler(keyHandler);
}
keyHandler->addKeyHandler(ArKeyHandler::PAGEUP, &myUpCB);
keyHandler->addKeyHandler('u', &myUpCB);
keyHandler->addKeyHandler(ArKeyHandler::PAGEDOWN, &myDownCB);
keyHandler->addKeyHandler('d', &myDownCB);
keyHandler->addKeyHandler('o', &myOpenCB);
keyHandler->addKeyHandler('c', &myCloseCB);
keyHandler->addKeyHandler('s', &myStopCB);
}
开发者ID:eilo,项目名称:Evolucion-Artificial-y-Robotica-Autonoma-en-Robots-Pioneer-P3-DX,代码行数:17,代码来源:gripper.cpp
示例14: takeKeys
AREXPORT void ArActionKeydrive::takeKeys(void)
{
ArKeyHandler *keyHandler;
if ((keyHandler = Aria::getKeyHandler()) == NULL)
{
ArLog::log(ArLog::Terse,
"ArActionKeydrive::takeKeys: There is no key handler, keydrive will not work.");
}
// now that we have one, add our keys as callbacks, print out big
// warning messages if they fail
if (!keyHandler->addKeyHandler(ArKeyHandler::UP, &myUpCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for up, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::DOWN, &myDownCB))
ArLog::log(ArLog::Terse, "The key handler already has a key for down, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::LEFT, &myLeftCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for left, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::RIGHT, &myRightCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for right, keydrive will not work correctly.");
if (!keyHandler->addKeyHandler(ArKeyHandler::SPACE, &mySpaceCB))
ArLog::log(ArLog::Terse,
"The key handler already has a key for space, keydrive will not work correctly.");
}
示例15: main
int main(int argc, char **argv)
{
int key;
ArKeyHandler keyHandler;
Aria::init();
printf("type away... (ESC to quit)\n");
while (1)
{
//keyHandler.checkKeys();
key = keyHandler.getKey();
if(key == -1)
{
ArUtil::sleep(100);
continue;
}
printf("keyHandler.getKey() returned %d.\n", key);
switch (key) {
case ArKeyHandler::UP:
printf("Up\n");
break;
case ArKeyHandler::DOWN:
printf("Down\n");
break;
case ArKeyHandler::LEFT:
printf("Left\n");
break;
case ArKeyHandler::RIGHT:
printf("Right\n");
break;
case ArKeyHandler::ESCAPE:
printf("Escape\n");
printf("Exiting\n");
keyHandler.restore();
exit(0);
case ArKeyHandler::F1:
printf("F1\n");
break;
case ArKeyHandler::F2:
printf("F2\n");
break;
case ArKeyHandler::F3:
printf("F3\n");
break;
case ArKeyHandler::F4:
printf("F4\n");
break;
case ArKeyHandler::F5:
printf("F5\n");
break;
case ArKeyHandler::F6:
printf("F6\n");
break;
case ArKeyHandler::F7:
printf("F7\n");
break;
case ArKeyHandler::F8:
printf("F8\n");
break;
case ArKeyHandler::F9:
printf("F9\n");
break;
case ArKeyHandler::F10:
printf("F10\n");
break;
case ArKeyHandler::F11:
printf("F11\n");
break;
case ArKeyHandler::F12:
printf("F12\n");
break;
case ArKeyHandler::HOME:
printf("HOME\n");
break;
case ArKeyHandler::END:
printf("END\n");
break;
case ArKeyHandler::INSERT:
printf("INSERT\n");
break;
case ArKeyHandler::DEL:
printf("DELETE\n");
break;
case ArKeyHandler::PAGEUP:
printf("PAGEUP\n");
break;
case ArKeyHandler::PAGEDOWN:
printf("PAGEDOWN\n");
break;
case ArKeyHandler::SPACE:
printf("Space\n");
break;
case ArKeyHandler::TAB:
printf("Tab\n");
break;
case ArKeyHandler::ENTER:
printf("Enter\n");
break;
case ArKeyHandler::BACKSPACE:
printf("Backspace\n");
//.........这里部分代码省略.........