From: <na...@us...> - 2009-05-14 20:19:13
|
Revision: 7667 http://playerstage.svn.sourceforge.net/playerstage/?rev=7667&view=rev Author: natepak Date: 2009-05-14 20:19:07 +0000 (Thu, 14 May 2009) Log Message: ----------- Updates to openal Modified Paths: -------------- code/gazebo/trunk/server/GuiAPI.hh code/gazebo/trunk/server/OpenALAPI.cc code/gazebo/trunk/server/OpenALAPI.hh code/gazebo/trunk/server/audio_video/CMakeLists.txt code/gazebo/trunk/server/audio_video/OpenAL.cc code/gazebo/trunk/server/audio_video/OpenAL.hh code/gazebo/trunk/server/controllers/audio/Audio.cc code/gazebo/trunk/server/controllers/audio/Audio.hh Modified: code/gazebo/trunk/server/GuiAPI.hh =================================================================== --- code/gazebo/trunk/server/GuiAPI.hh 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/GuiAPI.hh 2009-05-14 20:19:07 UTC (rev 7667) @@ -24,6 +24,9 @@ * SVN: $Id:$ */ +#ifndef GUIAPI_HH +#define GUIAPI_HH + #include <string> #include <iostream> @@ -54,5 +57,6 @@ private: Gui *gui; }; +} -} +#endif Modified: code/gazebo/trunk/server/OpenALAPI.cc =================================================================== --- code/gazebo/trunk/server/OpenALAPI.cc 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/OpenALAPI.cc 2009-05-14 20:19:07 UTC (rev 7667) @@ -41,3 +41,4 @@ OpenAL::Instance()->Fini( ); #endif } + Modified: code/gazebo/trunk/server/OpenALAPI.hh =================================================================== --- code/gazebo/trunk/server/OpenALAPI.hh 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/OpenALAPI.hh 2009-05-14 20:19:07 UTC (rev 7667) @@ -24,8 +24,12 @@ * SVN: $Id$ */ +#ifndef OPENALAPI_HH +#define OPENALAPI_HH + namespace gazebo { + class OpenALSource; class XMLConfigNode; class OpenALAPI @@ -42,7 +46,16 @@ /// \brief Initialize public: void Init(); + /// \brief Create an OpenALSource object from XML node + /// \param node The XML config node containing the auiod information + /// \return A pointer to an OpenALSource object + //public: OpenALSource *CreateSource( XMLConfigNode *node ); + /// \brief Finalize public: void Fini(); }; + + } + +#endif Modified: code/gazebo/trunk/server/audio_video/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-14 20:19:07 UTC (rev 7667) @@ -1,3 +1,11 @@ +INCLUDE_DIRECTORIES( + ${OAL_INCLUDE_DIRS} +) + +LINK_DIRECTORIES( + ${OAL_LIBRARY_DIRS} +) + SET (sources AudioDecoder.cc OpenAL.cc ) @@ -12,5 +20,8 @@ ADD_LIBRARY(gazebo_av STATIC ${sources}) ADD_LIBRARY(gazebo_av-shared SHARED ${sources}) +TARGET_LINK_LIBRARIES(gazebo_av ${OAL_LIBRARIES}) +TARGET_LINK_LIBRARIES(gazebo_av-shared ${OAL_LIBRARIES}) + SET_TARGET_PROPERTIES(gazebo_av-shared PROPERTIES OUTPUT_NAME "gazebo_av") INSTALL (TARGETS gazebo_av gazebo_av-shared DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) Modified: code/gazebo/trunk/server/audio_video/OpenAL.cc =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-05-14 20:19:07 UTC (rev 7667) @@ -240,8 +240,6 @@ } - - //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // OPENAL SOURCE Modified: code/gazebo/trunk/server/audio_video/OpenAL.hh =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.hh 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/audio_video/OpenAL.hh 2009-05-14 20:19:07 UTC (rev 7667) @@ -83,7 +83,6 @@ private: static OpenAL *myself; }; - /// \brief OpenAL Source. This can be thought of as a speaker. class OpenALSource { Modified: code/gazebo/trunk/server/controllers/audio/Audio.cc =================================================================== --- code/gazebo/trunk/server/controllers/audio/Audio.cc 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/controllers/audio/Audio.cc 2009-05-14 20:19:07 UTC (rev 7667) @@ -31,6 +31,7 @@ #include "gazebo.h" #include "GazeboError.hh" #include "ControllerFactory.hh" +#include "OpenAL.hh" #include "Audio.hh" #include <string.h> Modified: code/gazebo/trunk/server/controllers/audio/Audio.hh =================================================================== --- code/gazebo/trunk/server/controllers/audio/Audio.hh 2009-05-14 18:59:59 UTC (rev 7666) +++ code/gazebo/trunk/server/controllers/audio/Audio.hh 2009-05-14 20:19:07 UTC (rev 7667) @@ -29,7 +29,6 @@ #include "Controller.hh" #include "Entity.hh" -#include "OpenAL.hh" namespace gazebo { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-15 19:43:21
|
Revision: 7674 http://playerstage.svn.sourceforge.net/playerstage/?rev=7674&view=rev Author: natepak Date: 2009-05-15 19:43:14 +0000 (Fri, 15 May 2009) Log Message: ----------- Started to disable the openalapi files Modified Paths: -------------- code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/World.hh code/gazebo/trunk/server/audio_video/OpenAL.cc code/gazebo/trunk/server/audio_video/OpenAL.hh Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-05-15 17:20:26 UTC (rev 7673) +++ code/gazebo/trunk/server/World.cc 2009-05-15 19:43:14 UTC (rev 7674) @@ -41,7 +41,7 @@ #include "gazebo.h" #include "World.hh" -#include "OpenALAPI.hh" +#include "OpenAL.hh" #include "Geom.hh" @@ -111,11 +111,6 @@ { gzthrow(e); } - - if (this->openAL) - delete this->openAL; - this->openAL = NULL; - } //////////////////////////////////////////////////////////////////////////////// @@ -152,7 +147,9 @@ // Load OpenAL audio if (rootNode->GetChild("openal","audio")) { - this->openAL = new OpenALAPI(); + //this->openAL = new OpenALAPI(); + //this->openAL->Load(rootNode->GetChild("openal", "audio")); + this->openAL = OpenAL::Instance(); this->openAL->Load(rootNode->GetChild("openal", "audio")); } Modified: code/gazebo/trunk/server/World.hh =================================================================== --- code/gazebo/trunk/server/World.hh 2009-05-15 17:20:26 UTC (rev 7673) +++ code/gazebo/trunk/server/World.hh 2009-05-15 19:43:14 UTC (rev 7674) @@ -49,7 +49,7 @@ class PhysicsEngine; class XMLConfigNode; class GraphicsIfaceHandler; - class OpenALAPI; + class OpenAL; /// \brief The World /* @@ -226,7 +226,7 @@ /// Length of time to run before receiving a "go" command private: double simPauseTime; - private: OpenALAPI *openAL; + private: OpenAL *openAL; private: friend class DestroyerT<World>; private: friend class SingletonT<World>; Modified: code/gazebo/trunk/server/audio_video/OpenAL.cc =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-05-15 17:20:26 UTC (rev 7673) +++ code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-05-15 19:43:14 UTC (rev 7674) @@ -26,16 +26,15 @@ #include "config.h" -#ifdef HAVE_OPENAL - #include <stdio.h> #include <unistd.h> #include <iostream> - +#ifdef HAVE_OPENAL #include <AL/al.h> #include <AL/alc.h> #include <AL/alext.h> +#endif #include "XMLConfig.hh" #include "GazeboError.hh" @@ -53,8 +52,10 @@ ///// Constructor OpenAL::OpenAL() { +#ifdef HAVE_OPENAL this->context = NULL; this->audioDevice = NULL; +#endif } //////////////////////////////////////////////////////////////////////////////// @@ -78,6 +79,7 @@ /// Destructor void OpenAL::Load(XMLConfigNode *node) { +#ifdef HAVE_OPENAL std::string deviceName = "default"; // Get the audio device name @@ -116,6 +118,7 @@ // TODO: put in function to set distance model //alDistanceModel(AL_EXPONENT_DISTANCE); +#endif } //////////////////////////////////////////////////////////////////////////////// @@ -128,6 +131,8 @@ /// Finalize void OpenAL::Fini() { +#ifdef HAVE_OPENAL + if (this->audioDevice) { alcCloseDevice(this->audioDevice); @@ -139,12 +144,14 @@ alcMakeContextCurrent(NULL); alcDestroyContext(this->context); } +#endif } //////////////////////////////////////////////////////////////////////////////// // Create an openal source from XML config node OpenALSource *OpenAL::CreateSource( XMLConfigNode *node ) { +#ifdef HAVE_OPENAL // Make sure the xml node is valid if (!node) { @@ -167,6 +174,9 @@ // Return a pointer to the source return source; +#else + return NULL; +#endif } @@ -174,6 +184,7 @@ /// Set the listener position void OpenAL::SetListenerPos( const Vector3 pos ) { +#ifdef HAVE_OPENAL ALenum error; // Make sure we have an audio device @@ -192,12 +203,14 @@ { gzerr(0) << " Error: [" << error << "]\n"; } +#endif } //////////////////////////////////////////////////////////////////////////////// /// Set the listener velocity void OpenAL::SetListenerVel( const Vector3 vel ) { +#ifdef HAVE_OPENAL ALenum error; // Make sure we have an audio device @@ -214,7 +227,7 @@ { gzerr(0) << " Error: [" << error << "]\n"; } - +#endif } //////////////////////////////////////////////////////////////////////////////// @@ -222,6 +235,7 @@ void OpenAL::SetListenerOrient( float cx, float cy, float cz, float ux, float uy, float uz ) { +#ifdef HAVE_OPENAL ALenum error; ALfloat orient[]={cx, cy, cz, ux, uy, uz}; @@ -240,7 +254,7 @@ { gzerr(0) << " Error: [" << error << "]\n"; } - +#endif } @@ -255,25 +269,30 @@ // Constructor OpenALSource::OpenALSource() { +#ifdef HAVE_OPENAL //Create 1 source alGenSources(1, &this->alSource); // Create 1 buffer alGenBuffers(1, &this->alBuffer); +#endif } //////////////////////////////////////////////////////////////////////////////// // Destructor OpenALSource::~OpenALSource() { +#ifdef HAVE_OPENAL alDeleteSources(1, &this->alSource); alDeleteBuffers(1, &this->alBuffer); +#endif } //////////////////////////////////////////////////////////////////////////////// // Load from xml node void OpenALSource::Load(XMLConfigNode *node) { +#ifdef HAVE_OPENAL // Set the pitch of the source this->SetPitch( node->GetDouble("pitch",1.0,0) ); @@ -285,12 +304,14 @@ if (node->GetChild("mp3") != NULL) this->FillBufferFromFile(node->GetString("mp3","",1)); +#endif } //////////////////////////////////////////////////////////////////////////////// // Set the position of the source int OpenALSource::SetPos(const Vector3 &pos) { +#ifdef HAVE_OPENAL ALfloat p[3] = {pos.x, pos.y, pos.z}; ALenum error; @@ -304,6 +325,7 @@ gzerr(0) << "Error: [" << error << "]\n"; return -1; } +#endif return 0; } @@ -312,6 +334,7 @@ // Set the position of the source int OpenALSource::SetVel(const Vector3 &vel) { +#ifdef HAVE_OPENAL ALenum error; ALfloat v[3] = {vel.x, vel.y, vel.z}; @@ -325,7 +348,7 @@ gzerr(0) << "Error: [" << error << "]\n"; return -1; } - +#endif return 0; } @@ -333,6 +356,7 @@ // Set the pitch of the source int OpenALSource::SetPitch(float p) { +#ifdef HAVE_OPENAL ALenum error; // clear error state @@ -345,7 +369,7 @@ gzerr(0) << " Error: [" << error << "]\n"; return -1; } - +#endif return 0; } @@ -353,6 +377,7 @@ // Set the pitch of the source int OpenALSource::SetGain(float g) { +#ifdef HAVE_OPENAL ALenum error; @@ -366,7 +391,7 @@ gzerr(0) << "Error: [" << error << "]\n"; return -1; } - +#endif return 0; } @@ -374,6 +399,7 @@ // Set whether the source loops the audio int OpenALSource::SetLoop(bool state) { +#ifdef HAVE_OPENAL ALenum error; // clear error state @@ -387,6 +413,7 @@ gzerr(0) << " Error: [" << error << "]\n"; return -1; } +#endif return 0; } @@ -395,6 +422,7 @@ // Play the source void OpenALSource::Play() { +#ifdef HAVE_OPENAL int sourceState; alGetSourcei(this->alSource, AL_SOURCE_STATE, &sourceState); @@ -403,47 +431,58 @@ { alSourcePlay( this->alSource ); } +#endif } //////////////////////////////////////////////////////////////////////////////// // Pause the source void OpenALSource::Pause() { +#ifdef HAVE_OPENAL int sourceState; alGetSourcei(this->alSource, AL_SOURCE_STATE, &sourceState); // Pause the source if it playing if (sourceState == AL_PLAYING) alSourcePause( this->alSource ); +#endif } //////////////////////////////////////////////////////////////////////////////// // Stop the source void OpenALSource::Stop() { +#ifdef HAVE_OPENAL int sourceState; alGetSourcei(this->alSource, AL_SOURCE_STATE, &sourceState); // Stop the source if it is not already stopped if (sourceState != AL_STOPPED) alSourcePause( this->alSource); +#endif } //////////////////////////////////////////////////////////////////////////////// /// Rewind the sound to the beginning void OpenALSource::Rewind() { +#ifdef HAVE_OPENAL alSourceRewind(this->alSource); +#endif } //////////////////////////////////////////////////////////////////////////////// /// Is the audio playing bool OpenALSource::IsPlaying() { +#ifdef HAVE_OPENAL int sourceState; alGetSourcei(this->alSource, AL_SOURCE_STATE, &sourceState); return sourceState == AL_PLAYING; +#else + return false; +#endif } @@ -452,6 +491,7 @@ void OpenALSource::FillBufferFromPCM(uint8_t *pcmData, unsigned int dataCount, int sampleRate ) { +#ifdef HAVE_OPENAL // First detach the buffer alSourcei(this->alSource, AL_BUFFER, 0 ); @@ -468,12 +508,14 @@ { gzthrow("Unable to copy data into openAL buffer\n"); } +#endif } //////////////////////////////////////////////////////////////////////////////// /// Fill the OpenAL audio buffer with data from a sound file void OpenALSource::FillBufferFromFile( const std::string &audioFile ) { +#ifdef HAVE_OPENAL std::string fullPathAudioFile = audioFile; @@ -522,6 +564,6 @@ if (dataBuffer) delete [] dataBuffer; -} #endif +} Modified: code/gazebo/trunk/server/audio_video/OpenAL.hh =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.hh 2009-05-15 17:20:26 UTC (rev 7673) +++ code/gazebo/trunk/server/audio_video/OpenAL.hh 2009-05-15 19:43:14 UTC (rev 7674) @@ -34,9 +34,9 @@ #include "Vector3.hh" #ifdef HAVE_OPENAL - struct ALCcontext_struct; struct ALCdevice_struct; +#endif namespace gazebo { @@ -80,8 +80,10 @@ public: void SetListenerOrient(float cx, float cy, float cz, float ux, float uy, float uz); +#ifdef HAVE_OPENAL private: ALCcontext_struct *context; private: ALCdevice_struct *audioDevice; +#endif private: static OpenAL *myself; }; @@ -144,4 +146,3 @@ } #endif -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-15 19:46:56
|
Revision: 7675 http://playerstage.svn.sourceforge.net/playerstage/?rev=7675&view=rev Author: natepak Date: 2009-05-15 19:46:48 +0000 (Fri, 15 May 2009) Log Message: ----------- Removed OpenALAPI Removed Paths: ------------- code/gazebo/trunk/server/OpenALAPI.cc code/gazebo/trunk/server/OpenALAPI.hh Deleted: code/gazebo/trunk/server/OpenALAPI.cc =================================================================== --- code/gazebo/trunk/server/OpenALAPI.cc 2009-05-15 19:43:14 UTC (rev 7674) +++ code/gazebo/trunk/server/OpenALAPI.cc 2009-05-15 19:46:48 UTC (rev 7675) @@ -1,46 +0,0 @@ -#include "config.h" - -#include "OpenAL.hh" -#include "OpenALAPI.hh" - -using namespace gazebo; - -//////////////////////////////////////////////////////////////////////////////// -/// Constructor -OpenALAPI::OpenALAPI() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -/// Destructor -OpenALAPI::~OpenALAPI() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// Load -void OpenALAPI::Load(XMLConfigNode *node) -{ -#ifdef HAVE_OPENAL - OpenAL::Instance()->Load( node ); -#endif -} - -//////////////////////////////////////////////////////////////////////////////// -/// Initialize -void OpenALAPI::Init() -{ -#ifdef HAVE_OPENAL - OpenAL::Instance()->Init( ); -#endif -} - -//////////////////////////////////////////////////////////////////////////////// -/// Finalize -void OpenALAPI::Fini() -{ -#ifdef HAVE_OPENAL - OpenAL::Instance()->Fini( ); -#endif -} - Deleted: code/gazebo/trunk/server/OpenALAPI.hh =================================================================== --- code/gazebo/trunk/server/OpenALAPI.hh 2009-05-15 19:43:14 UTC (rev 7674) +++ code/gazebo/trunk/server/OpenALAPI.hh 2009-05-15 19:46:48 UTC (rev 7675) @@ -1,61 +0,0 @@ -/* - * Gazebo - Outdoor Multi-Robot Simulator - * Copyright (C) 2003 - * Nate Koenig & Andrew Howard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -/* Desc: OpenAL API - * Author: Nate Koenig - * Date: 14 May 2009 - * SVN: $Id$ - */ - -#ifndef OPENALAPI_HH -#define OPENALAPI_HH - -namespace gazebo -{ - class OpenALSource; - class XMLConfigNode; - - class OpenALAPI - { - /// \brief Constructor - public: OpenALAPI(); - - /// \brief Destructor - public: virtual ~OpenALAPI(); - - /// \brief Load - public: void Load(XMLConfigNode *node); - - /// \brief Initialize - public: void Init(); - - /// \brief Create an OpenALSource object from XML node - /// \param node The XML config node containing the auiod information - /// \return A pointer to an OpenALSource object - //public: OpenALSource *CreateSource( XMLConfigNode *node ); - - /// \brief Finalize - public: void Fini(); - }; - - -} - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hsu...@us...> - 2009-05-16 19:56:01
|
Revision: 7686 http://playerstage.svn.sourceforge.net/playerstage/?rev=7686&view=rev Author: hsujohnhsu Date: 2009-05-16 19:55:50 +0000 (Sat, 16 May 2009) Log Message: ----------- comment out static portion, build shared lib only for gazebo_av and gazebo_gui. Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt code/gazebo/trunk/server/audio_video/CMakeLists.txt code/gazebo/trunk/server/gui/CMakeLists.txt Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-16 19:43:24 UTC (rev 7685) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-16 19:55:50 UTC (rev 7686) @@ -111,8 +111,8 @@ ${boost_libraries} ${freeimage_library} gazebo_server - gazebo_av - gazebo_gui + gazebo_av-shared + gazebo_gui-shared gazebo ) Modified: code/gazebo/trunk/server/audio_video/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-16 19:43:24 UTC (rev 7685) +++ code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-16 19:55:50 UTC (rev 7686) @@ -14,11 +14,13 @@ OpenAL.hh ) -ADD_LIBRARY(gazebo_av STATIC ${sources}) +#ADD_LIBRARY(gazebo_av STATIC ${sources}) ADD_LIBRARY(gazebo_av-shared SHARED ${sources}) -TARGET_LINK_LIBRARIES(gazebo_av ${OAL_LIBRARIES}) +#TARGET_LINK_LIBRARIES(gazebo_av ${OAL_LIBRARIES}) TARGET_LINK_LIBRARIES(gazebo_av-shared ${OAL_LIBRARIES}) +#SET_TARGET_PROPERTIES(gazebo_av PROPERTIES OUTPUT_NAME "gazebo_av") SET_TARGET_PROPERTIES(gazebo_av-shared PROPERTIES OUTPUT_NAME "gazebo_av") -INSTALL (TARGETS gazebo_av gazebo_av-shared DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + +INSTALL (TARGETS gazebo_av-shared DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) Modified: code/gazebo/trunk/server/gui/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-16 19:43:24 UTC (rev 7685) +++ code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-16 19:55:50 UTC (rev 7686) @@ -16,13 +16,13 @@ GLFrame.hh ) -ADD_LIBRARY(gazebo_gui STATIC ${sources}) +#ADD_LIBRARY(gazebo_gui STATIC ${sources}) ADD_LIBRARY(gazebo_gui-shared SHARED ${sources}) -TARGET_LINK_LIBRARIES(gazebo_gui ${FLTK_LIBRARIES} ) +#TARGET_LINK_LIBRARIES(gazebo_gui ${FLTK_LIBRARIES} ) TARGET_LINK_LIBRARIES(gazebo_gui-shared ${FLTK_LIBRARIES} ) -#SET_TARGET_PROPERTIES(gazebo_gui-static PROPERTIES OUTPUT_NAME "gazebo_gui") +#SET_TARGET_PROPERTIES(gazebo_gui PROPERTIES OUTPUT_NAME "gazebo_gui") SET_TARGET_PROPERTIES(gazebo_gui-shared PROPERTIES OUTPUT_NAME "gazebo_gui") -INSTALL (TARGETS gazebo_gui gazebo_gui-shared DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) +INSTALL (TARGETS gazebo_gui-shared DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-20 18:07:29
|
Revision: 7701 http://playerstage.svn.sourceforge.net/playerstage/?rev=7701&view=rev Author: natepak Date: 2009-05-20 18:07:23 +0000 (Wed, 20 May 2009) Log Message: ----------- Fixed warning Modified Paths: -------------- code/gazebo/trunk/server/GazeboConfig.cc code/gazebo/trunk/server/main.cc Modified: code/gazebo/trunk/server/GazeboConfig.cc =================================================================== --- code/gazebo/trunk/server/GazeboConfig.cc 2009-05-20 17:13:28 UTC (rev 7700) +++ code/gazebo/trunk/server/GazeboConfig.cc 2009-05-20 18:07:23 UTC (rev 7701) @@ -64,7 +64,7 @@ std::string str(ogre_resource_path); int pos1 = 0; int pos2 = str.find(delim); - while (pos2 != std::string::npos) + while (pos2 != (int)std::string::npos) { this->ogrePaths.push_back(str.substr(pos1,pos2-pos1+1)); pos1 = pos2+1; @@ -78,7 +78,7 @@ std::string str(gazebo_resource_path); int pos1 = 0; int pos2 = str.find(delim); - while (pos2 != std::string::npos) + while (pos2 != (int)std::string::npos) { this->gazeboPaths.push_back(str.substr(pos1,pos2-pos1)); pos1 = pos2+1; Modified: code/gazebo/trunk/server/main.cc =================================================================== --- code/gazebo/trunk/server/main.cc 2009-05-20 17:13:28 UTC (rev 7700) +++ code/gazebo/trunk/server/main.cc 2009-05-20 18:07:23 UTC (rev 7701) @@ -297,7 +297,7 @@ { std::cerr << "Error Loading Gazebo" << std::endl; std::cerr << e << std::endl; - gazebo::Simulator::Instance()->Close(); + gazebo::Simulator::Instance()->Fini(); return -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-20 18:22:57
|
Revision: 7702 http://playerstage.svn.sourceforge.net/playerstage/?rev=7702&view=rev Author: natepak Date: 2009-05-20 18:22:48 +0000 (Wed, 20 May 2009) Log Message: ----------- Cleaned Fini Modified Paths: -------------- code/gazebo/trunk/server/Entity.cc code/gazebo/trunk/server/rendering/OgreCreator.cc Modified: code/gazebo/trunk/server/Entity.cc =================================================================== --- code/gazebo/trunk/server/Entity.cc 2009-05-20 18:07:23 UTC (rev 7701) +++ code/gazebo/trunk/server/Entity.cc 2009-05-20 18:22:48 UTC (rev 7702) @@ -83,7 +83,9 @@ World::Instance()->GetPhysicsEngine()->RemoveEntity(this); - OgreCreator::Instance()->DeleteVisual(this->visualNode); + if (this->visualNode) + OgreCreator::Instance()->DeleteVisual(this->visualNode); + this->visualNode = NULL; } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-05-20 18:07:23 UTC (rev 7701) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-05-20 18:22:48 UTC (rev 7702) @@ -806,11 +806,11 @@ iter = this->visuals.find(visual->GetName()); - if (iter != this->visuals.end()) + if (iter != this->visuals.end() && iter->second != NULL) { delete iter->second; iter->second = NULL; - this->visuals.erase(iter); + //this->visuals.erase(iter); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-23 16:29:41
|
Revision: 7713 http://playerstage.svn.sourceforge.net/playerstage/?rev=7713&view=rev Author: natepak Date: 2009-05-23 16:29:36 +0000 (Sat, 23 May 2009) Log Message: ----------- Added a random number class Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt Added Paths: ----------- code/gazebo/trunk/server/Rand.cc code/gazebo/trunk/server/Rand.hh Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-23 00:33:08 UTC (rev 7712) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-23 16:29:36 UTC (rev 7713) @@ -63,6 +63,7 @@ GraphicsIfaceHandler.cc GuiAPI.cc Simulator.cc + Rand.cc ) SET (headers Common.hh @@ -87,6 +88,7 @@ GraphicsIfaceHandler.hh GuiAPI.hh Simulator.hh + Rand.hh ) APPEND_TO_SERVER_HEADERS(${headers}) Added: code/gazebo/trunk/server/Rand.cc =================================================================== --- code/gazebo/trunk/server/Rand.cc (rev 0) +++ code/gazebo/trunk/server/Rand.cc 2009-05-23 16:29:36 UTC (rev 7713) @@ -0,0 +1,54 @@ +#include <ctime> +#include "Rand.hh" + +using namespace gazebo; + +GeneratorType *Rand::randGenerator = new GeneratorType(std::time(0)); + +/////////////////////////////////////////////////////////////////////////////// +// Constructor +Rand::Rand() +{ +} + +/////////////////////////////////////////////////////////////////////////////// +// Destructor +Rand::~Rand() +{ +} + +/////////////////////////////////////////////////////////////////////////////// +/// Get a double from a uniform distribution +double Rand::GetDblUniform(double min, double max) +{ + URealGen gen(*randGenerator, UniformRealDist(min, max)); + + return gen(); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Get a double from a normal distribution +double Rand::GetDblNormal(double mean, double sigma) +{ + NRealGen gen(*randGenerator, NormalRealDist(mean, sigma)); + + return gen(); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Get a integer from a uniform distribution +int Rand::GetIntUniform(int min, int max) +{ + UIntGen gen(*randGenerator, UniformIntDist(min,max)); + + return gen(); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Get a double from a normal distribution +int Rand::GetIntNormal(int mean, int sigma) +{ + NRealGen gen(*randGenerator, NormalRealDist(mean, sigma)); + + return (int)(gen()); +} Added: code/gazebo/trunk/server/Rand.hh =================================================================== --- code/gazebo/trunk/server/Rand.hh (rev 0) +++ code/gazebo/trunk/server/Rand.hh 2009-05-23 16:29:36 UTC (rev 7713) @@ -0,0 +1,53 @@ +#ifndef RAND_HH +#define RAND_HH + +#include <boost/random.hpp> + +namespace gazebo +{ + + typedef boost::mt19937 GeneratorType; + typedef boost::uniform_real<double> UniformRealDist; + typedef boost::normal_distribution<double> NormalRealDist; + typedef boost::uniform_int<int> UniformIntDist; + + typedef boost::variate_generator<GeneratorType&, UniformRealDist > URealGen; + typedef boost::variate_generator<GeneratorType&, NormalRealDist > NRealGen; + typedef boost::variate_generator<GeneratorType&, UniformIntDist > UIntGen; + + /// \brief Random number generator class + class Rand + { + /// \brief Constructor + private: Rand(); + + /// \brief Destructor + private: virtual ~Rand(); + + /// \brief Get a double from a uniform distribution + /// \param min Minimum bound for the random number + /// \param max Maximum bound for the random number + public: static double GetDblUniform(double min=0, double max=1); + + /// \brief Get a double from a normal distribution + /// \param mean Mean value for the distribution + /// \param sigma Sigma value for the distribution + public: static double GetDblNormal(double mean=0, double sigma=1); + + /// \brief Get a integer from a uniform distribution + /// \param min Minimum bound for the random number + /// \param max Maximum bound for the random number + public: static int GetIntUniform(int min, int max); + + /// \brief Get a double from a normal distribution + /// \param mean Mean value for the distribution + /// \param sigma Sigma value for the distribution + public: static int GetIntNormal(int mean, int sigma); + + // The random number generator + private: static GeneratorType *randGenerator; + }; + +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-27 15:10:14
|
Revision: 7727 http://playerstage.svn.sourceforge.net/playerstage/?rev=7727&view=rev Author: natepak Date: 2009-05-27 15:10:05 +0000 (Wed, 27 May 2009) Log Message: ----------- Added comments Modified Paths: -------------- code/gazebo/trunk/server/Rand.cc code/gazebo/trunk/server/Rand.hh code/gazebo/trunk/server/rendering/OgreAdaptor.cc code/gazebo/trunk/server/rendering/OgreCreator.cc Modified: code/gazebo/trunk/server/Rand.cc =================================================================== --- code/gazebo/trunk/server/Rand.cc 2009-05-27 03:11:26 UTC (rev 7726) +++ code/gazebo/trunk/server/Rand.cc 2009-05-27 15:10:05 UTC (rev 7727) @@ -1,3 +1,29 @@ +/* + * Gazebo - Outdoor Multi-Robot Simulator + * Copyright (C) 2003 + * Nate Koenig & Andrew Howard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/* Desc: Random number generator + * Author: Nate Koenig + * Date: 27 May 2009 + * SVN: $Id:$ + */ + #include <ctime> #include "Rand.hh" Modified: code/gazebo/trunk/server/Rand.hh =================================================================== --- code/gazebo/trunk/server/Rand.hh 2009-05-27 03:11:26 UTC (rev 7726) +++ code/gazebo/trunk/server/Rand.hh 2009-05-27 15:10:05 UTC (rev 7727) @@ -1,3 +1,29 @@ +/* + * Gazebo - Outdoor Multi-Robot Simulator + * Copyright (C) 2003 + * Nate Koenig & Andrew Howard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/* Desc: Random number generator + * Author: Nate Koenig + * Date: 27 May 2009 + * SVN: $Id:$ + */ + #ifndef RAND_HH #define RAND_HH Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-05-27 03:11:26 UTC (rev 7726) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-05-27 15:10:05 UTC (rev 7727) @@ -196,8 +196,9 @@ else { this->sceneType= SCENE_EXT; - this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_CLOSE); - //this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_FAR); + this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_FAR); + //this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_CLOSE); + //this->sceneMgr = this->root->createSceneManager(Ogre::ST_GENERIC); } Param::Begin(&this->parameters); @@ -211,33 +212,42 @@ this->drawGridP->Load(node); this->updateRateP->Load(node); + //Preload basic shapes that can be used anywhere + OgreCreator::LoadBasicShapes(); ambient.r = (**(this->ambientP)).x; ambient.g = (**(this->ambientP)).y; ambient.b = (**(this->ambientP)).z; ambient.a = (**(this->ambientP)).w; - // Ambient lighting - this->sceneMgr->setAmbientLight(ambient); - - this->sceneMgr->setShadowTextureSelfShadow(true); - this->sceneMgr->setShadowTexturePixelFormat(Ogre::PF_FLOAT16_R); - this->sceneMgr->setShadowTextureSize(**(this->shadowTextureSizeP)); - this->sceneMgr->setShadowIndexBufferSize(**(this->shadowIndexSizeP) ); - + // Settings for shadow mapping if (**(this->shadowTechniqueP) == std::string("stencilAdditive")) this->sceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_ADDITIVE ); + else if (**(this->shadowTechniqueP) == std::string("stencilModulative")) + this->sceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_MODULATIVE ); else if (**(this->shadowTechniqueP) == std::string("textureAdditive")) this->sceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_TEXTURE_ADDITIVE ); + else if (**(this->shadowTechniqueP) == std::string("textureModulative")) + this->sceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_TEXTURE_MODULATIVE ); else if (**(this->shadowTechniqueP) == std::string("none")) this->sceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_NONE ); else gzthrow(std::string("Unsupported shadow technique: ") + **(this->shadowTechniqueP) + "\n"); - //Preload basic shapes that can be used anywhere - OgreCreator::LoadBasicShapes(); + this->sceneMgr->setShadowTextureSelfShadow(true); + this->sceneMgr->setShadowTexturePixelFormat(Ogre::PF_FLOAT16_R); + this->sceneMgr->setShadowTextureSize(**(this->shadowTextureSizeP)); + this->sceneMgr->setShadowIndexBufferSize(**(this->shadowIndexSizeP) ); + // Ambient lighting + this->sceneMgr->setAmbientLight(ambient); + + this->sceneMgr->setShadowTextureSettings(512,2); + this->sceneMgr->setShowDebugShadows(true); + this->sceneMgr->setShadowColour(Ogre::ColourValue(0.2, 0.2, 0.2)); + this->sceneMgr->setShadowFarDistance(30); + // Add a sky dome to our scene if (node->GetChild("sky")) { Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-05-27 03:11:26 UTC (rev 7726) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-05-27 15:10:05 UTC (rev 7727) @@ -173,6 +173,7 @@ // Set the direction which the light points vec = node->GetVector3("direction", Vector3(0.0, 0.0, -1.0)); + vec.Normalize(); light->setDirection(vec.x, vec.y, vec.z); // Absolute range of light in world coordinates @@ -207,6 +208,8 @@ Ogre::Radian(Ogre::Degree(vec.y)), vec.z); } + light->setCastShadows(node->GetBool("castShadows",false,0)); + parent->AttachObject(light); return stream.str(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hsu...@us...> - 2009-05-29 04:25:58
|
Revision: 7737 http://playerstage.svn.sourceforge.net/playerstage/?rev=7737&view=rev Author: hsujohnhsu Date: 2009-05-29 02:25:59 +0000 (Fri, 29 May 2009) Log Message: ----------- - renamed GetMutex to GetMRMutex. - MonoCameraSensor supports multiple formats. Defauls is still R8G8B8. Modified Paths: -------------- code/gazebo/trunk/server/Global.hh code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/Simulator.hh code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc code/gazebo/trunk/server/physics/ode/ODEPhysics.cc code/gazebo/trunk/server/rendering/OgreCamera.cc code/gazebo/trunk/server/rendering/OgreCamera.hh code/gazebo/trunk/server/rendering/OgreCreator.cc code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc Modified: code/gazebo/trunk/server/Global.hh =================================================================== --- code/gazebo/trunk/server/Global.hh 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/Global.hh 2009-05-29 02:25:59 UTC (rev 7737) @@ -80,4 +80,6 @@ #define ROUND(x) ( (int)( floor((x)+0.5) ) ) +//#define TIMING + #endif Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/Simulator.cc 2009-05-29 02:25:59 UTC (rev 7737) @@ -628,6 +628,9 @@ while (!this->userQuit) { +#ifdef TIMING + double tmpT1 = this->GetWallTime(); +#endif currTime = this->GetRealTime(); if (physicsUpdateRate == 0 || @@ -666,12 +669,16 @@ this->userQuit = true; break; } +#ifdef TIMING + double tmpT2 = this->GetWallTime(); + std::cout << " Simulator::PhysicsLoop() DT(" << tmpT2-tmpT1 << ")" << std::endl; +#endif } } //////////////////////////////////////////////////////////////////////////////// /// Get the simulator mutex -boost::recursive_mutex *Simulator::GetMutex() +boost::recursive_mutex *Simulator::GetMRMutex() { return this->mutex; } Modified: code/gazebo/trunk/server/Simulator.hh =================================================================== --- code/gazebo/trunk/server/Simulator.hh 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/Simulator.hh 2009-05-29 02:25:59 UTC (rev 7737) @@ -179,7 +179,7 @@ public: Body *GetParentBody( Entity *entity ) const; /// \brief Get the simulator mutex - public:boost::recursive_mutex *GetMutex(); + public:boost::recursive_mutex *GetMRMutex(); /// \brief Function to run gui. Used by guiThread private: void PhysicsLoop(); Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/World.cc 2009-05-29 02:25:59 UTC (rev 7737) @@ -363,7 +363,7 @@ // Add a new entity to the world void World::InsertEntity( std::string xmlString) { - boost::recursive_mutex::scoped_lock lock(*Simulator::Instance()->GetMutex()); + boost::recursive_mutex::scoped_lock lock(*Simulator::Instance()->GetMRMutex()); this->toLoadEntities.push_back( xmlString ); } @@ -371,7 +371,7 @@ // Load all the entities that have been queued void World::ProcessEntitiesToLoad() { - boost::recursive_mutex::scoped_lock lock(*Simulator::Instance()->GetMutex()); + boost::recursive_mutex::scoped_lock lock(*Simulator::Instance()->GetMRMutex()); std::vector< std::string >::iterator iter; for (iter = this->toLoadEntities.begin(); Modified: code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc =================================================================== --- code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc 2009-05-29 02:25:59 UTC (rev 7737) @@ -128,7 +128,7 @@ data->width = this->myParent->GetImageWidth(); data->height = this->myParent->GetImageHeight(); - data->image_size = data->width * data->height * 3; + data->image_size = data->width * data->height * this->myParent->GetImageDepth(); // GetFOV() returns radians data->hfov = *(this->myParent->GetHFOV()); @@ -150,6 +150,7 @@ src = this->myParent->GetImageData(0); dst = data->image; + boost::recursive_mutex::scoped_lock mr_lock(*Simulator::Instance()->GetMRMutex()); memcpy(dst, src, data->image_size); this->myParent->EnableSaveFrame( data->saveFrames ); Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-05-29 02:25:59 UTC (rev 7737) @@ -343,8 +343,18 @@ { double h, kp, kd; - // skip 0 depth contacts - if(contactGeoms[i].depth == 0) + if (0) + std::cout << "dContactGeoms: " + << " geom1: " << geom1->GetName() + << " geom2: " << geom2->GetName() + << " contact points: " << numc + << " contact: " << i + << " pos: " << contactGeoms[i].pos[0]<<","<< contactGeoms[i].pos[1]<<","<< contactGeoms[i].pos[2]<<","<< contactGeoms[i].pos[3] + << " norm: " << contactGeoms[i].normal[0]<<","<< contactGeoms[i].normal[1]<<","<< contactGeoms[i].normal[2]<<","<< contactGeoms[i].normal[3] + << " depth: " << contactGeoms[i].depth + << std::endl; + // skip negative depth contacts + if(contactGeoms[i].depth < 0) continue; contact.geom = contactGeoms[i]; Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.cc 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2009-05-29 02:25:59 UTC (rev 7737) @@ -73,6 +73,7 @@ this->imageSizeP = new ParamT< Vector2<int> >("imageSize", Vector2<int>(320, 240),0); this->visMaskP = new ParamT<std::string>("mask","none",0); this->hfovP = new ParamT<Angle>("hfov", Angle(DTOR(60)),0); + this->imageFormatP = new ParamT<std::string>("imageFormat", "R8G8B8", 0); Param::End(); this->captureData = false; @@ -96,6 +97,7 @@ delete this->saveFramesP; delete this->savePathnameP; delete this->imageSizeP; + delete this->imageFormatP; delete this->visMaskP; delete this->hfovP; } @@ -114,6 +116,7 @@ this->saveFramesP->Load(node); this->savePathnameP->Load(node); this->imageSizeP->Load(node); + this->imageFormatP->Load(node); this->visMaskP->Load(node); this->hfovP->Load(node); @@ -121,6 +124,18 @@ { this->visibilityMask ^= GZ_LASER_CAMERA; } + + if (this->imageFormatP->GetValue() == "L8") + this->imageFormat = Ogre::PF_L8; + else if (this->imageFormatP->GetValue() == "R8G8B8") + this->imageFormat = Ogre::PF_R8G8B8; + else if (this->imageFormatP->GetValue() == "B8G8R8") + this->imageFormat = Ogre::PF_B8G8R8; + else + { + std::cerr << "Error parsing image format, using default Ogre::PF_R8G8B8\n"; + this->imageFormat = Ogre::PF_R8G8B8; + } } // Create the directory to store frames @@ -153,6 +168,7 @@ stream << prefix << (*this->saveFramesP) << "\n"; stream << prefix << (*this->savePathnameP) << "\n"; stream << prefix << (*this->imageSizeP) << "\n"; + stream << prefix << (*this->imageFormatP) << "\n"; stream << prefix << (*this->visMaskP) << "\n"; stream << prefix << (*this->hfovP) << "\n"; } @@ -224,19 +240,21 @@ if (this->captureData) { + boost::recursive_mutex::scoped_lock mr_lock(*Simulator::Instance()->GetMRMutex()); Ogre::HardwarePixelBufferSharedPtr mBuffer; size_t size; // Get access to the buffer and make an image and write it to file mBuffer = this->renderTexture->getBuffer(0, 0); - size = this->imageSizeP->GetValue().x * this->imageSizeP->GetValue().y * 3; + size = this->imageSizeP->GetValue().x * this->imageSizeP->GetValue().y * this->GetImageDepth(); // Allocate buffer if (!this->saveFrameBuffer) this->saveFrameBuffer = new unsigned char[size]; memset(this->saveFrameBuffer,128,size); + mBuffer->lock(Ogre::HardwarePixelBuffer::HBL_READ_ONLY); int top = (int)((mBuffer->getHeight() - this->imageSizeP->GetValue().y) / 2.0); @@ -252,7 +270,7 @@ this->imageSizeP->GetValue().x, this->imageSizeP->GetValue().y, 1, - Ogre::PF_B8G8R8, + this->imageFormat, this->saveFrameBuffer) ); @@ -353,6 +371,30 @@ } ////////////////////////////////////////////////////////////////////////////// +/// \brief Get the height of the image +int OgreCamera::GetImageDepth() const +{ + if (this->imageFormatP->GetValue() == "L8") + return 1; + else if (this->imageFormatP->GetValue() == "R8G8B8") + return 3; + else if (this->imageFormatP->GetValue() == "B8G8R8") + return 3; + else + { + std::cerr << "Error parsing image format, using default Ogre::PF_R8G8B8\n"; + return 3; + } +} + +////////////////////////////////////////////////////////////////////////////// +/// \brief Get the height of the image +std::string OgreCamera::GetImageFormat() const +{ + return this->imageFormatP->GetValue(); +} + +////////////////////////////////////////////////////////////////////////////// /// Get the width of the texture unsigned int OgreCamera::GetTextureWidth() const { @@ -371,7 +413,7 @@ // Get the image size in bytes size_t OgreCamera::GetImageByteSize() const { - return this->imageSizeP->GetValue().y * this->imageSizeP->GetValue().x * 3; + return this->imageSizeP->GetValue().y * this->imageSizeP->GetValue().x * this->GetImageDepth(); } @@ -565,8 +607,8 @@ imgData->width = this->imageSizeP->GetValue().x; imgData->height = this->imageSizeP->GetValue().y; - imgData->depth = 1; - imgData->format = Ogre::PF_B8G8R8; + imgData->depth = this->GetImageDepth(); + imgData->format = this->imageFormat; size = this->GetImageByteSize(); // Wrap buffer in a chunk Modified: code/gazebo/trunk/server/rendering/OgreCamera.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.hh 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/rendering/OgreCamera.hh 2009-05-29 02:25:59 UTC (rev 7737) @@ -123,6 +123,12 @@ /// \brief Get the height of the image public: unsigned int GetImageHeight() const; + /// \brief Get the height of the image + public: int GetImageDepth() const; + + /// \brief Get the height of the image + public: std::string GetImageFormat() const; + /// \brief Get the height of the texture public: unsigned int GetTextureHeight() const; @@ -218,8 +224,10 @@ protected: unsigned int saveCount; protected: ParamT<bool> *saveFramesP; protected: ParamT<std::string> *savePathnameP; + protected: ParamT<std::string> *imageFormatP; protected: ParamT<std::string> *visMaskP; + protected: Ogre::PixelFormat imageFormat; protected: unsigned int visibilityMask; protected: Ogre::RenderTarget *renderTarget; Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-05-29 02:25:59 UTC (rev 7737) @@ -759,7 +759,7 @@ } { - boost::recursive_mutex::scoped_lock lock(*Simulator::Instance()->GetMutex()); + boost::recursive_mutex::scoped_lock lock(*Simulator::Instance()->GetMRMutex()); // Update the visuals for (viter = this->visuals.begin(); viter != this->visuals.end(); viter++) Modified: code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc =================================================================== --- code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc 2009-05-29 00:13:51 UTC (rev 7736) +++ code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc 2009-05-29 02:25:59 UTC (rev 7737) @@ -89,7 +89,7 @@ this->imageSizeP->GetValue().x, this->imageSizeP->GetValue().y, 0, - Ogre::PF_R8G8B8, + this->imageFormat, Ogre::TU_RENDERTARGET); this->renderTarget = this->renderTexture->getBuffer()->getRenderTarget(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2009-06-19 07:12:56
|
Revision: 7860 http://playerstage.svn.sourceforge.net/playerstage/?rev=7860&view=rev Author: robotos Date: 2009-06-19 07:12:55 +0000 (Fri, 19 Jun 2009) Log Message: ----------- disallow trimesh and cameras on non rendering engine setups Modified Paths: -------------- code/gazebo/trunk/server/physics/TrimeshGeom.cc code/gazebo/trunk/server/rendering/OgreCamera.cc Modified: code/gazebo/trunk/server/physics/TrimeshGeom.cc =================================================================== --- code/gazebo/trunk/server/physics/TrimeshGeom.cc 2009-06-18 15:24:34 UTC (rev 7859) +++ code/gazebo/trunk/server/physics/TrimeshGeom.cc 2009-06-19 07:12:55 UTC (rev 7860) @@ -117,6 +117,9 @@ this->meshNameP->Load(node); this->scaleP->Load(node); + + if (!Simulator::Instance()->GetRenderEngineEnabled()) + gzthrow("Trimesh objects are not supported when running Gazebo without rendering engine"); mesh = Ogre::MeshManager::getSingleton().load(this->meshNameP->GetValue(),Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.cc 2009-06-18 15:24:34 UTC (rev 7859) +++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2009-06-19 07:12:55 UTC (rev 7860) @@ -107,6 +107,9 @@ void OgreCamera::LoadCam( XMLConfigNode *node ) { + if (!Simulator::Instance()->GetRenderEngineEnabled()) + gzthrow("Cameras can not be used when running Gazebo without rendering engine"); + this->visibilityMask = GZ_ALL_CAMERA; if (node) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2009-06-19 22:48:17
|
Revision: 7857 http://playerstage.svn.sourceforge.net/playerstage/?rev=7857&view=rev Author: robotos Date: 2009-06-18 13:04:08 +0000 (Thu, 18 Jun 2009) Log Message: ----------- Check objects on exit code paths. Move check for existance of file from C to C++. Modified Paths: -------------- code/gazebo/trunk/server/GazeboConfig.cc code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/XMLConfig.cc code/gazebo/trunk/server/main.cc Modified: code/gazebo/trunk/server/GazeboConfig.cc =================================================================== --- code/gazebo/trunk/server/GazeboConfig.cc 2009-06-18 11:28:09 UTC (rev 7856) +++ code/gazebo/trunk/server/GazeboConfig.cc 2009-06-18 13:04:08 UTC (rev 7857) @@ -88,7 +88,7 @@ this->gazeboPaths.push_back(str.substr(pos1,str.size()-pos1)); } - if (cfgFile) + if (cfgFile.is_open()) { XMLConfig rc; XMLConfigNode *node; Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-06-18 11:28:09 UTC (rev 7856) +++ code/gazebo/trunk/server/Simulator.cc 2009-06-18 13:04:08 UTC (rev 7857) @@ -241,6 +241,7 @@ } this->loaded=true; + } //////////////////////////////////////////////////////////////////////////////// @@ -259,6 +260,9 @@ gzthrow("Failed to Initialize the World\n" << e); } + // This is not a debug line. This is useful for external programs that + // launch Gazebo and wait till it is ready + std::cout << "Gazebo successfully initialized" << std::endl; } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-06-18 11:28:09 UTC (rev 7856) +++ code/gazebo/trunk/server/World.cc 2009-06-18 13:04:08 UTC (rev 7857) @@ -294,12 +294,14 @@ (*miter)->Fini(); } - this->physicsEngine->Fini(); + if (this->physicsEngine) + this->physicsEngine->Fini(); // Done with the external interface try { - this->simIface->Destroy(); + if (this->simIface) + this->simIface->Destroy(); } catch (std::string e) { @@ -308,7 +310,8 @@ try { - this->server->Fini(); + if (this->server) + this->server->Fini(); } catch (std::string e) { Modified: code/gazebo/trunk/server/XMLConfig.cc =================================================================== --- code/gazebo/trunk/server/XMLConfig.cc 2009-06-18 11:28:09 UTC (rev 7856) +++ code/gazebo/trunk/server/XMLConfig.cc 2009-06-18 13:04:08 UTC (rev 7857) @@ -29,6 +29,7 @@ #include <math.h> #include <string.h> #include <iostream> +#include <fstream> #include <sstream> #include <libxml/xinclude.h> @@ -67,6 +68,14 @@ { this->filename = filename; + std::ifstream fin; + fin.open(this->filename.c_str(), std::ios::in); + if( !fin.is_open() ) + { + gzthrow( "The world file can not be opened, check path and permissions" ); + } + fin.close(); + // Enable line numbering xmlLineNumbersDefault( 1 ); Modified: code/gazebo/trunk/server/main.cc =================================================================== --- code/gazebo/trunk/server/main.cc 2009-06-18 11:28:09 UTC (rev 7856) +++ code/gazebo/trunk/server/main.cc 2009-06-18 13:04:08 UTC (rev 7857) @@ -233,18 +233,6 @@ // Get the world file name worldFileName = argv[0]; - tmpFile = fopen(worldFileName, "r"); - - if (tmpFile == NULL) - { - char tmpStr[256]; - sprintf(tmpStr, "WorldFile [%s]", worldFileName); - - perror(tmpStr); - return -1; - } - fclose(tmpFile); - return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2009-06-21 14:00:46
|
Revision: 7867 http://playerstage.svn.sourceforge.net/playerstage/?rev=7867&view=rev Author: robotos Date: 2009-06-21 13:59:20 +0000 (Sun, 21 Jun 2009) Log Message: ----------- laserFiducialID and laserRetro properties for models. This not only saves typing but also .model files with no fiducial information can be fiducialized in the .world file. Modified Paths: -------------- code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/Model.hh code/gazebo/trunk/server/physics/Body.cc code/gazebo/trunk/server/physics/Body.hh Modified: code/gazebo/trunk/server/Model.cc =================================================================== --- code/gazebo/trunk/server/Model.cc 2009-06-20 13:07:12 UTC (rev 7866) +++ code/gazebo/trunk/server/Model.cc 2009-06-21 13:59:20 UTC (rev 7867) @@ -84,6 +84,12 @@ this->collideP = new ParamT<std::string>("collide", "all", 0); this->collideP->Callback( &Model::SetCollideMode, this ); + this->laserFiducialP = new ParamT<int>("laserFiducialId", -1, 0); + this->laserFiducialP->Callback( &Model::SetLaserFiducialId, this ); + + this->laserRetroP = new ParamT<float>("laserRetro", -1, 0); + this->laserRetroP->Callback( &Model::SetLaserRetro, this ); + Param::End(); this->graphicsHandler = NULL; @@ -245,6 +251,9 @@ this->SetCollideMode( **this->collideP ); + this->SetLaserFiducialId( **this->laserFiducialP); + this->SetLaserRetro( **this->laserRetroP); + // Create the graphics iface handler this->graphicsHandler = new GraphicsIfaceHandler(); this->graphicsHandler->Load(this->GetName(), this); @@ -975,6 +984,38 @@ } //////////////////////////////////////////////////////////////////////////////// +/// Set the collide mode of the model +void Model::SetLaserFiducialId( const int &id ) +{ + Body *body; + + std::map<std::string, Body* >::iterator iter; + + for (iter=this->bodies.begin(); iter!=this->bodies.end(); iter++) + { + body = iter->second; + + body->SetLaserFiducialId( id ); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the collide mode of the model +void Model::SetLaserRetro( const float &retro ) +{ + Body *body; + + std::map<std::string, Body* >::iterator iter; + + for (iter=this->bodies.begin(); iter!=this->bodies.end(); iter++) + { + body = iter->second; + + body->SetLaserRetro( retro ); + } +} + +//////////////////////////////////////////////////////////////////////////////// // Load a renderable model (like a light source). void Model::LoadRenderable(XMLConfigNode *node) { Modified: code/gazebo/trunk/server/Model.hh =================================================================== --- code/gazebo/trunk/server/Model.hh 2009-06-20 13:07:12 UTC (rev 7866) +++ code/gazebo/trunk/server/Model.hh 2009-06-21 13:59:20 UTC (rev 7867) @@ -178,6 +178,12 @@ /// \brief Set the collide mode of the model public: void SetCollideMode( const std::string &m ); + /// \brief Set the laser fiducial integer Id of the model + public: void SetLaserFiducialId( const int &id ); + + /// \brief Set the laser retro reflectiveness of the model + public: void SetLaserRetro( const float &retro ); + /// \brief Load a body helper function /// \param node XML Configuration node private: void LoadBody(XMLConfigNode *node); @@ -230,6 +236,8 @@ private: ParamT<std::string> *myBodyNameP; private: ParamT<bool> *enableGravityP; private: ParamT<bool> *enableFrictionP; + private: ParamT<int> *laserFiducialP; + private: ParamT<float> *laserRetroP; private: ParamT<std::string> *collideP; Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2009-06-20 13:07:12 UTC (rev 7866) +++ code/gazebo/trunk/server/physics/Body.cc 2009-06-21 13:59:20 UTC (rev 7867) @@ -364,6 +364,34 @@ } //////////////////////////////////////////////////////////////////////////////// +/// Set the laser fiducial integer id of this body +void Body::SetLaserFiducialId(int id) +{ + std::map< std::string, Geom* >::iterator giter; + + for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) + { + giter->second->SetLaserFiducialId( id ); + } + +} + + +//////////////////////////////////////////////////////////////////////////////// +/// Set the laser retro reflectiveness of this body +void Body::SetLaserRetro(float retro) +{ + std::map< std::string, Geom* >::iterator giter; + + for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) + { + giter->second->SetLaserRetro( retro ); + } + +} + + +//////////////////////////////////////////////////////////////////////////////// // Initialize the body void Body::Init() { Modified: code/gazebo/trunk/server/physics/Body.hh =================================================================== --- code/gazebo/trunk/server/physics/Body.hh 2009-06-20 13:07:12 UTC (rev 7866) +++ code/gazebo/trunk/server/physics/Body.hh 2009-06-21 13:59:20 UTC (rev 7867) @@ -138,6 +138,12 @@ // with other bodies even if they share the same parent. public: bool GetSelfCollide(); + /// \brief Set the laser fiducial integer id + public: void SetLaserFiducialId(int id); + + /// \brief Set the laser retro reflectiveness + public: void SetLaserRetro(float retro); + /// \brief Set the linear velocity of the body public: void SetLinearVel(const Vector3 &vel); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-06-22 15:54:44
|
Revision: 7869 http://playerstage.svn.sourceforge.net/playerstage/?rev=7869&view=rev Author: natepak Date: 2009-06-22 15:54:22 +0000 (Mon, 22 Jun 2009) Log Message: ----------- Added model namespace to gazebo iface names Modified Paths: -------------- code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/controllers/Controller.cc Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-06-21 23:15:55 UTC (rev 7868) +++ code/gazebo/trunk/server/Simulator.cc 2009-06-22 15:54:22 UTC (rev 7869) @@ -114,11 +114,6 @@ this->physicsThread = NULL; } - if (this->mutex) - { - delete this->mutex; - this->mutex = NULL; - } } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/controllers/Controller.cc =================================================================== --- code/gazebo/trunk/server/controllers/Controller.cc 2009-06-21 23:15:55 UTC (rev 7868) +++ code/gazebo/trunk/server/controllers/Controller.cc 2009-06-22 15:54:22 UTC (rev 7869) @@ -103,6 +103,16 @@ // Get the name of the iface std::string ifaceName = childNode->GetString("name","",1); + // Constructor the heirarchical name for the iface + Entity *p = parent; + while (p != NULL) + { + Model *m = dynamic_cast<Model*>(p); + if (m) + ifaceName.insert(0, m->GetName()+"::"); + p = p->GetParent(); + } + try { // Use the factory to get a new iface based on the type @@ -277,4 +287,4 @@ gzthrow(stream.str()); } return iface; -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-06-27 00:08:46
|
Revision: 7917 http://playerstage.svn.sourceforge.net/playerstage/?rev=7917&view=rev Author: asadat Date: 2009-06-27 00:08:44 +0000 (Sat, 27 Jun 2009) Log Message: ----------- added some methods to get the child interfaces of a model/body/sensor. Modified Paths: -------------- code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/Model.hh code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/World.hh code/gazebo/trunk/server/controllers/Controller.cc code/gazebo/trunk/server/controllers/Controller.hh code/gazebo/trunk/server/physics/Body.cc code/gazebo/trunk/server/physics/Body.hh code/gazebo/trunk/server/sensors/Sensor.cc code/gazebo/trunk/server/sensors/Sensor.hh Modified: code/gazebo/trunk/server/Model.cc =================================================================== --- code/gazebo/trunk/server/Model.cc 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/Model.cc 2009-06-27 00:08:44 UTC (rev 7917) @@ -49,6 +49,7 @@ #include "IfaceFactory.hh" #include "Model.hh" + #ifdef TIMING #include "Simulator.hh" #endif @@ -1108,3 +1109,47 @@ } } + + +///////////////////////////////////////////////////////////////////////////////////// +// Get the list of model interfaces e.g "pioneer2dx_model1::laser::laser_iface0->laser" +void Model::GetModelInterfaceNames(std::vector<std::string>& list) const{ + + + //std::vector<Entity*>::iterator eiter; + std::map<std::string, Controller* >::const_iterator contIter; + + for (contIter=this->controllers.begin(); + contIter!=this->controllers.end(); contIter++) + { + contIter->second->GetInterfaceNames(list); + + } + + + std::map< std::string, Body* >::const_iterator biter; + + for (biter=this->bodies.begin(); biter != this->bodies.end(); biter++) + { + + biter->second->GetInterfaceNames(list); + + + } + + + +/* + for (eiter=this->GetChildren().begin(); eiter!=this->GetChildren().end(); eiter++) + { + Model* m; + m = dynamic_cast<Model*>(*eiter); + if(m) + m->GetModelInterfaceNames(list); + + } +*/ + +} + + Modified: code/gazebo/trunk/server/Model.hh =================================================================== --- code/gazebo/trunk/server/Model.hh 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/Model.hh 2009-06-27 00:08:44 UTC (rev 7917) @@ -39,6 +39,7 @@ #include "Entity.hh" #include "gazebo.h" + namespace boost { class recursive_mutex; @@ -190,6 +191,9 @@ /// \brief Set the laser retro reflectiveness of the model public: void SetLaserRetro( const float &retro ); + /// \brief Get the list of interfaces e.g "pioneer2dx_model1::laser::laser_iface0->laser" + public: void GetModelInterfaceNames(std::vector<std::string>& list) const; + /// \brief Load a body helper function /// \param node XML Configuration node private: void LoadBody(XMLConfigNode *node); Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/World.cc 2009-06-27 00:08:44 UTC (rev 7917) @@ -920,6 +920,177 @@ break; } + case SimulationRequestData::GET_INTERFACE_TYPE: + { + //printf("Model Type Request\n"); + std::vector<std::string> list; + + response->type = req->type; + strcpy( response->modelName, req->modelName); + std::vector<Model*>::iterator miter; + + for (miter=models.begin(); miter!=models.end(); miter++) + GetInterfaceNames((*miter), list); + + std::string mname = req->modelName; + unsigned int i=mname.find("."); + while(i!= std::string::npos){ + + mname.erase(i,1); + mname.insert(i,"::"); + i= mname.find("."); + } + + + std::vector<std::string> candids; + + for(unsigned int j=0;j<list.size();j++){ + + int ind = list[j].find(mname); + if(ind==0 && ind!=std::string::npos && list[j].size() > mname.size()){ + candids.push_back(list[j].substr(ind+mname.size(),list[j].size()-ind-mname.size())); + } + } + + /*for(unsigned int ii=0;ii<candids.size();ii++) + printf("candidatetypes: %s\n",candids[ii].c_str());*/ + + for(i=0; i<candids.size(); i++){ + if(candids[i][0]=='>'){ + + strcpy(response->strValue,candids[i].substr(2,candids[i].size()-2).c_str()); + response->strValue[511]='\0'; + i=candids.size()+5; + + } + } + + if(strcmp(response->strValue,"irarray")==0){ + strcpy(response->strValue,"ranger"); + response->strValue[511]='\0'; + } + + if(i<candids.size()+4) // the model is not an interface + { + + strcpy(response->strValue,"unkown"); + response->strValue[511]='\0'; + + } + + //printf("-> modeltype: %s \n", response->modelType); + + response++; + this->simIface->data->responseCount += 1; + + break; + } + + case SimulationRequestData::GET_MODEL_INTERFACES: + { + + //printf("Requested the children\n"); + //printf("-> %s", req->modelName); + + + response->nChildInterfaces=0; + //std::vector<Entity*>::iterator iter; + std::vector<std::string> list; + + response->type = req->type; + strcpy( response->modelName, req->modelName); + std::vector<Model*>::iterator miter; + + for (miter=models.begin(); miter!=models.end(); miter++) + GetInterfaceNames((*miter), list); + /* + for(unsigned int ii=0;ii<list.size();ii++) + printf("interface: %s\n",list[ii].c_str()); + */ + // removing the ">>type" from the end of each interface names + for(unsigned int jj=0;jj<list.size();jj++){ + unsigned int index = list[jj].find(">>"); + if(index !=std::string::npos) + list[jj].replace(index,list[jj].size(),""); + //printf("-->> %s \n",list[jj].c_str()); + } + + + if(strcmp((char*)req->modelName,"")==0){ + + std::vector<std::string> chlist; + for(unsigned int i=0;i<list.size();i++){ + + std::string str = list[i].substr(0,list[i].find("::")); + std::vector<std::string>::iterator itr; + itr = std::find(chlist.begin(),chlist.end(), str); + + if(itr!=chlist.end() || str=="") + continue; + + chlist.push_back(str); + strcpy(response->childInterfaces[response->nChildInterfaces++],str.c_str()); + response->childInterfaces[response->nChildInterfaces-1][511]='\0'; + } + + + }else{ + + + std::vector<std::string> newlist; + std::string mname = (char*)req->modelName; + + unsigned int i=mname.find("."); + while(i>-1){ + + mname.erase(i,1); + mname.insert(i,"::"); + i= mname.find("."); + } + + for(unsigned int j=0;j<list.size();j++){ + + unsigned int ind = list[j].find(mname); + if(ind==0 && ind!=std::string::npos && list[j].size() > mname.size()){ + newlist.push_back(list[j].substr(ind+mname.size()+2,list[j].size()-ind-mname.size()-2)); + } + } + + /*for(unsigned int ii=0;ii<newlist.size();ii++) + printf("child interface: %s\n",newlist[ii].c_str()); +*/ + std::vector<std::string> chlist; + for( i=0;i<newlist.size();i++){ + + unsigned int indx = newlist[i].find("::"); + indx = (indx==std::string::npos)?newlist[i].size():indx; + std::string str = newlist[i].substr(0,indx); + std::vector<std::string>::iterator itr; + itr = std::find(chlist.begin(),chlist.end(), str); + + if(itr!=chlist.end() || str=="") + continue; + + chlist.push_back(str); + // Adding the parent name to the child name e.g "parent.child" + str=mname+"::"+str; + + strcpy(response->childInterfaces[response->nChildInterfaces++],str.c_str()); + response->childInterfaces[response->nChildInterfaces-1][511]='\0'; + } + + + + + + } + + response++; + this->simIface->data->responseCount += 1; + + + break; + } case SimulationRequestData::GO: { this->simPauseTime = Simulator::Instance()->GetSimTime() @@ -946,7 +1117,7 @@ } else { - gzerr(0) << "Invalid model name[" << req->modelName << "] in simulation interface Set Pose 2d Request.\n"; + gzerr(0) << "Invalid model name[" << req->modelName << "] in simulation interface Get Children Request.\n"; } break; } @@ -983,3 +1154,25 @@ this->toDeleteModels.clear(); } +void World::GetInterfaceNames(Entity* en, std::vector<std::string>& list){ + + + Model* m = dynamic_cast<Model*>(en); + if(m){ + m->GetModelInterfaceNames(list); + } + + std::vector<Entity*>::iterator citer; + for (citer=en->GetChildren().begin(); citer!=en->GetChildren().end(); citer++) + { + + + this->GetInterfaceNames((*citer),list); + + + } + +} + + + Modified: code/gazebo/trunk/server/World.hh =================================================================== --- code/gazebo/trunk/server/World.hh 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/World.hh 2009-06-27 00:08:44 UTC (rev 7917) @@ -34,6 +34,7 @@ #include "SingletonT.hh" #include "Vector3.hh" #include "Pose3d.hh" +#include "Entity.hh" namespace gazebo { @@ -202,6 +203,9 @@ /// \brief Update the simulation iface private: void UpdateSimulationIface(); + /// \brif Get the names of interfaces defined in the tree of a model + private: void GetInterfaceNames(Entity* m, std::vector<std::string>& list); + /// Pointer the physics engine private: PhysicsEngine *physicsEngine; Modified: code/gazebo/trunk/server/controllers/Controller.cc =================================================================== --- code/gazebo/trunk/server/controllers/Controller.cc 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/controllers/Controller.cc 2009-06-27 00:08:44 UTC (rev 7917) @@ -288,3 +288,18 @@ } return iface; } + +void Controller::GetInterfaceNames(std::vector<std::string>& list) const{ + + std::vector<Iface*>::const_iterator iter; + + for (iter = this->ifaces.begin(); iter != this->ifaces.end(); iter++) + { + std::string str; + str=(*iter)->GetId()+">>"+(*iter)->GetType(); + list.push_back(str); + + } + + +} Modified: code/gazebo/trunk/server/controllers/Controller.hh =================================================================== --- code/gazebo/trunk/server/controllers/Controller.hh 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/controllers/Controller.hh 2009-06-27 00:08:44 UTC (rev 7917) @@ -99,6 +99,8 @@ /// \return The name of the controller public: std::string GetName() const; + public: void GetInterfaceNames(std::vector<std::string>& list) const; + /// \brief Return Iface by type /// \param type The type of the iface to retrieve /// \param number If several ifaces of the same type present, which one Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/physics/Body.cc 2009-06-27 00:08:44 UTC (rev 7917) @@ -1289,6 +1289,19 @@ return this->sensors; } +//////////////////////////////////////////////////////////////////////////////////////// +/// \brief Get the list of interfaces e.g "pioneer2dx_model1::laser::laser_iface0->laser" +void Body::GetInterfaceNames(std::vector<std::string>& list) const{ + + std::vector< Sensor* >::const_iterator iter; + + for (iter = this->sensors.begin(); iter != this->sensors.end(); iter++) + { + (*iter)->GetInterfaceNames(list); + } + +} + //////////////////////////////////////////////////////////////////////////////// /// Get the size of the body void Body::GetBoundingBox(Vector3 &min, Vector3 &max ) const Modified: code/gazebo/trunk/server/physics/Body.hh =================================================================== --- code/gazebo/trunk/server/physics/Body.hh 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/physics/Body.hh 2009-06-27 00:08:44 UTC (rev 7917) @@ -192,6 +192,9 @@ /// \brief Get the mass of the body public: float GetMass() const { return mass.mass; } + /// \brief Get the list of interfaces e.g "pioneer2dx_model1::laser::laser_iface0->laser" + public: void GetInterfaceNames(std::vector<std::string>& list) const; + /// \brief Get a sensor by name public: Sensor *GetSensor( const std::string &name ) const; Modified: code/gazebo/trunk/server/sensors/Sensor.cc =================================================================== --- code/gazebo/trunk/server/sensors/Sensor.cc 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/sensors/Sensor.cc 2009-06-27 00:08:44 UTC (rev 7917) @@ -229,3 +229,9 @@ { return this->body->GetPose(); } +/////////////////////////////////////////////////////////////////////////////// +/// Get the name of the interfaces define in the sensor controller +void Sensor::GetInterfaceNames(std::vector<std::string>& list) const +{ + controller->GetInterfaceNames(list); +} Modified: code/gazebo/trunk/server/sensors/Sensor.hh =================================================================== --- code/gazebo/trunk/server/sensors/Sensor.hh 2009-06-27 00:06:41 UTC (rev 7916) +++ code/gazebo/trunk/server/sensors/Sensor.hh 2009-06-27 00:08:44 UTC (rev 7917) @@ -69,8 +69,14 @@ /// \brief Finalize the sensor public: void Fini(); + /// \brief Get the type of the sensor + public: std::string GetSensorType(){return typeName;} + /// \brief Get the current pose public: virtual Pose3d GetPose() const; + + /// \brief Get the name of the interfaces define in the sensor controller + public: void GetInterfaceNames(std::vector<std::string>& list) const; /// \brief Set whether the sensor is active or not public: void SetActive(bool value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-07-23 01:11:16
|
Revision: 8082 http://playerstage.svn.sourceforge.net/playerstage/?rev=8082&view=rev Author: natepak Date: 2009-07-23 01:11:01 +0000 (Thu, 23 Jul 2009) Log Message: ----------- Added dInitODE2 and thread safety for ODE Modified Paths: -------------- code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/physics/PhysicsEngine.hh code/gazebo/trunk/server/physics/ode/ODEPhysics.cc code/gazebo/trunk/server/physics/ode/ODEPhysics.hh Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-07-22 22:37:08 UTC (rev 8081) +++ code/gazebo/trunk/server/Simulator.cc 2009-07-23 01:11:01 UTC (rev 8082) @@ -599,6 +599,8 @@ { World *world = World::Instance(); + world->GetPhysicsEngine()->InitForThread(); + double step = world->GetPhysicsEngine()->GetStepTime(); double physicsUpdateRate = world->GetPhysicsEngine()->GetUpdateRate(); double physicsUpdatePeriod = 1.0 / physicsUpdateRate; Modified: code/gazebo/trunk/server/physics/PhysicsEngine.hh =================================================================== --- code/gazebo/trunk/server/physics/PhysicsEngine.hh 2009-07-22 22:37:08 UTC (rev 8081) +++ code/gazebo/trunk/server/physics/PhysicsEngine.hh 2009-07-23 01:11:01 UTC (rev 8082) @@ -95,6 +95,9 @@ /// \brief Initialize the physics engine public: virtual void Init() = 0; + + /// \brief Initialize for separate thread + public: virtual void InitForThread() = 0; /// \brief Update the physics engine collision public: virtual void UpdateCollision() = 0; Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-07-22 22:37:08 UTC (rev 8081) +++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-07-23 01:11:01 UTC (rev 8082) @@ -56,8 +56,10 @@ : PhysicsEngine() { // Collision detection init - dInitODE(); + dInitODE2(0); + dAllocateODEDataForThread(dAllocateMaskAll); + this->worldId = dWorldCreate(); //this->spaceId = dSimpleSpaceCreate(0); @@ -80,6 +82,8 @@ // Destructor ODEPhysics::~ODEPhysics() { + dCloseODE(); + if (this->spaceId) dSpaceDestroy(this->spaceId); @@ -152,6 +156,13 @@ } //////////////////////////////////////////////////////////////////////////////// +// Initialize for separate thread +void ODEPhysics::InitForThread() +{ + dAllocateODEDataForThread(dAllocateMaskAll); +} + +//////////////////////////////////////////////////////////////////////////////// // Update the ODE collisions, create joints void ODEPhysics::UpdateCollision() { Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.hh =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEPhysics.hh 2009-07-22 22:37:08 UTC (rev 8081) +++ code/gazebo/trunk/server/physics/ode/ODEPhysics.hh 2009-07-23 01:11:01 UTC (rev 8082) @@ -101,6 +101,9 @@ /// \brief Initialize the ODE engine public: virtual void Init(); + /// \brief Initialize for separate thread + public: virtual void InitForThread(); + /// \brief Update the ODE collision public: virtual void UpdateCollision(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hsu...@us...> - 2009-07-30 02:52:33
|
Revision: 8158 http://playerstage.svn.sourceforge.net/playerstage/?rev=8158&view=rev Author: hsujohnhsu Date: 2009-07-30 02:52:18 +0000 (Thu, 30 Jul 2009) Log Message: ----------- fix Model::Reset(): keep pose offset from canonical body to model frame, use for updating model pose. turn off some debugging outputs. Modified Paths: -------------- code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/physics/Body.cc code/gazebo/trunk/server/physics/Body.hh Modified: code/gazebo/trunk/server/Model.cc =================================================================== --- code/gazebo/trunk/server/Model.cc 2009-07-30 02:35:06 UTC (rev 8157) +++ code/gazebo/trunk/server/Model.cc 2009-07-30 02:52:18 UTC (rev 8158) @@ -239,6 +239,8 @@ if (this->canonicalBodyNameP->GetValue().empty()) { + /// FIXME: Model::pose is set to the pose of first body + /// seems like there should be a warning for users this->canonicalBodyNameP->SetValue( this->bodies.begin()->first ); } @@ -457,7 +459,20 @@ if (!this->canonicalBodyNameP->GetValue().empty()) { + /// model pose is the canonical body pose of the body + a transform from body frame to model frame + /// the tranform is defined by initModelOffset in body frame, + + /// recover the transform in inertial frame based on body pose this->pose = this->bodies[this->canonicalBodyNameP->GetValue()]->GetPose(); + Quatern body_rot = this->pose.rot; + Pose3d offset_transform = this->bodies[this->canonicalBodyNameP->GetValue()]->initModelOffset; + Vector3 xyz_offset = (offset_transform.RotatePositionAboutOrigin(body_rot.GetInverse())).pos; + Quatern q_offset = offset_transform.rot; + + // apply transform to get model pose + this->pose.pos = this->pose.pos + xyz_offset; + this->pose.rot = this->pose.CoordRotationAdd(q_offset); + this->xyzP->SetValue(this->pose.pos); this->rpyP->SetValue(this->pose.rot); } @@ -535,13 +550,13 @@ jiter->second->Reset(); } - /*for (biter=this->bodies.begin(); biter != this->bodies.end(); biter++) + for (biter=this->bodies.begin(); biter != this->bodies.end(); biter++) { biter->second->SetLinearVel(v); biter->second->SetAngularVel(v); biter->second->SetForce(v); biter->second->SetTorque(v); - }*/ + } } Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2009-07-30 02:35:06 UTC (rev 8157) +++ code/gazebo/trunk/server/physics/Body.cc 2009-07-30 02:52:18 UTC (rev 8158) @@ -208,6 +208,12 @@ initPose.pos = **(this->xyzP); initPose.rot = **(this->rpyP); + // save transform from this Parent Model Frame to this Body Frame + // this is only used in setting Model pose from canonicalBody + // the true model pose given a canonical body is + // this body's pose - this body's offsetFromModelFrame + this->initModelOffset = initPose.CoordPoseSolve(Pose3d()); + childNode = node->GetChildByNSPrefix("geom"); // Load the geometries @@ -253,7 +259,6 @@ } this->SetPose(initPose); - } //////////////////////////////////////////////////////////////////////////////// @@ -936,23 +941,23 @@ // get pose with comPose set to oldPose // get pose with comPose set to newPose // - std::cout << " name : " << this->GetName(); - std::cout << " pose : " << this->GetPose(); + //std::cout << " name : " << this->GetName(); + //std::cout << " pose : " << this->GetPose(); // get pose of gazebo body origin given new comPose this->comPose = newPose; this->UpdatePose(); - std::cout << " UpdatePose : " << this->GetPose(); + //std::cout << " UpdatePose : " << this->GetPose(); tmpPose = this->GetPose(); - std::cout << " tmpPose : " << tmpPose; + //std::cout << " tmpPose : " << tmpPose; // set pose this->comPose = oldPose; - std::cout << " oldPose : " << oldPose; + //std::cout << " oldPose : " << oldPose; this->SetPose(tmpPose); - std::cout << " final pose : " << this->GetPose(); - std::cout << std::endl; + //std::cout << " final pose : " << this->GetPose(); + //std::cout << std::endl; // Settle on the new CoM pose Modified: code/gazebo/trunk/server/physics/Body.hh =================================================================== --- code/gazebo/trunk/server/physics/Body.hh 2009-07-30 02:35:06 UTC (rev 8157) +++ code/gazebo/trunk/server/physics/Body.hh 2009-07-30 02:52:18 UTC (rev 8158) @@ -235,6 +235,10 @@ private: bool isStatic; + /// Used by Model if this body is the canonical body + /// model pose = body pose + initModelOffset + public: Pose3d initModelOffset; + private: Pose3d comPose; private: Pose3d staticPose; private: Pose3d pose; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |