/*! @brief The nubot's main loop The nubot's main loop. This function will probably never return. The idea is to simply have @verbatim NUbot* nubot = new NUbot(arc, argv); nubot->run(); delete nubot; @endverbatim */ void NUbot::run() { #if defined(TARGET_IS_NAOWEBOTS) int count = 0; double previoussimtime; NAOWebotsPlatform* webots = (NAOWebotsPlatform*) m_platform; int timestep = int(webots->getBasicTimeStep()); while (true) { previoussimtime = Platform->getTime(); webots->step(timestep); // stepping the simulator generates new data to run motion, and vision data #if defined(USE_MOTION) m_sensemove_thread->signal(true); #endif #if defined(USE_VISION) or defined(USE_LOCALISATION) if (count%2 == 0) // depending on the selected frame rate vision might not need to be updated every simulation step { m_seethink_thread->signal(true); } #endif count++; }; #else while (true) { periodicSleep(33); #if !defined(USE_VISION) and defined(USE_LOCALISATION) m_seethink_thread->signal(true); #endif } #endif }
/*! @brief The nubot's main loop The nubot's main loop. This function will probably never return. The idea is to simply have @verbatim NUbot* nubot = new NUbot(arc, argv); nubot->run(); delete nubot; @endverbatim */ void NUbot::run() { #ifdef TARGET_IS_NAOWEBOTS int count = 0; double previoussimtime; NAOWebotsPlatform* webots = (NAOWebotsPlatform*) platform; while (true) { previoussimtime = nusystem->getTime(); webots->step(40); // stepping the simulator generates new data to run motion, and sometimes the vision data if (nusystem->getTime() - previoussimtime > 81) debug << "NUbot::run(): simulationskip: " << (nusystem->getTime() - previoussimtime) << endl; signalMotion(); if (count%2 == 0) // depending on the selected frame rate vision might not need to be updated every simulation step { signalVision(); waitForVisionCompletion(); } waitForMotionCompletion(); count++; }; #endif }