本文整理汇总了C++中ArRobot::stopRunning方法的典型用法代码示例。如果您正苦于以下问题:C++ ArRobot::stopRunning方法的具体用法?C++ ArRobot::stopRunning怎么用?C++ ArRobot::stopRunning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArRobot
的用法示例。
在下文中一共展示了ArRobot::stopRunning方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: disconnected
// if we lost connection then exit
void ConnHandler::disconnected(void)
{
printf("Lost connection\n");
myRobot->stopRunning();
myJoydrive->stopRunning();
Aria::exit(3); // exit program with error code 3
}
示例2: connFail
// just exit if the connection failed
void ConnHandler::connFail(void)
{
printf("Failed to connect.\n");
myRobot->stopRunning();
Aria::shutdown();
return;
}
示例3: main
int main(int argc, char **argv)
{
Aria::init();
ArRobot robot;
ArArgumentParser argParser(&argc, argv);
ArSimpleConnector con(&argParser);
if(!Aria::parseArgs() || !argParser.checkHelpAndWarnUnparsed())
{
Aria::logOptions();
return 1;
}
// Create a connection handler object, defined above, then try to connect to the
// robot.
ConnHandler ch(&robot);
con.connectRobot(&robot);
robot.runAsync(true);
// Sleep for 10 seconds, then request that ArRobot stop its thread.
ArLog::log(ArLog::Normal, "Sleeping for 10 seconds...");
ArUtil::sleep(10000);
ArLog::log(ArLog::Normal, "...requesting that the robot thread exit, then shutting down ARIA and exiting.");
robot.stopRunning();
Aria::shutdown();
return 0;
}
示例4: connFail
// just exit if we failed to connect
void ConnHandler::connFail(void)
{
printf("Failed to connect.\n");
myRobot->stopRunning();
myJoydrive->stopRunning();
Aria::exit(2); // exit program with error code 2
}
示例5: popupClosed
void SensorDetectPopup::popupClosed(ArTypes::Byte4 popupID, int button)
{
// A client closed the popup
ArLog::log(ArLog::Normal, "popupExample: a client closed popup dialog window with id=%d. Button=%d...", popupID, button);
myPopupDisplayed = false;
if(button < 0)
{
ArLog::log(ArLog::Normal, "\t...popup timed out or closed due to an error.");
return;
}
if (button == 0)
{
ArLog::log(ArLog::Normal, "\t...OK pressed.");
return;
}
if(button == 1)
{
ArLog::log(ArLog::Normal, "\t...180 degree rotate requested.");
myRobot->lock();
myRobot->setDeltaHeading(180);
myRobot->unlock();
return;
}
if(button == 2)
{
ArLog::log(ArLog::Normal, "\t...exit requested.");
myRobot->stopRunning();
Aria::shutdown();
Aria::exit(0);
}
}
示例6: disconnected
// if we lost connection then exit
void ConnHandler::disconnected(void)
{
printf("Lost connection\n");
myRobot->stopRunning();
myJoydrive->stopRunning();
Aria::shutdown();
return;
}
示例7: cleanup
void RosAriaNode::cleanup()
{
if (robot != NULL) {
robot->remSensorInterpTask("ROSPublishingTask");
// disable motors and sonar.
robot->disableMotors();
robot->disableSonar();
robot->stopRunning();
delete conn;
delete robot;
}
Aria::shutdown();
}
示例8: printf
/*!
* Shuts down the system.
*
*/
void
Advanced::shutDown(void)
{
Aria::exit(0);
//
// Stop the path planning thread.
//
if(myPathPlanningTask){
myPathPlanningTask->stopRunning();
// delete myPathPlanningTask;
printf("Stopped Path Planning Thread\n");
}
//
// Stop the localization thread.
//
if(myLocaTask){
myLocaTask->stopRunning();
delete myLocaTask;
printf("Stopped Localization Thread\n");
}
//
// Stop the laser thread.
//
if(mySick)
{
mySick->lockDevice();
mySick->disconnect();
mySick->unlockDevice();
printf("Stopped Laser Thread\n");
}
//
// Stop the robot thread.
//
myRobot->lock();
myRobot->stopRunning();
myRobot->unlock();
printf("Stopped Robot Thread\n");
//
// Exit Aria
//
Aria::shutdown();
printf("Aria Shutdown\n");
}
示例9: manualControlHandler
void manualControlHandler(){
if(firstCall){
firstCall=false;
showMenu();
}
if(keyPressedBefore && !driver->estaEjecutando()){
keyPressedBefore=false;
showMenu();
}
if(mrpt::system::os::kbhit() ){
char c = mrpt::system::os::getch();
keyPressedBefore=true;
switch(c){
case '\033':
c=mrpt::system::os::getch(); // skip the [
cout << "Siguiente caracter" << (int)c << endl;
double v;
switch(mrpt::system::os::getch()) { // the real value
case 'A':
// code for arrow up
v=robot->getVel();
robot->setVel(v+50);
break;
case 'B':
// code for arrow down
v=robot->getVel();
robot->setVel(v-50);
break;
case 'C':
// code for arrow right
v=robot->getRotVel();
robot->setRotVel(v-5);
break;
case 'D':
// code for arrow left
v=robot->getRotVel();
robot->setRotVel(v+5);
break;
}
break;
case ' ':
robot->stop();
break;
case 'x':
//Aria::shutdown();
driver->stopRunning();
robot->stopRunning();
break;
case 'c':
guardarContinuo();
break;
case 'p':
start();
break;
case 'g':
guardar();
break;
case 'w':
guardarTrayectoria();
break;
case 't':
testParado();
break;
case 's':
stop();
break;
}
}
}
示例10: handler
//.........这里部分代码省略.........
myAcquire->deactivate();
myPickUp->deactivate();
myDriveTo->activate();
myDriveTo->setChannel(myLapWall);
myDropOff->deactivate();
myTableLimiter->activate();
}
if (myDriveTo->getState() == DriveTo::STATE_FAILED)
{
printf("###### DriveToLapWall: failed\n");
setState(STATE_BACKUP_LAP_WALL);
//handler();
return;
}
else if (myDriveTo->getState() == DriveTo::STATE_SUCCEEDED)
{
printf("###### DriveToLapWall: succesful\n");
setState(STATE_BACKUP_LAP_WALL);
//handler();
return;
}
break;
case STATE_BACKUP_LAP_WALL:
if (myNewState)
{
myNewState = false;
myRobot->move(BACKUP_DIST * .75);
myAcquire->deactivate();
myPickUp->deactivate();
myDriveTo->deactivate();
myDropOff->deactivate();
myTableLimiter->deactivate();
}
if (myRobot->isLeftMotorStalled() || myRobot->isRightMotorStalled())
{
printf("###### BackupLapWall: Failed, going forwards\n");
myRobot->clearDirectMotion();
setState(STATE_FORWARD_LAP_WALL);
}
if (myStateStartTime.mSecSince() > BACKUP_TIME ||
myStateStartPos.findDistanceTo(myRobot->getPose()) >
ArMath::fabs(BACKUP_DIST * .95 * .75))
{
printf("###### BackupLapWall: Succeeded\n");
myRobot->clearDirectMotion();
setState(STATE_SWITCH);
//handler();
return;
}
break;
case STATE_FORWARD_LAP_WALL:
if (myNewState)
{
myNewState = false;
myRobot->move(-BACKUP_DIST * .75);
myAcquire->deactivate();
myPickUp->deactivate();
myDriveTo->deactivate();
myDropOff->deactivate();
myTableLimiter->deactivate();
}
if (myRobot->isLeftMotorStalled() || myRobot->isRightMotorStalled())
{
printf("###### ForwardLapWall: Failed\n");
myRobot->clearDirectMotion();
setState(STATE_FAILED);
}
if (myStateStartTime.mSecSince() > BACKUP_TIME ||
myStateStartPos.findDistanceTo(myRobot->getPose()) >
ArMath::fabs(BACKUP_DIST * .95 * .75))
{
printf("###### ForwardLapWall: Succeeded\n");
myRobot->clearDirectMotion();
setState(STATE_SWITCH);
//handler();
return;
}
break;
case STATE_SWITCH:
printf("!! Switching walls around.\n");
tempColor = myDropWall;
myDropWall = myLapWall;
myLapWall = tempColor;
setState(STATE_ACQUIRE_BLOCK);
//handler();
return;
case STATE_FAILED:
printf("@@@@@ Failed to complete the task!\n");
myRobot->comInt(ArCommands::SONAR, 0);
ArUtil::sleep(50);
myRobot->comStr(ArCommands::SAY, "\52\77\37\62\42\70");
ArUtil::sleep(500);
Aria::shutdown();
myRobot->disconnect();
myRobot->stopRunning();
return;
}
}
示例11: handler
//.........这里部分代码省略.........
{
printf("###### Drop: success\n");
setState(STATE_DROP_BACKUP);
//handler();
return;
}
break;
case STATE_DROP_BACKUP:
if (myNewState)
{
printf("!! Drop backup\n");
myAcquire->deactivate();
myPickUp->deactivate();
myDriveTo->deactivate();
myBackup->activate();
myNewState = false;
}
if (myStateStart.mSecSince() > 2000)
{
printf("###### Drop_Backup: done\n");
setState(STATE_ACQUIRE_LAP_WALL);
//handler();
return;
}
break;
case STATE_ACQUIRE_LAP_WALL:
if (myNewState)
{
printf("!! Acquire Lap wall, channel %d\n", myLapWall);
myNewState = false;
mySony->panTilt(0, -5);
myAcquire->activate();
myAcquire->setChannel(myLapWall);
myPickUp->deactivate();
myDriveTo->deactivate();
myBackup->deactivate();
}
if (myAcquire->getState() == Acquire::STATE_FAILED ||
myStateStart.mSecSince() > 35000)
{
printf("###### AcquireLapWall:: failed\n");
setState(STATE_SWITCH);
//handler();
return;
}
else if (myAcquire->getState() == Acquire::STATE_SUCCEEDED)
{
printf("###### AcquireLapWall: successful\n");
setState(STATE_DRIVETO_LAP_WALL);
//handler();
return;
}
break;
case STATE_DRIVETO_LAP_WALL:
if (myNewState)
{
printf("!! Driveto Lap wall, channel %d\n", myLapWall);
myNewState = false;
myAcquire->deactivate();
myPickUp->deactivate();
myDriveTo->activate();
myDriveTo->setChannel(myLapWall);
myBackup->deactivate();
}
if (myDriveTo->getState() == DriveTo::STATE_FAILED)
{
printf("###### DriveToLapWall: failed\n");
setState(STATE_SWITCH);
//handler();
return;
}
else if (myDriveTo->getState() == DriveTo::STATE_SUCCEEDED)
{
printf("###### DriveToLapWall: succesful\n");
setState(STATE_SWITCH);
//handler();
return;
}
break;
case STATE_SWITCH:
printf("!! Switching walls around.\n");
tempColor = myDropWall;
myDropWall = myLapWall;
myLapWall = tempColor;
setState(STATE_ACQUIRE_BLOCK);
//handler();
return;
case STATE_FAILED:
printf("@@@@@ Failed to complete the task!\n");
myRobot->comInt(ArCommands::SONAR, 0);
ArUtil::sleep(50);
myRobot->comStr(ArCommands::SAY, "\52\77\37\62\42\70");
ArUtil::sleep(500);
Aria::shutdown();
myRobot->disconnect();
myRobot->stopRunning();
return;
}
}
示例12: main
//.........这里部分代码省略.........
return 1;
}
}
if (!Aria::parseArgs())
{
Aria::logOptions();
Aria::exit(1);
return 1;
}
ArLog::log(ArLog::Normal, "simpleMotionCommands: Connected.");
// 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);
// Print out some data from the SIP.
// We must "lock" the ArRobot object
// before calling its methods, and "unlock" when done, to prevent conflicts
// with the background thread started by the call to robot.runAsync() above.
// See the section on threading in the manual for more about this.
// Make sure you unlock before any sleep() call or any other code that will
// take some time; if the robot remains locked during that time, then
// ArRobot's background thread will be blocked and unable to communicate with
// the robot, call tasks, etc.
robot.lock();
ArLog::log(ArLog::Normal, "simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV",
robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getRotVel(), robot.getBatteryVoltage());
robot.unlock();
// Sleep for 3 seconds.
ArLog::log(ArLog::Normal, "simpleMotionCommands: Will start driving in 3 seconds...");
ArUtil::sleep(3000);
// Set forward velocity to 50 mm/s
ArLog::log(ArLog::Normal, "simpleMotionCommands: Driving forward at 250 mm/s for 5 sec...");
robot.lock();
robot.enableMotors();
robot.setVel(250);
robot.unlock();
ArUtil::sleep(5000);
ArLog::log(ArLog::Normal, "simpleMotionCommands: Stopping.");
robot.lock();
robot.stop();
robot.unlock();
ArUtil::sleep(1000);
ArLog::log(ArLog::Normal, "simpleMotionCommands: Rotating at 10 deg/s for 5 sec...");
robot.lock();
robot.setRotVel(10);
robot.unlock();
ArUtil::sleep(5000);
ArLog::log(ArLog::Normal, "simpleMotionCommands: Rotating at -10 deg/s for 10 sec...");
robot.lock();
robot.setRotVel(-10);
robot.unlock();
ArUtil::sleep(10000);
ArLog::log(ArLog::Normal, "simpleMotionCommands: Driving forward at 150 mm/s for 5 sec...");
robot.lock();
robot.setRotVel(0);
robot.setVel(150);
robot.unlock();
ArUtil::sleep(5000);
ArLog::log(ArLog::Normal, "simpleMotionCommands: Stopping.");
robot.lock();
robot.stop();
robot.unlock();
ArUtil::sleep(1000);
// Other motion command functions include move(), setHeading(),
// setDeltaHeading(). You can also adjust acceleration and deceleration
// values used by the robot with setAccel(), setDecel(), setRotAccel(),
// setRotDecel(). See the ArRobot class documentation for more.
robot.lock();
ArLog::log(ArLog::Normal, "simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV",
robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getRotVel(), robot.getBatteryVoltage());
robot.unlock();
ArLog::log(ArLog::Normal, "simpleMotionCommands: Ending robot thread...");
robot.stopRunning();
// wait for the thread to stop
robot.waitForRunExit();
// exit
ArLog::log(ArLog::Normal, "simpleMotionCommands: Exiting.");
Aria::exit(0);
return 0;
}
示例13: handler
//.........这里部分代码省略.........
handler();
return;
}
else if (myPickUp->getState() == PickUp::STATE_SUCCEEDED)
{
printf("## PickUpBlock2: successful\n");
setState(STATE_ACQUIRE_WALL);
myGripper->liftUp();
handler();
return;
}
break;
case STATE_ACQUIRE_WALL:
if (myNewState)
{
myNewState = false;
mySony->panTilt(0, -5);
myAcquire->activate();
myAcquire->setChannel(COLOR_FIRST_WALL);
myPickUp->deactivate();
myDriveTo->deactivate();
myBackup->deactivate();
}
if (myAcquire->getState() == Acquire::STATE_FAILED)
{
printf("## AcquireWall:: failed\n");
setState(STATE_FAILED);
handler();
return;
}
else if (myAcquire->getState() == Acquire::STATE_SUCCEEDED)
{
printf("## AcquireWall: successful\n");
setState(STATE_DRIVETO_WALL);
handler();
return;
}
break;
case STATE_DRIVETO_WALL:
if (myNewState)
{
myNewState = false;
myAcquire->deactivate();
myPickUp->deactivate();
myDriveTo->activate();
myDriveTo->setChannel(COLOR_FIRST_WALL);
myBackup->deactivate();
}
if (myDriveTo->getState() == DriveTo::STATE_FAILED)
{
printf("## DriveToWall: failed\n");
setState(STATE_FAILED);
handler();
return;
}
else if (myDriveTo->getState() == DriveTo::STATE_SUCCEEDED)
{
printf("## DriveToWall: succesful\n");
setState(STATE_DROP);
handler();
return;
}
break;
case STATE_DROP:
if (myNewState)
{
myGripper->liftDown();
myNewState = false;
}
if (myStateStart.mSecSince() > 3500)
{
myGripper->gripOpen();
}
if (myStateStart.mSecSince() > 5500)
{
printf("## Drop: success\n");
setState(STATE_SUCCEEDED);
handler();
return;
}
break;
case STATE_SUCCEEDED:
printf("Succeeded at the task!\n");
Aria::shutdown();
myRobot->disconnect();
myRobot->stopRunning();
return;
case STATE_FAILED:
printf("Failed to complete the task!\n");
Aria::shutdown();
myRobot->disconnect();
myRobot->stopRunning();
return;
default:
printf("TakeBlockToWall::handler: Unknown state!\n");
}
}