Error runProgram(const core::FilePath& programFilePath, const std::vector<std::string>& args, const core::system::Options& extraEnvVars, const core::FilePath& workingDir, const boost::function<void(const std::string&)>& onOutput, const boost::function<void(int,const std::string&)>& onExited) { // get system program file path std::string programPath = string_utils::utf8ToSystem( programFilePath.absolutePath()); // setup options core::system::ProcessOptions options; options.terminateChildren = true; options.redirectStdErrToStdOut = true; core::system::Options env; core::system::getModifiedEnv(extraEnvVars, &env); options.environment = env; options.workingDir = workingDir; // setup callbacks boost::shared_ptr<CB> pCB(new CB(onOutput, onExited)); core::system::ProcessCallbacks cb; cb.onStdout = cb.onStderr = boost::bind(&CB::onOutput, pCB, _2); cb.onExit = boost::bind(&CB::onExit, pCB, _1); // run process using supervisor return s_processSupervisor.runProgram(programPath, args, options, cb); }
/*! * 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); } } }