本文整理汇总了C++中ArRobot::run方法的典型用法代码示例。如果您正苦于以下问题:C++ ArRobot::run方法的具体用法?C++ ArRobot::run怎么用?C++ ArRobot::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArRobot
的用法示例。
在下文中一共展示了ArRobot::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
// 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;
}
示例3: main
int main(int argc, char** argv)
{
Aria::init();
ArArgumentParser parser(&argc, argv);
parser.loadDefaultArguments();
ArRobot robot;
ArSonarDevice sonar;
// Connect to the robot, get some initial data from it such as type and name,
// and then load parameter files for this robot.
ArRobotConnector robotConnector(&parser, &robot);
if(!robotConnector.connectRobot())
{
ArLog::log(ArLog::Terse, "actionExample: Could not connect to the robot.");
if(parser.checkHelpAndWarnUnparsed())
{
// -help not given
Aria::logOptions();
Aria::exit(1);
}
}
if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
Aria::exit(1);
}
ArLog::log(ArLog::Normal, "actionExample: Connected to robot.");
// Create instances of the actions defined above, plus ArActionStallRecover,
// a predefined action from Aria.
ActionGo go(500, 350);
ActionTurn turn(400, 10);
ArActionStallRecover recover;
// Add the range device to the robot. You should add all the range
// devices and such before you add actions
robot.addRangeDevice(&sonar);
// Add our actions in order. The second argument is the priority,
// with higher priority actions going first, and possibly pre-empting lower
// priority actions.
robot.addAction(&recover, 100);
robot.addAction(&go, 50);
robot.addAction(&turn, 49);
// Enable the motors, disable amigobot sounds
robot.enableMotors();
// Run the robot processing cycle.
// 'true' means to return if it loses connection,
// after which we exit the program.
robot.run(true);
Aria::exit(0);
}
示例4: main
int main(int argc, char** argv)
{
Aria::init();
ArSimpleConnector conn(&argc, argv);
ArRobot robot;
ArSonarDevice sonar;
// Create instances of the actions defined above, plus ArActionStallRecover,
// a predefined action from Aria.
ActionGo go(500, 350);
ActionTurn turn(400, 10);
ArActionStallRecover recover;
// Parse all command-line arguments
if(!Aria::parseArgs())
{
Aria::logOptions();
return 1;
}
// Connect to the robot
if(!conn.connectRobot(&robot))
{
ArLog::log(ArLog::Terse, "actionExample: Could not connect to robot! Exiting.");
return 2;
}
// Add the range device to the robot. You should add all the range
// devices and such before you add actions
robot.addRangeDevice(&sonar);
// Add our actions in order. The second argument is the priority,
// with higher priority actions going first, and possibly pre-empting lower
// priority actions.
robot.addAction(&recover, 100);
robot.addAction(&go, 50);
robot.addAction(&turn, 49);
// Enable the motors, disable amigobot sounds
robot.enableMotors();
// Run the robot processing cycle.
// 'true' means to return if it loses connection,
// after which we exit the program.
robot.run(true);
Aria::shutdown();
return 0;
}
示例5: main
int main(int argc, char **argv)
{
ArRobot robot;
Aria::init();
ArSimpleConnector connector(&argc, argv);
if (!connector.parseArgs() || argc > 1)
{
connector.logOptions();
return 1;
}
// Instance of the JoydriveAction class defined above
JoydriveAction jdAct;
// if the joydrive action couldn't find the joystick, then exit.
if (!jdAct.joystickInited())
{
printf("Do not have a joystick, set up the joystick then rerun the program\n\n");
Aria::exit(1);
return 1;
}
// Connect to the robot
if (!connector.connectRobot(&robot))
{
printf("Could not connect to robot... exiting\n");
return 2;
}
// disable sonar, enable motors, disable amigobot sound
robot.comInt(ArCommands::SONAR, 0);
robot.comInt(ArCommands::ENABLE, 1);
robot.comInt(ArCommands::SOUNDTOG, 0);
// add the action
robot.addAction(&jdAct, 100);
// run the robot, true so it'll exit if we lose connection
robot.run(true);
// now exit program
Aria::exit(0);
return 0;
}
示例6: main
int main()
{
ArModuleLoader::Status status;
ArSerialConnection con;
ArRobot robot;
int ret;
std::string str;
Aria::init();
status=ArModuleLoader::load("./joydriveActionMod", &robot);
printStatus(status);
if (status == ArModuleLoader::STATUS_INIT_FAILED)
return(1);
if ((ret = con.open()) != 0)
{
str = con.getOpenMessage(ret);
printf("Open failed: %s\n", str.c_str());
Aria::shutdown();
return 1;
}
robot.setDeviceConnection(&con);
if (!robot.blockingConnect())
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
return 1;
}
robot.comInt(ArCommands::SONAR, 0);
robot.comInt(ArCommands::ENABLE, 1);
robot.comInt(ArCommands::SOUNDTOG, 0);
robot.run(true);
status=ArModuleLoader::close("./joydriveActionMod");
printStatus(status);
Aria::shutdown();
return 0;
}
示例7: main
int main(int argc, char **argv)
{
std::string str;
int ret;
ArTcpConnection con;
ArRobot robot;
ActionTest at1(-50, 333);
ActionTest at2(25, 666);
ActionTest at3(25, 0);
ActionTest at4(0, -999);
Aria::init();
if ((ret = con.open()) != 0)
{
str = con.getOpenMessage(ret);
printf("Open failed: %s\n", str.c_str());
Aria::shutdown();
return 1;
}
robot.setDeviceConnection(&con);
if (!robot.blockingConnect())
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
return 1;
}
robot.addAction(&at1, 100);
robot.addAction(&at2, 100);
robot.addAction(&at3, 100);
robot.addAction(&at4, 100);
robot.run(true);
Aria::shutdown();
return 0;
}
示例8: main
int main(void)
{
ArTcpConnection con;
ArRobot robot;
ArSonarDevice sonar;
int ret;
std::string str;
ArActionStallRecover recover;
ArActionConstantVelocity constantVelocity("Constant Velocity", 400);
Aria::init();
if ((ret = con.open()) != 0)
{
str = con.getOpenMessage(ret);
printf("Open failed: %s\n", str.c_str());
Aria::shutdown();
return 1;
}
robot.addRangeDevice(&sonar);
robot.setDeviceConnection(&con);
if (!robot.blockingConnect())
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
return 1;
}
robot.comInt(ArCommands::ENABLE, 1);
robot.comInt(ArCommands::SOUNDTOG, 0);
robot.addAction(&recover, 100);
robot.addAction(&constantVelocity, 25);
robot.run(true);
Aria::shutdown();
return 0;
}
示例9: main
int main()
{
/*
TODO
Check that the Starclass is updating the global pose right - not done
Check that the MapClass is giving the right pose - not done
check khenglee can use the behaviours - not done
check emergency control - not done
*/
Network yarp;
SamgarModule VR("Vrobot","Loco","wheel",SamgarModule::run); // Cant have spaces or underscores
VR.AddPortS("TransitIn");
SetupRobot();
ActionEmergencyControl EmergencyControl;
UpdateMap UpdMap (&VR);
UpOdo OdoUp (&VR);
Transit TransitIn (&VR);
// PlaySounder SoundPlayer (&VR);
// BehaveMove MoveBehave (&VR);
// MoveCAM CAMMove (&VR);
// lowest priority might actully be highest becouse coms direct to robot and not through desiredaction.
robot.addAction(&EmergencyControl,99); // need to check this works
robot.addAction(&UpdMap,99);
robot.addAction(&OdoUp,99);
robot.addAction(&TransitIn,70);
// robot.addAction(&SoundPlayer,100);
// robot.addAction(&MoveBehave,100);
// robot.addAction(&CAMMove,100);
robot.run(true);
robot.disconnect();
Aria::shutdown();
return 0;
}
示例10: main
//.........这里部分代码省略.........
ArSonarDevice sonar;
argParser.loadDefaultArguments();
if(!Aria::parseArgs() || !argParser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
return 1;
}
/* - the action group for teleoperation actions: */
teleop = new ArActionGroup(&robot);
// don't hit any tables (if the robot has IR table sensors)
teleop->addAction(new ArActionLimiterTableSensor, 100);
// limiter for close obstacles
teleop->addAction(new ArActionLimiterForwards("speed limiter near",
300, 600, 250), 95);
// limiter for far away obstacles
teleop->addAction(new ArActionLimiterForwards("speed limiter far",
300, 1100, 400), 90);
// limiter so we don't bump things backwards
teleop->addAction(new ArActionLimiterBackwards, 85);
// the joydrive action (drive from joystick)
ArActionJoydrive joydriveAct("joydrive", 400, 15);
teleop->addAction(&joydriveAct, 50);
// the keydrive action (drive from keyboard)
teleop->addAction(new ArActionKeydrive, 45);
/* - the action group for wander actions: */
wander = new ArActionGroup(&robot);
// if we're stalled we want to back up and recover
wander->addAction(new ArActionStallRecover, 100);
// react to bumpers
wander->addAction(new ArActionBumpers, 75);
// turn to avoid things closer to us
wander->addAction(new ArActionAvoidFront("Avoid Front Near", 225, 0), 50);
// turn avoid things further away
wander->addAction(new ArActionAvoidFront, 45);
// keep moving
wander->addAction(new ArActionConstantVelocity("Constant Velocity", 400), 25);
/* - use key commands to switch modes, and use keyboard
* and joystick as inputs for teleoperation actions. */
// create key handler if Aria does not already have one
ArKeyHandler *keyHandler = Aria::getKeyHandler();
if (keyHandler == NULL)
{
keyHandler = new ArKeyHandler;
Aria::setKeyHandler(keyHandler);
robot.attachKeyHandler(keyHandler);
}
// set the callbacks
ArGlobalFunctor teleopCB(&teleopMode);
ArGlobalFunctor wanderCB(&wanderMode);
keyHandler->addKeyHandler('w', &wanderCB);
keyHandler->addKeyHandler('W', &wanderCB);
keyHandler->addKeyHandler('t', &teleopCB);
keyHandler->addKeyHandler('T', &teleopCB);
// if we don't have a joystick, let 'em know
if (!joydriveAct.joystickInited())
printf("Note: Do not have a joystick, only the arrow keys on the keyboard will work.\n");
// set the joystick so it won't do anything if the button isn't pressed
joydriveAct.setStopIfNoButtonPressed(false);
/* - connect to the robot, then enter teleoperation mode. */
robot.addRangeDevice(&sonar);
if(!con.connectRobot(&robot))
{
ArLog::log(ArLog::Terse, "actionGroupExample: Could not connect to the robot.");
Aria::shutdown();
return 1;
}
robot.enableMotors();
teleopMode();
robot.run(true);
Aria::shutdown();
return 0;
}
示例11: main
int main(void)
{
ArSerialConnection con;
ArRobot robot;
int ret;
std::string str;
ArActionLimiterForwards limiter("speed limiter near", 225, 600, 250);
ArActionLimiterForwards limiterFar("speed limiter far", 225, 1100, 400);
ArActionTableSensorLimiter tableLimiter;
ArActionLimiterBackwards backwardsLimiter;
ArActionConstantVelocity stop("stop", 0);
ArSonarDevice sonar;
ArACTS_1_2 acts;
ArPTZ *ptz;
ptz = new ArVCC4(&robot, true);
ArGripper gripper(&robot);
Acquire acq(&acts, &gripper);
DriveTo driveTo(&acts, &gripper, ptz);
DropOff dropOff(&acts, &gripper, ptz);
PickUp pickUp(&acts, &gripper, ptz);
TakeBlockToWall takeBlock(&robot, &gripper, ptz, &acq, &driveTo, &pickUp,
&dropOff, &tableLimiter);
if (!acts.openPort(&robot))
{
printf("Could not connect to acts, exiting\n");
exit(0);
}
Aria::init();
robot.addRangeDevice(&sonar);
//con.setBaud(38400);
if ((ret = con.open()) != 0)
{
str = con.getOpenMessage(ret);
printf("Open failed: %s\n", str.c_str());
Aria::shutdown();
return 1;
}
robot.setDeviceConnection(&con);
if (!robot.blockingConnect())
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
return 1;
}
ptz->init();
ArUtil::sleep(8000);
printf("### 2222\n");
ptz->panTilt(0, -40);
printf("### whee\n");
ArUtil::sleep(8000);
robot.setAbsoluteMaxTransVel(400);
robot.setStateReflectionRefreshTime(250);
robot.comInt(ArCommands::ENABLE, 1);
robot.comInt(ArCommands::SOUNDTOG, 0);
ArUtil::sleep(200);
robot.addAction(&tableLimiter, 100);
robot.addAction(&limiter, 99);
robot.addAction(&limiterFar, 98);
robot.addAction(&backwardsLimiter, 97);
robot.addAction(&acq, 77);
robot.addAction(&driveTo, 76);
robot.addAction(&pickUp, 75);
robot.addAction(&dropOff, 74);
robot.addAction(&stop, 30);
robot.run(true);
Aria::shutdown();
return 0;
}
示例12: main
int main(void)
{
// The connection we'll use to talk to the robot
ArTcpConnection con;
// the robot
ArRobot robot;
// the sonar device
ArSonarDevice sonar;
// some stuff for return values
int ret;
std::string str;
// the behaviors from above, and a stallRecover behavior that uses defaults
ActionGo go(500, 350);
ActionTurn turn(400, 30);
ArActionStallRecover recover;
// this needs to be done
Aria::init();
// open the connection, just using the defaults, if it fails, exit
if ((ret = con.open()) != 0)
{
str = con.getOpenMessage(ret);
printf("Open failed: %s\n", str.c_str());
Aria::shutdown();
return 1;
}
// add the range device to the robot, you should add all the range
// devices and such before you add actions
robot.addRangeDevice(&sonar);
// set the robot to use the given connection
robot.setDeviceConnection(&con);
// do a blocking connect, if it fails exit
if (!robot.blockingConnect())
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
return 1;
}
// enable the motors, disable amigobot sounds
robot.comInt(ArCommands::ENABLE, 1);
robot.comInt(ArCommands::SOUNDTOG, 0);
// add our actions in a good order, the integer here is the priority,
// with higher priority actions going first
robot.addAction(&recover, 100);
robot.addAction(&go, 50);
robot.addAction(&turn, 49);
// run the robot, the true here is to exit if it loses connection
robot.run(true);
// now just shutdown and go away
Aria::shutdown();
return 0;
}
示例13: main
int main(void)
{
ArSerialConnection con;
ArRobot robot;
int ret;
std::string str;
ArActionLimiterForwards limiter("speed limiter near", 300, 600, 250);
ArActionLimiterForwards limiterFar("speed limiter far", 300, 1100, 400);
ArActionLimiterBackwards backwardsLimiter;
ArActionConstantVelocity stop("stop", 0);
ArActionConstantVelocity backup("backup", -200);
ArSonarDevice sonar;
ArACTS_1_2 acts;
ArSonyPTZ sony(&robot);
ArGripper gripper(&robot, ArGripper::GENIO);
Acquire acq(&acts, &gripper);
DriveTo driveTo(&acts, &gripper, &sony);
PickUp pickUp(&acts, &gripper, &sony);
TakeBlockToWall takeBlock(&robot, &gripper, &sony, &acq, &driveTo, &pickUp,
&backup);
Aria::init();
if (!acts.openPort(&robot))
{
printf("Could not connect to acts\n");
exit(1);
}
robot.addRangeDevice(&sonar);
//con.setBaud(38400);
if ((ret = con.open()) != 0)
{
str = con.getOpenMessage(ret);
printf("Open failed: %s\n", str.c_str());
Aria::shutdown();
return 1;
}
robot.setDeviceConnection(&con);
if (!robot.blockingConnect())
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
return 1;
}
sony.init();
ArUtil::sleep(1000);
//robot.setAbsoluteMaxTransVel(400);
robot.setStateReflectionRefreshTime(250);
robot.comInt(ArCommands::ENABLE, 1);
robot.comInt(ArCommands::SOUNDTOG, 0);
ArUtil::sleep(200);
robot.addAction(&limiter, 100);
robot.addAction(&limiterFar, 99);
robot.addAction(&backwardsLimiter, 98);
robot.addAction(&acq, 77);
robot.addAction(&driveTo, 76);
robot.addAction(&pickUp, 75);
robot.addAction(&backup, 50);
robot.addAction(&stop, 30);
robot.run(true);
Aria::shutdown();
return 0;
}
示例14: main
int main(int argc, char **argv)
{
Aria::init();
ArRobot robot;
ArArgumentParser argParser(&argc, argv);
ArSimpleConnector connector(&argParser);
ArGripper gripper(&robot);
ArSonarDevice sonar;
robot.addRangeDevice(&sonar);
argParser.loadDefaultArguments();
if (!Aria::parseArgs() || !argParser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
Aria::shutdown();
return 1;
}
if (!connector.connectRobot(&robot))
{
ArLog::log(ArLog::Terse, "gripperExample: Could not connect to robot... exiting");
Aria::shutdown();
return 2;
}
ArLog::log(ArLog::Normal, "gripperExample: Connected to robot.");
ArLog::log(ArLog::Normal, "gripperExample: GripperType=%d", gripper.getType());
gripper.logState();
if(gripper.getType() == ArGripper::NOGRIPPER)
{
ArLog::log(ArLog::Terse, "gripperExample: Error: Robot does not have a gripper. Exiting.");
Aria::shutdown();
return -1;
}
// Teleoperation actions with obstacle-collision avoidance
ArActionLimiterTableSensor tableLimit;
robot.addAction(&tableLimit, 110);
ArActionLimiterForwards limitNearAction("near", 300, 600, 250);
robot.addAction(&limitNearAction, 100);
ArActionLimiterForwards limitFarAction("far", 300, 1100, 400);
robot.addAction(&limitFarAction, 90);
ArActionLimiterBackwards limitBackAction;
robot.addAction(&limitBackAction, 50);
ArActionJoydrive joydriveAction("joydrive", 400, 15);
robot.addAction(&joydriveAction, 40);
joydriveAction.setStopIfNoButtonPressed(false);
ArActionKeydrive keydriveAction;
robot.addAction(&keydriveAction, 30);
// Handlers to control the gripper and print out info (classes defined above)
PrintGripStatus printStatus(&gripper);
GripperControlHandler gripControl(&gripper);
printStatus.addRobotTask(&robot);
gripControl.addKeyHandlers(&robot);
// enable motors and run (if we lose connection to the robot, exit)
ArLog::log(ArLog::Normal, "You may now operate the robot with arrow keys or joystick. Operate the gripper with the u, d, o, c, and page up/page down keys.");
robot.enableMotors();
robot.run(true);
Aria::shutdown();
return 0;
}
开发者ID:eilo,项目名称:Evolucion-Artificial-y-Robotica-Autonoma-en-Robots-Pioneer-P3-DX,代码行数:67,代码来源:gripper.cpp
示例15: main
int main(int argc, char **argv)
{
Aria::init();
ArArgumentParser parser(&argc, argv);
parser.loadDefaultArguments();
ArRobot robot;
ArRobotConnector robotConnector(&parser, &robot);
if(!robotConnector.connectRobot())
{
ArLog::log(ArLog::Terse, "teleopActionsExample: Could not connect to the robot.");
if(parser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
Aria::exit(1);
}
}
if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
Aria::exit(1);
}
ArLog::log(ArLog::Normal, "teleopActionsExample: Connected.");
// limiter for close obstacles
ArActionLimiterForwards limiter("speed limiter near", 300, 600, 250);
// limiter for far away obstacles
ArActionLimiterForwards limiterFar("speed limiter far", 300, 1100, 400);
// limiter that checks IR sensors (like Peoplebot has)
ArActionLimiterTableSensor tableLimiter;
// limiter so we don't bump things backwards
ArActionLimiterBackwards backwardsLimiter;
// the joydrive action
ArActionJoydrive joydriveAct;
// the keydrive action
ArActionKeydrive keydriveAct;
// sonar device, used by the limiter actions.
ArSonarDevice sonar;
printf("This program will allow you to use a joystick or keyboard to control the robot.\nYou can use the arrow keys to drive, and the spacebar to stop.\nFor joystick control press the trigger button and then drive.\nPress escape to exit.\n");
// if we don't have a joystick, let 'em know
if (!joydriveAct.joystickInited())
printf("Do not have a joystick, only the arrow keys on the keyboard will work.\n");
// add the sonar to the robot
robot.addRangeDevice(&sonar);
// set the robots maximum velocity (sonar don't work at all well if you're
// going faster)
robot.setAbsoluteMaxTransVel(400);
// enable the motor
robot.enableMotors();
// Add the actions, with the limiters as highest priority, then the teleop.
// actions. This will keep the teleop. actions from being able to drive too
// fast and hit something
robot.addAction(&tableLimiter, 100);
robot.addAction(&limiter, 95);
robot.addAction(&limiterFar, 90);
robot.addAction(&backwardsLimiter, 85);
robot.addAction(&joydriveAct, 50);
robot.addAction(&keydriveAct, 45);
// Configure the joydrive action so it will let the lower priority actions
// (i.e. keydriveAct) request motion if the joystick button is
// not pressed.
joydriveAct.setStopIfNoButtonPressed(false);
// run the robot, true means that the run will exit if connection lost
robot.run(true);
Aria::exit(0);
}