Revision: 8631 http://playerstage.svn.sourceforge.net/playerstage/?rev=8631&view=rev Author: natepak Date: 2010-04-27 16:23:21 +0000 (Tue, 27 Apr 2010)
Log Message: ----------- Fixed a thread bug, and a shutdown bug Modified Paths: -------------- code/gazebo/trunk/cmake/SearchForStuff.cmake code/gazebo/trunk/config.h.in code/gazebo/trunk/libgazebo/SimIface.cc code/gazebo/trunk/libgazebo/gz.h code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/controllers/ControllerFactory.cc code/gazebo/trunk/server/rendering/OgreAdaptor.cc code/gazebo/trunk/server/rendering/OgreAdaptor.hh code/gazebo/trunk/server/rendering/RTShaderSystem.cc code/gazebo/trunk/tools/gazebomodel.cc code/gazebo/trunk/worlds/pioneer2dx.world Modified: code/gazebo/trunk/cmake/SearchForStuff.cmake =================================================================== --- code/gazebo/trunk/cmake/SearchForStuff.cmake 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/cmake/SearchForStuff.cmake 2010-04-27 16:23:21 UTC (rev 8631) @@ -399,26 +399,28 @@ ######################################## # Find libdl -FIND_PATH(libdl_include_dir dlfcn.h /usr/include /usr/local/include) -IF (NOT libdl_include_dir) - MESSAGE (STATUS "Looking for dlfcn.h - not found") - MESSAGE (STATUS "Warning: Unable to find libdl, plugins will not be supported.") - SET (libdl_include_dir /usr/include) -ELSE (NOT libdl_include_dir) - MESSAGE (STATUS "Looking for dlfcn.h - found") -ENDIF (NOT libdl_include_dir) +find_path(libdl_include_dir dlfcn.h /usr/include /usr/local/include) +if (NOT libdl_include_dir) + message (STATUS "Looking for dlfcn.h - not found") + message (STATUS "Warning: Unable to find libdl, plugins will not be supported.") + set (libdl_include_dir /usr/include) +else (NOT libdl_include_dir) + message (STATUS "Looking for dlfcn.h - found") +endif (NOT libdl_include_dir) -FIND_LIBRARY(libdl_library dl /usr/lib /usr/local/lib) -IF (NOT libdl_library) - MESSAGE (STATUS "Looking for libdl - not found") - MESSAGE (STATUS "Warning: Unable to find libdl, plugins will not be supported.") -ELSE (NOT libdl_library) - MESSAGE (STATUS "Looking for libdl - found") -ENDIF (NOT libdl_library) +find_library(libdl_library dl /usr/lib /usr/local/lib) +if (NOT libdl_library) + message (STATUS "Looking for libdl - not found") + message (STATUS "Warning: Unable to find libdl, plugins will not be supported.") +else (NOT libdl_library) + message (STATUS "Looking for libdl - found") +endif (NOT libdl_library) -IF (libdl_library AND libdl_include_dir) +if (libdl_library AND libdl_include_dir) SET (HAVE_DL TRUE) -ENDIF (libdl_library AND libdl_include_dir) +else (libdl_library AND libdl_include_dir) + SET (HAVE_DL FALSE) +endif (libdl_library AND libdl_include_dir) ######################################## # Find assimp Modified: code/gazebo/trunk/config.h.in =================================================================== --- code/gazebo/trunk/config.h.in 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/config.h.in 2010-04-27 16:23:21 UTC (rev 8631) @@ -7,9 +7,10 @@ #define GAZEBO_VERSION "${GAZEBO_VERSION}" -#cmakedefine HAVE_OPENAL -#cmakedefine HAVE_FFMPEG -#cmakedefine HAVE_LTDL -#cmakedefine ENABLE_SHADOWS -#cmakedefine INCLUDE_BULLET -#cmakedefine INCLUDE_ODE +#cmakedefine HAVE_OPENAL 1 +#cmakedefine HAVE_FFMPEG 1 +#cmakedefine HAVE_LTDL 1 +#cmakedefine HAVE_DL 1 +#cmakedefine ENABLE_SHADOWS 1 +#cmakedefine INCLUDE_BULLET 1 +#cmakedefine INCLUDE_ODE 1 Modified: code/gazebo/trunk/libgazebo/SimIface.cc =================================================================== --- code/gazebo/trunk/libgazebo/SimIface.cc 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/libgazebo/SimIface.cc 2010-04-27 16:23:21 UTC (rev 8631) @@ -39,10 +39,6 @@ /// Destroy an interface SimulationIface::~SimulationIface() { - if (this->goAckThread) - delete this->goAckThread; - this->goAckThread = NULL; - this->data = NULL; } @@ -95,6 +91,26 @@ } ////////////////////////////////////////////////////////////////////////////// +/// Close the interface +void SimulationIface::Close() +{ + printf("Close\n"); + + //stop BlockThread + if (this->goAckThread) + { + this->goAckThread->interrupt(); //ask thread to stop + this->GoAckPost(); + this->goAckThread->join(); //wait till it's stopped + delete this->goAckThread; + } + this->goAckThread = NULL; + + + Iface::Close(); +} + +////////////////////////////////////////////////////////////////////////////// // Destroy the interface (server) void SimulationIface::Destroy() { @@ -128,15 +144,28 @@ //////////////////////////////////////////////////////////////////////////////// void SimulationIface::BlockThread() { + printf("Block thread start\n"); + try + { + while (true) + { + // Wait for Gazebo to send a Post + this->GoAckWait(); - while (true) + //are we getting interrupted? + boost::this_thread::interruption_point(); + + // Signal the callback function + this->goAckSignal(); + } + } + catch (boost::thread_interrupted const &) { - // Wait for Gazebo to send a Post - this->GoAckWait(); + fprintf(stderr, "blockthread: thread got interrupted....\n"); + return; + } - // Signal the callback function - this->goAckSignal(); - } + printf("Block thread end\n"); } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/libgazebo/gz.h =================================================================== --- code/gazebo/trunk/libgazebo/gz.h 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/libgazebo/gz.h 2010-04-27 16:23:21 UTC (rev 8631) @@ -505,10 +505,12 @@ /// \brief id String id public: virtual void Create(Server *server, std::string id); + /// \brief Close the interface + public: virtual void Close(); + /// \brief Destroy the interface (server) public: virtual void Destroy(); - /// \brief Open a simulation interface /// \param client Pointer to the client /// \param id String name of the client Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/server/Simulator.cc 2010-04-27 16:23:21 UTC (rev 8631) @@ -84,7 +84,6 @@ // Destructor Simulator::~Simulator() { - if (this->gazeboConfig) { delete this->gazeboConfig; @@ -334,6 +333,9 @@ { gazebo::World::Instance()->Fini(); + if (this->renderEngineEnabled) + gazebo::OgreAdaptor::Instance()->Fini(); + this->Close(); } Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/server/World.cc 2010-04-27 16:23:21 UTC (rev 8631) @@ -1446,8 +1446,11 @@ case SimulationRequestData::GO: { + int sec = req->runTime/1000; + int nsec = (req->runTime - sec) * 1e9; + this->simPauseTime = Simulator::Instance()->GetSimTime() - + Time(req->runTime); + + Time(sec, nsec); Simulator::Instance()->SetPaused(false); break; Modified: code/gazebo/trunk/server/controllers/ControllerFactory.cc =================================================================== --- code/gazebo/trunk/server/controllers/ControllerFactory.cc 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/server/controllers/ControllerFactory.cc 2010-04-27 16:23:21 UTC (rev 8631) @@ -75,7 +75,6 @@ { #ifdef HAVE_DL - std::cerr << "\n\n\n\n\USING DL\n\n\n\n"; void* handle = dlopen(plugin.c_str(), RTLD_LAZY|RTLD_GLOBAL); if (!handle) { Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2010-04-27 16:23:21 UTC (rev 8631) @@ -104,7 +104,6 @@ delete this->drawGridP; delete this->skyMaterialP; - RTShaderSystem::Instance()->Fini(); } //////////////////////////////////////////////////////////////////////////////// @@ -294,6 +293,13 @@ } //////////////////////////////////////////////////////////////////////////////// +/// Finalize +void OgreAdaptor::Fini() +{ + RTShaderSystem::Instance()->Fini(); +} + +//////////////////////////////////////////////////////////////////////////////// // Save void OgreAdaptor::Save(std::string &prefix, std::ostream &stream) { Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.hh 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.hh 2010-04-27 16:23:21 UTC (rev 8631) @@ -88,6 +88,9 @@ /// \brief Initialize ogre public: void Init(XMLConfigNode *rootNode); + + /// \brief Finalize + public: void Fini(); /// \brief Save Ogre settings public: void Save(std::string &prefix, std::ostream &stream); Modified: code/gazebo/trunk/server/rendering/RTShaderSystem.cc =================================================================== --- code/gazebo/trunk/server/rendering/RTShaderSystem.cc 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/server/rendering/RTShaderSystem.cc 2010-04-27 16:23:21 UTC (rev 8631) @@ -47,25 +47,6 @@ /// Destructor RTShaderSystem::~RTShaderSystem() { -#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= MINOR_VERSION - // Restore default scheme. - Ogre::MaterialManager::getSingleton().setActiveScheme(Ogre::MaterialManager::DEFAULT_SCHEME_NAME); - - // Unregister the material manager listener. - if (this->materialMgrListener != NULL) - { - Ogre::MaterialManager::getSingleton().removeListener( - this->materialMgrListener); - this->materialMgrListener = NULL; - } - - // Finalize RTShader system. - if (this->shaderGenerator != NULL) - { - Ogre::RTShader::ShaderGenerator::finalize(); - this->shaderGenerator = NULL; - } -#endif } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/tools/gazebomodel.cc =================================================================== --- code/gazebo/trunk/tools/gazebomodel.cc 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/tools/gazebomodel.cc 2010-04-27 16:23:21 UTC (rev 8631) @@ -141,7 +141,9 @@ while (!feof(file)) { char buffer[256]; - fgets(buffer, 256, file); + if (fgets(buffer, 256, file) == NULL) + std::cerr << "Unable to read file\n"; + if (feof(file)) break; stream << buffer; @@ -240,7 +242,8 @@ char str[1024]; while (!feof(stdin)) { - fgets(str, 1024, stdin); + if (fgets(str, 1024, stdin)==NULL) + std::cerr << "Unable to read file\n"; if (feof(stdin)) break; std::string p = str; Modified: code/gazebo/trunk/worlds/pioneer2dx.world =================================================================== --- code/gazebo/trunk/worlds/pioneer2dx.world 2010-04-27 15:07:08 UTC (rev 8630) +++ code/gazebo/trunk/worlds/pioneer2dx.world 2010-04-27 16:23:21 UTC (rev 8631) @@ -101,7 +101,7 @@ </include> --> - <model:physical name="pioneer2dx_model1"> + <model:physical name="pioneer2dx_model"> <xyz>0 0 1.145</xyz> <rpy>0.0 0.0 90.0</rpy> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit