Пример #1
0
void ModeExecutor::run()
{
	ros::Rate r(_activeMode->getFrequency());

	ros::Time timeStart = ros::Time::now();

	while(!isStopRequested())
	{
		_activeMode->execute();

		if((_activeMode->getPulses() != 0) && 
			(_activeMode->getPulses() <= _activeMode->pulsed()))
			break;

		if(_activeMode->getTimeout() != 0)
		{
			ros::Duration timePassed = ros::Time::now() - timeStart;
			if(timePassed.toSec() >= ((double)_activeMode->getTimeout()/1000))
				break;
		}
		r.sleep();
	}

	delete _activeMode;
	_activeMode = NULL;
}
void ConsoleReader::run()
{
    QTextStream stream(stdin);
    QString line;

    m_stop_requested = false;

    forever
    {
        if (isStopRequested()) break;
        line = stream.readLine();
        if (line.isNull()) continue;
        emit lineReceived(line);
    }
}
Пример #3
0
void Simulator::simulate()
{
    if ( !world ){
	throw std::logic_error("Failed to start simulation: world not set");
    }

    while(! isStopRequested() ){
	simulateStep( dt );
	simulatedSteps ++;
	simulatedTime += dt;
	if (simulationDelay)
	    boost::this_thread::sleep(boost::posix_time::milliseconds( simulationDelay )); 
    }

    stopRequest = false;//stop request fulfilled
}