From: <na...@us...> - 2008-07-16 21:44:56
|
Revision: 6883 http://playerstage.svn.sourceforge.net/playerstage/?rev=6883&view=rev Author: natepak Date: 2008-07-17 04:45:04 +0000 (Thu, 17 Jul 2008) Log Message: ----------- Commented out speed check in main loop. Modified Paths: -------------- code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/rendering/OgreAdaptor.cc Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2008-07-17 03:39:25 UTC (rev 6882) +++ code/gazebo/trunk/server/Simulator.cc 2008-07-17 04:45:04 UTC (rev 6883) @@ -41,7 +41,7 @@ #include "Simulator.hh" -#define MAX_FRAME_RATE 35 +#define MAX_FRAME_RATE 60 using namespace gazebo; @@ -292,10 +292,10 @@ elapsedTime = (this->GetRealTime() - currTime); // Wait if we're going too fast - if ( elapsedTime < 1.0/MAX_FRAME_RATE ) + /*if ( elapsedTime < 1.0/MAX_FRAME_RATE ) { usleep( (int)((1.0/MAX_FRAME_RATE - elapsedTime) * 1e6) ); - } + }*/ if (this->timeout > 0 && this->GetRealTime() > this->timeout) break; Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2008-07-17 03:39:25 UTC (rev 6882) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2008-07-17 04:45:04 UTC (rev 6883) @@ -204,7 +204,8 @@ else { this->sceneType= SCENE_EXT; - this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_CLOSE); + //this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_CLOSE); + this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_FAR); } ambient.r = node->GetTupleDouble("ambient",0,1.0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-08-20 16:29:00
|
Revision: 6971 http://playerstage.svn.sourceforge.net/playerstage/?rev=6971&view=rev Author: natepak Date: 2008-08-20 23:29:10 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Changed from isnan to std::isnan Modified Paths: -------------- code/gazebo/trunk/server/Quatern.hh code/gazebo/trunk/server/physics/Body.cc Modified: code/gazebo/trunk/server/Quatern.hh =================================================================== --- code/gazebo/trunk/server/Quatern.hh 2008-08-20 23:19:02 UTC (rev 6970) +++ code/gazebo/trunk/server/Quatern.hh 2008-08-20 23:29:10 UTC (rev 6971) @@ -29,6 +29,7 @@ #include <iostream> #include <math.h> +#include <cmath> #include "Angle.hh" #include "Vector3.hh" @@ -141,11 +142,11 @@ v.y = v.y * 180.0 / M_PI; v.z = v.z * 180.0 / M_PI; - if (isnan(v.x)) + if (std::isnan(v.x)) v.x = 90.0; - if (isnan(v.y)) + if (std::isnan(v.y)) v.y = 90.0; - if (isnan(v.z)) + if (std::isnan(v.z)) v.z = 90.0; out << v.x << " " << v.y << " " << v.z; Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2008-08-20 23:19:02 UTC (rev 6970) +++ code/gazebo/trunk/server/physics/Body.cc 2008-08-20 23:29:10 UTC (rev 6971) @@ -510,13 +510,13 @@ // Old pose for the CoM oldPose = this->comPose; - if (isnan(this->mass.c[0])) + if (std::isnan(this->mass.c[0])) this->mass.c[0] = 0; - if (isnan(this->mass.c[1])) + if (std::isnan(this->mass.c[1])) this->mass.c[1] = 0; - if (isnan(this->mass.c[2])) + if (std::isnan(this->mass.c[2])) this->mass.c[2] = 0; // New pose for the CoM This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-09-02 04:56:23
|
Revision: 7003 http://playerstage.svn.sourceforge.net/playerstage/?rev=7003&view=rev Author: natepak Date: 2008-09-02 11:56:30 +0000 (Tue, 02 Sep 2008) Log Message: ----------- Updates to the GUI Modified Paths: -------------- code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/Model.hh code/gazebo/trunk/server/gui/Gui.cc code/gazebo/trunk/server/gui/Toolbar.cc code/gazebo/trunk/server/gui/Toolbar.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 2008-09-02 01:21:56 UTC (rev 7002) +++ code/gazebo/trunk/server/Model.cc 2008-09-02 11:56:30 UTC (rev 7003) @@ -614,6 +614,13 @@ } //////////////////////////////////////////////////////////////////////////////// +/// Get a map of all the bodies +const std::map<std::string, Body*> *Model::GetBodies() const +{ + return &(this->bodies); +} + +//////////////////////////////////////////////////////////////////////////////// /// Get a body by name Body *Model::GetBody(const std::string &name) { Modified: code/gazebo/trunk/server/Model.hh =================================================================== --- code/gazebo/trunk/server/Model.hh 2008-09-02 01:21:56 UTC (rev 7002) +++ code/gazebo/trunk/server/Model.hh 2008-09-02 11:56:30 UTC (rev 7003) @@ -126,6 +126,9 @@ /// \brief Get a body by name /// \return Pointer to the body public: Body *GetBody(const std::string &name); + + /// \brief Get a map of all the bodies + public: const std::map<std::string, Body*> *GetBodies() const; /// \brief Attach this model to its parent public: void Attach(XMLConfigNode *node); @@ -185,6 +188,7 @@ private: ParamT<std::string> *parentBodyNameP; private: ParamT<std::string> *myBodyNameP; + // Name of a light (if the model is renderable:light) private: std::string lightName; Modified: code/gazebo/trunk/server/gui/Gui.cc =================================================================== --- code/gazebo/trunk/server/gui/Gui.cc 2008-09-02 01:21:56 UTC (rev 7002) +++ code/gazebo/trunk/server/gui/Gui.cc 2008-09-02 11:56:30 UTC (rev 7003) @@ -59,7 +59,7 @@ // The order of creation matters! Menubar first, followed by FrameManager, // then statusbar { - int toolbarWidth = 200; + int toolbarWidth = 250; // Create a main menu new MainMenu(0,0,w(),30,(char *)"MainMenu"); Modified: code/gazebo/trunk/server/gui/Toolbar.cc =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-02 01:21:56 UTC (rev 7002) +++ code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-02 11:56:30 UTC (rev 7003) @@ -27,8 +27,11 @@ #include <stdio.h> #include <FL/Fl_Value_Output.H> #include <FL/Fl_Output.H> +#include <FL/Fl_Input.H> #include <FL/Fl_Button.H> +#include "Body.hh" +#include "Geom.hh" #include "Entity.hh" #include "Model.hh" #include "Simulator.hh" @@ -48,7 +51,7 @@ this->columnWidths[1] = 120; this->columnWidths[2] = 0; - this->entityBrowser = new Fl_Hold_Browser(x+10, y+20, w-20, 25*5, "Attributes"); + this->entityBrowser = new Fl_Hold_Browser(x+10, y+20, w-20, 25*10, "Attributes"); this->entityBrowser->align(FL_ALIGN_TOP); this->entityBrowser->column_char('~'); this->entityBrowser->column_widths( columnWidths ); @@ -68,74 +71,44 @@ void Toolbar::Update() { Entity *entity = Simulator::Instance()->GetSelectedEntity(); - std::vector<Param*> *parameters; - std::vector<Param*>::iterator iter; + this->attrCount = 0; if (entity) { - //Model *model = dynamic_cast<Model *>(entity); + std::string value = "@b@B52@s@cModel "; + this->AddToBrowser(value); + this->AddEntityToAttributeBrowser(entity, ""); - parameters = entity->GetParameters(); - - int i=0; - for (iter = parameters->begin(); iter != parameters->end(); iter++, i++) + Model *model = dynamic_cast<Model *>(entity); + if (model) { + const std::map<std::string, Body *> *bodies = model->GetBodies(); + const std::vector< Geom *> *geoms;; + std::map<std::string, Body *>::const_iterator iter; + std::vector<Geom*>::const_iterator giter; std::string value; - //boost::any anyValue = (*iter)->Get(); - //std::string typeName = (*iter)->GetTypename(); - std::string colorStr = ""; - /*if ( i%2 == 0) - colorStr = "@B50"; - */ + for (iter = bodies->begin(); iter != bodies->end(); iter++) + { + value = "@b@B52@s-Body:"; + this->AddToBrowser(value); + this->AddEntityToAttributeBrowser( iter->second, " " ); - value = colorStr + "@b@s" + (*iter)->GetKey() + ":~" + colorStr + "@s"; - value += (*iter)->GetAsString(); + geoms = iter->second->GetGeoms(); - - // Convert the variable value to a string - /*if (typeName == typeid(float).name()) - value += boost::lexical_cast<std::string>( - boost::any_cast<float>( anyValue )); - else if (typeName == typeid(double).name()) - value += boost::lexical_cast<std::string>( - boost::any_cast<double>( anyValue )); - else if (typeName == typeid(int).name()) - value += boost::lexical_cast<std::string>( - boost::any_cast<int>( anyValue )); - else if (typeName == typeid(bool).name()) - value += boost::lexical_cast<std::string>( - boost::any_cast<bool>(anyValue) ); - else if (typeName == typeid(long).name()) - value += boost::lexical_cast<std::string>( - boost::any_cast<long>(anyValue) ); - else if (typeName == typeid(Quatern).name()) - value += boost::lexical_cast<std::string>( - boost::any_cast<Quatern>( anyValue )); - else if (typeName == typeid(Vector3).name()) - value += boost::lexical_cast<std::string>( - boost::any_cast<Vector3>( anyValue )); - else if (typeName == typeid(std::string).name()) - value += boost::any_cast<std::string>( anyValue ); - else - gzerr(0) << "Unknown typename[" << typeName << "]\n"; - */ - - if (!this->entityBrowser->text(i+1)) - { - this->entityBrowser->add( value.c_str() ); + for (giter = geoms->begin(); giter != geoms->end(); giter++) + { + value = "@b@B52@s -Geom:"; + this->AddToBrowser(value); + this->AddEntityToAttributeBrowser( (*giter), " " ); + } } - else if (strcmp(this->entityBrowser->text(i+1), value.c_str()) != 0) - { - this->entityBrowser->text( i+1, value.c_str() ); - } } // Clear the remaining lines - while ( this->entityBrowser->text(i+1) != NULL ) + while ( this->entityBrowser->text(this->attrCount+1) != NULL ) { - this->entityBrowser->text( i+1, "" ); - i++; + this->AddToBrowser(""); } } @@ -148,3 +121,45 @@ { printf("Callback\n"); } + +//////////////////////////////////////////////////////////////////////////////// +// Add entity to browser +void Toolbar::AddEntityToAttributeBrowser(Entity *entity, std::string prefix) +{ + std::vector<Param*> *parameters; + std::vector<Param*>::iterator iter; + std::string value; + std::string colorStr = ""; + + parameters = entity->GetParameters(); + + // Process all the parameters in the entity + for (iter = parameters->begin(); iter != parameters->end(); iter++) + { + + /*if ( i%2 == 0) + colorStr = "@B50"; + */ + + value = colorStr + "@b@s" + prefix + (*iter)->GetKey() + ":~" + + colorStr + "@s" + (*iter)->GetAsString(); + + this->AddToBrowser( value ); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Add a line to the attribute browser +void Toolbar::AddToBrowser(const std::string &line) +{ + if (!this->entityBrowser->text(this->attrCount+1)) + { + this->entityBrowser->add( line.c_str() ); + } + else if (strcmp(this->entityBrowser->text(this->attrCount+1), line.c_str()) != 0) + { + this->entityBrowser->text( this->attrCount+1, line.c_str() ); + } + + this->attrCount++; +} Modified: code/gazebo/trunk/server/gui/Toolbar.hh =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-02 01:21:56 UTC (rev 7002) +++ code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-02 11:56:30 UTC (rev 7003) @@ -32,10 +32,12 @@ class Fl_Value_Output; class Fl_Output; +class Fl_Input; class Fl_Button; namespace gazebo { + class Entity; /// \brief Toolbar class Toolbar : public Fl_Group @@ -51,9 +53,13 @@ public: static void AttributeBrowserCB( Fl_Widget * w, void *data); + private: void AddEntityToAttributeBrowser(Entity *ent, std::string prefix); + private: void AddToBrowser(const std::string &line); + private: Fl_Hold_Browser *entityBrowser; private: int columnWidths[3]; + private: int attrCount; }; } Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2008-09-02 01:21:56 UTC (rev 7002) +++ code/gazebo/trunk/server/physics/Body.cc 2008-09-02 11:56:30 UTC (rev 7003) @@ -679,3 +679,10 @@ return torque; } + +//////////////////////////////////////////////////////////////////////////////// +/// Get the vector of all geoms +const std::vector<Geom*> *Body::GetGeoms() const +{ + return &(this->geoms); +} Modified: code/gazebo/trunk/server/physics/Body.hh =================================================================== --- code/gazebo/trunk/server/physics/Body.hh 2008-09-02 01:21:56 UTC (rev 7002) +++ code/gazebo/trunk/server/physics/Body.hh 2008-09-02 11:56:30 UTC (rev 7003) @@ -139,6 +139,9 @@ /// \brief Get the torque applied to the body public: Vector3 GetTorque() const; + + /// \brief Get the vector of all geoms + public: const std::vector<Geom*> *GetGeoms() const; /// Load a new geom helper function /// \param node XMLConfigNode used to load the geom This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-09-09 06:05:11
|
Revision: 7006 http://playerstage.svn.sourceforge.net/playerstage/?rev=7006&view=rev Author: natepak Date: 2008-09-09 13:05:16 +0000 (Tue, 09 Sep 2008) Log Message: ----------- Applied patch 2101288 Modified Paths: -------------- code/gazebo/trunk/server/Entity.cc code/gazebo/trunk/server/Entity.hh code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/Model.hh code/gazebo/trunk/server/Param.hh code/gazebo/trunk/server/XMLConfig.cc code/gazebo/trunk/server/XMLConfig.hh code/gazebo/trunk/server/gui/Toolbar.cc code/gazebo/trunk/server/gui/Toolbar.hh code/gazebo/trunk/server/physics/Body.cc code/gazebo/trunk/server/physics/Body.hh code/gazebo/trunk/server/physics/BoxGeom.cc code/gazebo/trunk/server/physics/BoxGeom.hh code/gazebo/trunk/server/physics/CylinderGeom.cc code/gazebo/trunk/server/physics/CylinderGeom.hh code/gazebo/trunk/server/physics/Geom.cc code/gazebo/trunk/server/physics/Geom.hh code/gazebo/trunk/server/physics/PlaneGeom.cc code/gazebo/trunk/server/physics/PlaneGeom.hh code/gazebo/trunk/server/physics/SphereGeom.cc code/gazebo/trunk/server/physics/SphereGeom.hh code/gazebo/trunk/server/rendering/CameraManager.hh code/gazebo/trunk/server/rendering/OgreCreator.cc code/gazebo/trunk/server/rendering/OgreCreator.hh Modified: code/gazebo/trunk/server/Entity.cc =================================================================== --- code/gazebo/trunk/server/Entity.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/Entity.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -45,6 +45,7 @@ Param::Begin(&this->parameters); this->nameP = new ParamT<std::string>("name","",1); this->staticP = new ParamT<bool>("static",false,0); + //this->staticP->Callback( &Entity::SetStatic, this); Param::End(); this->selected = false; @@ -142,7 +143,7 @@ //////////////////////////////////////////////////////////////////////////////// // Set whether this entity is static: immovable -void Entity::SetStatic(bool s) +void Entity::SetStatic(const bool &s) { std::vector< Entity *>::iterator iter; Body *body = NULL; @@ -200,9 +201,29 @@ //////////////////////////////////////////////////////////////////////////////// /// Get the parameters -std::vector<Param*> *Entity::GetParameters() +std::vector<Param*> *Entity::GetParams() { return &this->parameters; } +//////////////////////////////////////////////////////////////////////////////// +/// Get a parameter by name +Param *Entity::GetParam(const std::string &key) const +{ + std::vector<Param*>::const_iterator iter; + Param *result = NULL; + for (iter = this->parameters.begin(); iter != this->parameters.end(); iter++) + { + if ((*iter)->GetKey() == key) + { + result = *iter; + break; + } + } + + if (result == NULL) + gzerr(0) << "Unable to find Param using key[" << key << "]\n"; + + return result; +} Modified: code/gazebo/trunk/server/Entity.hh =================================================================== --- code/gazebo/trunk/server/Entity.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/Entity.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -97,7 +97,7 @@ /// \brief Set whether this entity is static: immovable /// \param s Bool, true = static - public: void SetStatic(bool s); + public: void SetStatic(const bool &s); /// \brief Return whether this entity is static /// \return bool True = static @@ -114,7 +114,10 @@ public: bool operator==(const Entity &ent) const; /// \brief Get the parameters - public: std::vector<Param*> *GetParameters(); + public: std::vector<Param*> *GetParams(); + + /// \brief Get a parameter by name + public: Param *GetParam(const std::string &key) const; /// \brief Parent of this entity protected: Entity *parent; Modified: code/gazebo/trunk/server/Model.cc =================================================================== --- code/gazebo/trunk/server/Model.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/Model.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -62,8 +62,12 @@ Param::Begin(&this->parameters); this->canonicalBodyNameP = new ParamT<std::string>("canonicalBody", std::string(),0); + this->xyzP = new ParamT<Vector3>("xyz", Vector3(0,0,0), 0); + this->xyzP->Callback(&Model::SetPosition, this); + this->rpyP = new ParamT<Quatern>("rpy", Quatern(1,0,0,0), 0); + this->rpyP->Callback( &Model::SetRotation, this); Param::End(); this->parentBodyNameP = NULL; @@ -466,6 +470,26 @@ } //////////////////////////////////////////////////////////////////////////////// +/// Set the position of the model +void Model::SetPosition( const Vector3 &pos) +{ + Pose3d pose = this->GetPose(); + pose.pos = pos; + + this->SetPose(pose); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the rotation of the model +void Model::SetRotation( const Quatern &rot) +{ + Pose3d pose = this->GetPose(); + pose.rot = rot; + + this->SetPose(pose); +} + +//////////////////////////////////////////////////////////////////////////////// // Get the current pose const Pose3d &Model::GetPose() const { @@ -689,6 +713,7 @@ return this->bodies[this->canonicalBodyNameP->GetValue()]; } + //////////////////////////////////////////////////////////////////////////////// // 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 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/Model.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -101,7 +101,13 @@ /// \brief Set the current pose public: void SetPose(const Pose3d &pose); - + + /// \brief Set the position of the model + public: void SetPosition( const Vector3 &pos ); + + /// \brief Set the rotation of the model + public: void SetRotation( const Quatern &rot ); + /// \brief Get the current pose public: const Pose3d &GetPose() const; Modified: code/gazebo/trunk/server/Param.hh =================================================================== --- code/gazebo/trunk/server/Param.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/Param.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -31,6 +31,8 @@ #include <vector> #include <boost/lexical_cast.hpp> #include <boost/any.hpp> +#include <boost/bind.hpp> +#include <boost/signal.hpp> #include <typeinfo> #include <string> @@ -61,6 +63,9 @@ /// \brief Get the type public: virtual std::string GetAsString() const {return std::string();} + /// \brief Set the parameter value from a string + public: virtual void SetFromString(std::string &, bool callback=false) {} + /// List of created parameters private: static std::vector<Param*> *params; @@ -81,8 +86,12 @@ /// \brief Load the param from an XML config file public: void Load(XMLConfigNode *node); + /// \brief Get the parameter value as a string public: virtual std::string GetAsString() const; + /// \brief Set the parameter value from a string + public: virtual void SetFromString( std::string &str, bool callback=false ); + /// \brief Get the value public: T GetValue() const; @@ -97,12 +106,20 @@ return out; } - + + public: template< typename C> + void Callback( void (C::*func)(const T &), C *c) + { + changeSignal.connect( boost::bind( func, c, _1) ); + } + + private: T value; private: T defaultValue; private: int required; + private: boost::signal<void (T)> changeSignal; }; @@ -138,28 +155,39 @@ std::string input = node->GetString(this->key, stream.str(), this->required); + this->SetFromString( input ); + } + + ////////////////////////////////////////////////////////////////////////////// + // Get value as string + template<typename T> + std::string ParamT<T>::GetAsString() const + { + return boost::lexical_cast<std::string>(this->value); + } + + ////////////////////////////////////////////////////////////////////////////// + // Set value from string + template<typename T> + void ParamT<T>::SetFromString(std::string &str, bool callback) + { // "true" and "false" doesn't work properly - if (input == "true") - input = "1"; - else if (input == "false") - input = "0"; + if (str == "true") + str = "1"; + else if (str == "false") + str = "0"; try { - this->value = boost::lexical_cast<T>(input); + this->value = boost::lexical_cast<T>(str); } catch (boost::bad_lexical_cast &e) { std::cerr << "Unable to read value with key[" << this->key << "]\n"; } - } - ////////////////////////////////////////////////////////////////////////////// - // Get value as boost - template<typename T> - std::string ParamT<T>::GetAsString() const - { - return boost::lexical_cast<std::string>(this->value); + if (callback) + this->changeSignal(this->value); } ////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/XMLConfig.cc =================================================================== --- code/gazebo/trunk/server/XMLConfig.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/XMLConfig.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -458,7 +458,7 @@ while (value[i] == ' ') i++; while (value[j] == ' ') j--; result = xmlStrndup(value+i, j-i+1); - delete value; + xmlFree(value); } return result; Modified: code/gazebo/trunk/server/XMLConfig.hh =================================================================== --- code/gazebo/trunk/server/XMLConfig.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/XMLConfig.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -131,7 +131,8 @@ public: std::string GetValue() const; /// \brief Get an attribute string value - public: std::string GetString( const std::string &key, const std::string &def, + public: std::string GetString( const std::string &key, + const std::string &def, int require = 0 ) const; /// \brief Get a attribute character value Modified: code/gazebo/trunk/server/gui/Toolbar.cc =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -57,6 +57,13 @@ this->entityBrowser->column_widths( columnWidths ); this->entityBrowser->callback(&Toolbar::AttributeBrowserCB, this); + y = this->entityBrowser->y() + this->entityBrowser->h() + 20; + this->attributeInput = new Fl_Input(x+10, y, w-20, 20, "Input:"); + this->attributeInput->align(FL_ALIGN_TOP); + this->attributeInput->labelsize(12); + this->attributeInput->when( FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE ); + this->attributeInput->callback(&Toolbar::AttributeInputCB, this); + this->end(); this->resizable(NULL); @@ -64,6 +71,7 @@ Toolbar::~Toolbar() { + delete this->attributeInput; } //////////////////////////////////////////////////////////////////////////////// @@ -83,14 +91,14 @@ if (model) { const std::map<std::string, Body *> *bodies = model->GetBodies(); - const std::vector< Geom *> *geoms;; - std::map<std::string, Body *>::const_iterator iter; - std::vector<Geom*>::const_iterator giter; + const std::map<std::string, Geom *> *geoms; + std::map<std::string, Body*>::const_iterator iter; + std::map<std::string, Geom*>::const_iterator giter; std::string value; for (iter = bodies->begin(); iter != bodies->end(); iter++) { - value = "@b@B52@s-Body:"; + value = "@b@B52@s-Body:~@b@B52@s" + iter->second->GetName(); this->AddToBrowser(value); this->AddEntityToAttributeBrowser( iter->second, " " ); @@ -98,9 +106,9 @@ for (giter = geoms->begin(); giter != geoms->end(); giter++) { - value = "@b@B52@s -Geom:"; + value = "@b@B52@s -Geom:~@b@B52@s" + giter->second->GetName(); this->AddToBrowser(value); - this->AddEntityToAttributeBrowser( (*giter), " " ); + this->AddEntityToAttributeBrowser( giter->second, " " ); } } } @@ -119,10 +127,106 @@ // Attribute browser callback void Toolbar::AttributeBrowserCB( Fl_Widget * w, void *data) { - printf("Callback\n"); + Fl_Hold_Browser *browser = (Fl_Hold_Browser*)(w); + Toolbar *toolbar = (Toolbar*)(data); + int selected = browser->value(); + std::string lineText = browser->text(selected); + std::string lbl; + int beginLbl = 0; + int endLbl = 0; + int beginValue = 0; + + if (lineText.find("-Body") != std::string::npos || + lineText.find("-Geom") != std::string::npos) + { + toolbar->attributeInput->deactivate(); + return; + } + else + toolbar->attributeInput->activate(); + + endLbl = lineText.find("~"); + while (lineText[beginLbl] == '@') beginLbl+=2; + while (lineText[beginLbl] == ' ') beginLbl++; + + beginValue = endLbl+1; + while (lineText[beginValue] == '@') beginValue+=2; + + toolbar->attributeInputLbl = lineText.substr(beginLbl, endLbl-beginLbl); + + toolbar->attributeInput->label(toolbar->attributeInputLbl.c_str()); + + toolbar->attributeInput->value( lineText.substr(beginValue, lineText.size() - beginValue).c_str() ); + + toolbar->attributeInput->redraw(); } //////////////////////////////////////////////////////////////////////////////// +// Attribute modification callback +void Toolbar::AttributeInputCB( Fl_Widget *w, void *data) +{ + Fl_Input *input = (Fl_Input*)(w); + Toolbar *toolbar = (Toolbar*)(data); + Fl_Hold_Browser *browser = toolbar->entityBrowser; + int selected = browser->value(); + Model *model = dynamic_cast<Model*>(Simulator::Instance()->GetSelectedEntity()); + Body *body = NULL; + Geom *geom = NULL; + std::string geomName, bodyName, value, label; + + // Make sure we have a valid model + if (!model) + { + gzerr(0) << "Somehow you selected something that is not a model.\n"; + return; + } + + value = input->value(); + label = input->label(); + + // Get rid of the ':' at the end + label = label.substr(0, label.size()-1); + + // Get the name of the body and geom. + while (selected > 0) + { + std::string lineText = browser->text(selected); + int lastAmp = lineText.rfind("@")+2; + + if (lineText.find("-Geom:") != std::string::npos && geomName.empty()) + geomName = lineText.substr( lastAmp, lineText.size()-lastAmp ); + else if (lineText.find("-Body:") != std::string::npos && bodyName.empty()) + bodyName = lineText.substr( lastAmp, lineText.size()-lastAmp ); + + selected--; + } + + // Get the body + if (!bodyName.empty()) + body = model->GetBody(bodyName); + + // Get the geom + if (!geomName.empty() && body) + geom = body->GetGeom(geomName); + + // Get the parameter + Param *param = NULL; + if (geom) + param = geom->GetParam(label); + else if (body) + param = body->GetParam(label); + else + param = model->GetParam(label); + + if (param) + { + param->SetFromString( value, true ); + } + + std::cout << "Label[" << label << "] Value[" << value << "]\n"; +} + +//////////////////////////////////////////////////////////////////////////////// // Add entity to browser void Toolbar::AddEntityToAttributeBrowser(Entity *entity, std::string prefix) { @@ -131,7 +235,7 @@ std::string value; std::string colorStr = ""; - parameters = entity->GetParameters(); + parameters = entity->GetParams(); // Process all the parameters in the entity for (iter = parameters->begin(); iter != parameters->end(); iter++) Modified: code/gazebo/trunk/server/gui/Toolbar.hh =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -52,6 +52,7 @@ public: void Update(); public: static void AttributeBrowserCB( Fl_Widget * w, void *data); + public: static void AttributeInputCB( Fl_Widget * w, void *data); private: void AddEntityToAttributeBrowser(Entity *ent, std::string prefix); private: void AddToBrowser(const std::string &line); @@ -60,6 +61,9 @@ private: int columnWidths[3]; private: int attrCount; + + private: Fl_Input *attributeInput; + private: std::string attributeInputLbl; }; } Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/Body.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -66,7 +66,10 @@ Param::Begin(&this->parameters); this->xyzP = new ParamT<Vector3>("xyz", Vector3(), 0); + this->xyzP->Callback( &Body::SetPosition, this ); + this->rpyP = new ParamT<Quatern>("rpy", Quatern(), 0); + this->rpyP->Callback( &Body::SetRotation, this ); Param::End(); } @@ -75,12 +78,12 @@ // Destructor Body::~Body() { - std::vector< Geom* >::iterator giter; + std::map< std::string, Geom* >::iterator giter; std::vector< Sensor* >::iterator siter; for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) { - GZ_DELETE (*giter); + GZ_DELETE (giter->second); } this->geoms.clear(); @@ -143,7 +146,7 @@ // Save the body based on our XMLConfig node void Body::Save(std::string &prefix, std::ostream &stream) { - std::vector< Geom* >::iterator giter; + std::map<std::string, Geom* >::iterator giter; std::vector< Sensor* >::iterator siter; Model *model = dynamic_cast<Model*>(this->parent); //Vector3 pose = model->GetPose() - this->GetPose(); @@ -160,7 +163,7 @@ for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) { stream << "\n"; - (*giter)->Save(p, stream); + giter->second->Save(p, stream); } for (siter = this->sensors.begin(); siter != this->sensors.end(); siter++) @@ -213,7 +216,7 @@ void Body::Update() { std::vector< Sensor* >::iterator sensorIter; - std::vector< Geom* >::iterator geomIter; + std::map< std::string, Geom* >::iterator geomIter; this->UpdatePose(); @@ -226,7 +229,7 @@ for (geomIter=this->geoms.begin(); geomIter!=this->geoms.end(); geomIter++) { - (*geomIter)->Update(); + geomIter->second->Update(); } for (sensorIter=this->sensors.begin(); @@ -251,7 +254,13 @@ } } - this->geoms.push_back(geom); + std::map<std::string, Geom*>::iterator iter = this->geoms.find(geom->GetName()); + + if (iter == this->geoms.end()) + this->geoms[geom->GetName()] = geom; + else + gzerr(0) << "Attempting to add two geoms with the same name[" << geom->GetName() << "] to body[" << this->GetName() << "].\n"; + } //////////////////////////////////////////////////////////////////////////////// @@ -267,7 +276,7 @@ Pose3d newPose; this->staticPose = pose; - std::vector<Geom*>::iterator iter; + std::map<std::string, Geom*>::iterator iter; //this->SetPosition(this->staticPose.pos); //this->SetRotation(this->staticPose.rot); @@ -275,9 +284,9 @@ for (iter = this->geoms.begin(); iter != this->geoms.end(); iter++) { //newPose = (*iter)->GetPose() - this->staticPose; - newPose = (*iter)->GetPose() - oldPose; + newPose = iter->second->GetPose() - oldPose; newPose += this->staticPose; - (*iter)->SetPose(newPose); + iter->second->SetPose(newPose); } } else @@ -498,7 +507,7 @@ { const dMass *lmass; Pose3d oldPose, newPose, pose; - std::vector< Geom* >::iterator giter; + std::map< std::string, Geom* >::iterator giter; if (!this->bodyId) return; @@ -508,8 +517,8 @@ for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) { - lmass = (*giter)->GetBodyMassMatrix(); - if ((*giter)->IsPlaceable() && (*giter)->GetGeomId()) + lmass = giter->second->GetBodyMassMatrix(); + if (giter->second->IsPlaceable() && giter->second->GetGeomId()) { dMassAdd( &this->mass, lmass ); } @@ -535,12 +544,12 @@ // Fixup the poses of the geoms (they are attached to the CoM) for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) { - if ((*giter)->IsPlaceable()) + if (giter->second->IsPlaceable()) { this->comPose = oldPose; - pose = (*giter)->GetPose(); + pose = giter->second->GetPose(); this->comPose = newPose; - (*giter)->SetPose(pose, false); + giter->second->SetPose(pose, false); } } @@ -682,7 +691,25 @@ //////////////////////////////////////////////////////////////////////////////// /// Get the vector of all geoms -const std::vector<Geom*> *Body::GetGeoms() const +const std::map<std::string, Geom*> *Body::GetGeoms() const { return &(this->geoms); } + +//////////////////////////////////////////////////////////////////////////////// +/// Get a geom by name +Geom *Body::GetGeom(const std::string &name) const +{ + std::map<std::string, Geom*>::const_iterator iter = this->geoms.find(name); + + if (iter != this->geoms.end()) + { + return iter->second; + } + else + { + gzerr(0) << "Unknown geom[" << name << "]\n"; + return NULL; + } +} + Modified: code/gazebo/trunk/server/physics/Body.hh =================================================================== --- code/gazebo/trunk/server/physics/Body.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/Body.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -28,7 +28,7 @@ #define BODY_HH #include <ode/ode.h> -#include <list> +#include <map> #include <vector> #include "XMLConfig.hh" @@ -141,7 +141,10 @@ public: Vector3 GetTorque() const; /// \brief Get the vector of all geoms - public: const std::vector<Geom*> *GetGeoms() const; + public: const std::map<std::string, Geom*> *GetGeoms() const; + + /// \brief Get a geom by name + public: Geom *GetGeom(const std::string &name) const; /// Load a new geom helper function /// \param node XMLConfigNode used to load the geom @@ -158,7 +161,7 @@ private: void UpdatePose(); /// List of geometries attached to this body - private: std::vector< Geom* > geoms; + private: std::map< std::string, Geom* > geoms; /// List of attached sensors private: std::vector< Sensor* > sensors; Modified: code/gazebo/trunk/server/physics/BoxGeom.cc =================================================================== --- code/gazebo/trunk/server/physics/BoxGeom.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/BoxGeom.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -39,6 +39,7 @@ { Param::Begin(&this->parameters); this->sizeP = new ParamT<Vector3>("size",Vector3(1,1,1),1); + this->sizeP->Callback( &BoxGeom::SetSize, this ); Param::End(); } @@ -55,24 +56,13 @@ void BoxGeom::LoadChild(XMLConfigNode *node) { this->sizeP->Load(node); - - // Initialize box mass matrix - dMassSetBoxTotal(&this->mass, this->massP->GetValue(), - this->sizeP->GetValue().x, - this->sizeP->GetValue().y, - this->sizeP->GetValue().z); - - // Create a box geometry with box mass matrix - this->SetGeom(dCreateBox( 0, this->sizeP->GetValue().x, - this->sizeP->GetValue().y, - this->sizeP->GetValue().z), true ); + this->SetSize( this->sizeP->GetValue() ); } ////////////////////////////////////////////////////////////////////////////// // Set the size of the box -void BoxGeom::SetSize( Vector3 size ) +void BoxGeom::SetSize( const Vector3 &size ) { - this->sizeP->SetValue( size ); // Initialize box mass matrix Modified: code/gazebo/trunk/server/physics/BoxGeom.hh =================================================================== --- code/gazebo/trunk/server/physics/BoxGeom.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/BoxGeom.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -85,7 +85,7 @@ protected: void SaveChild(std::string &prefix, std::ostream &stream); /// \brief Set the size of the box - public: void SetSize( Vector3 size ); + public: void SetSize( const Vector3 &size ); private: ParamT<Vector3> *sizeP; }; Modified: code/gazebo/trunk/server/physics/CylinderGeom.cc =================================================================== --- code/gazebo/trunk/server/physics/CylinderGeom.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/CylinderGeom.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -37,6 +37,8 @@ { Param::Begin(&this->parameters); this->sizeP = new ParamT<Vector2<double> >("size", Vector2<double>(1.0,1.0), 1); + this->sizeP->Callback( &CylinderGeom::SetSize, this); + Param::End(); } @@ -52,14 +54,21 @@ void CylinderGeom::LoadChild(XMLConfigNode *node) { this->sizeP->Load(node); + this->SetSize( this->sizeP->GetValue() ); +} +////////////////////////////////////////////////////////////////////////////// +// Set the size of the cylinder +void CylinderGeom::SetSize( const Vector2<double> &size ) +{ + this->sizeP->SetValue( size ); + // Initialize mass matrix dMassSetCylinderTotal(&this->mass, this->massP->GetValue(), 3, this->sizeP->GetValue().x, this->sizeP->GetValue().y); this->SetGeom( dCreateCylinder( 0, this->sizeP->GetValue().x, this->sizeP->GetValue().y ), true ); - } ////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/physics/CylinderGeom.hh =================================================================== --- code/gazebo/trunk/server/physics/CylinderGeom.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/CylinderGeom.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -77,6 +77,9 @@ /// \brief Destructor public: virtual ~CylinderGeom(); + /// \brief Set the size of the cylinder + public: void SetSize( const Vector2<double> &size ); + /// \brief Load the cylinder protected: void LoadChild(XMLConfigNode *node); Modified: code/gazebo/trunk/server/physics/Geom.cc =================================================================== --- code/gazebo/trunk/server/physics/Geom.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/Geom.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -63,8 +63,14 @@ Param::Begin(&this->parameters); this->massP = new ParamT<double>("mass",0.001,0); + this->massP->Callback( &Geom::SetMass, this); + this->xyzP = new ParamT<Vector3>("xyz", Vector3(), 0); + this->xyzP->Callback( &Geom::SetPosition, this); + this->rpyP = new ParamT<Quatern>("rpy", Quatern(), 0); + this->rpyP->Callback( &Geom::SetRotation, this); + this->laserFiducialIdP = new ParamT<int>("laserFiducialId",-1,0); this->laserRetroP = new ParamT<float>("laserRetro",-1,0); Param::End(); @@ -502,3 +508,13 @@ */ } } + +//////////////////////////////////////////////////////////////////////////////// +/// Set the mass +void Geom::SetMass(const double &mass) +{ + dMassAdjust(&this->mass, mass); + this->body->UpdateCoM(); +} + + Modified: code/gazebo/trunk/server/physics/Geom.hh =================================================================== --- code/gazebo/trunk/server/physics/Geom.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/Geom.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -137,9 +137,12 @@ /// \brief Set the visibility of the joints public: void ShowJoints(bool show); - /// \brief Set the visibility of the physical entity of this geom + /// \brief Set the visibility of the physical entity of this geom public: void ShowPhysics(bool); + /// \brief Set the mass + public: void SetMass(const double &mass); + /// Contact parameters public: ContactParams *contact; Modified: code/gazebo/trunk/server/physics/PlaneGeom.cc =================================================================== --- code/gazebo/trunk/server/physics/PlaneGeom.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/PlaneGeom.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -42,14 +42,26 @@ { Param::Begin(&this->parameters); this->normalP = new ParamT<Vector3>("normal",Vector3(0,0,1),0); + this->normalP->Callback( &PlaneGeom::SetNormal, this ); + this->sizeP = new ParamT<Vector2<double> >("size", Vector2<double>(1000, 1000), 0); + this->sizeP->Callback( &PlaneGeom::SetSize, this ); + this->segmentsP = new ParamT<Vector2<double> >("segments", Vector2<double>(10, 10), 0); + this->segmentsP->Callback( &PlaneGeom::SetSegments, this ); + this->uvTileP = new ParamT<Vector2<double> >("uvTile", Vector2<double>(1, 1), 0); + this->uvTileP->Callback( &PlaneGeom::SetUVTile, this ); + this->materialP = new ParamT<std::string>("material","",1); + this->materialP->Callback( &PlaneGeom::SetMaterial, this ); + this->castShadowsP = new ParamT<bool>("castShadows", false, 0); + this->castShadowsP->Callback( &PlaneGeom::SetCastShadows, this ); + Param::End(); } @@ -83,19 +95,26 @@ { Vector3 perp; - double altitude = 0; - this->normalP->Load(node); this->sizeP->Load(node); this->segmentsP->Load(node); this->uvTileP->Load(node); this->materialP->Load(node); this->castShadowsP->Load(node); + this->CreatePlane(); +} - OgreCreator::CreatePlane(**(this->normalP), **(this->sizeP), - **(this->segmentsP), **(this->uvTileP), **(this->materialP), - **(this->castShadowsP), this->GetVisualNode()); +//////////////////////////////////////////////////////////////////////////////// +// Create the plane +void PlaneGeom::CreatePlane() +{ + double altitude = 0; + this->meshName = OgreCreator::CreatePlane(**(this->normalP), + **(this->sizeP), **(this->segmentsP), **(this->uvTileP), + **(this->materialP), **(this->castShadowsP), this->GetVisualNode(), + this->meshName); + this->SetGeom(dCreatePlane(this->spaceId, this->normalP->GetValue().x, this->normalP->GetValue().y, this->normalP->GetValue().z, altitude),false); @@ -106,6 +125,61 @@ } ////////////////////////////////////////////////////////////////////////////// +/// Set the normal +void PlaneGeom::SetNormal( const Vector3 &norm ) +{ + OgreCreator::RemoveMesh(this->meshName); + this->normalP->SetValue( norm ); + this->CreatePlane(); +} + +////////////////////////////////////////////////////////////////////////////// +// Set the size +void PlaneGeom::SetSize( const Vector2<double> &size ) +{ + OgreCreator::RemoveMesh(this->meshName); + this->sizeP->SetValue( size ); + this->CreatePlane(); +} + +////////////////////////////////////////////////////////////////////////////// +// Set the number of segments +void PlaneGeom::SetSegments(const Vector2<double> &seg) +{ + OgreCreator::RemoveMesh(this->meshName); + this->segmentsP->SetValue( seg ); + this->CreatePlane(); +} + + +////////////////////////////////////////////////////////////////////////////// +// Set the uvtile +void PlaneGeom::SetUVTile(const Vector2<double> &uv) +{ + OgreCreator::RemoveMesh(this->meshName); + this->uvTileP->SetValue( uv ); + this->CreatePlane(); +} + +////////////////////////////////////////////////////////////////////////////// +// Set the material +void PlaneGeom::SetMaterial(const std::string &mat) +{ + OgreCreator::RemoveMesh(this->meshName); + this->materialP->SetValue( mat ); + this->CreatePlane(); +} + +////////////////////////////////////////////////////////////////////////////// +/// Set cast shadows +void PlaneGeom::SetCastShadows(const bool &cast) +{ + OgreCreator::RemoveMesh(this->meshName); + this->castShadowsP->SetValue( cast ); + this->CreatePlane(); +} + +////////////////////////////////////////////////////////////////////////////// /// Save child parameters void PlaneGeom::SaveChild(std::string &prefix, std::ostream &stream) { Modified: code/gazebo/trunk/server/physics/PlaneGeom.hh =================================================================== --- code/gazebo/trunk/server/physics/PlaneGeom.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/PlaneGeom.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -96,6 +96,28 @@ /// \brief Load the plane public: virtual void LoadChild(XMLConfigNode *node); + /// \brief Create the plane + public: void CreatePlane(); + + /// \brief Set the normal + public: void SetNormal( const Vector3 &norm ); + + /// \brief Set the size + public: void SetSize( const Vector2<double> &size ); + + /// \brief Set the number of segments + public: void SetSegments(const Vector2<double> &seg); + + /// \brief Set the uvtile + public: void SetUVTile(const Vector2<double> &uv); + + /// \brief Set the material + public: void SetMaterial(const std::string &mat); + + /// \brief Set cast shadows + public: void SetCastShadows(const bool &cast); + + /// \brief Save child parameters protected: void SaveChild(std::string &prefix, std::ostream &stream); @@ -105,6 +127,8 @@ private: ParamT<Vector2<double> > *uvTileP; private: ParamT<std::string> *materialP; private: ParamT<bool> *castShadowsP; + + private: std::string meshName; }; /// \} Modified: code/gazebo/trunk/server/physics/SphereGeom.cc =================================================================== --- code/gazebo/trunk/server/physics/SphereGeom.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/SphereGeom.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -39,6 +39,7 @@ { Param::Begin(&this->parameters); this->radiusP = new ParamT<double>("size",1.0,0); + this->radiusP->Callback( &SphereGeom::SetSize, this ); Param::End(); } @@ -55,15 +56,24 @@ void SphereGeom::LoadChild(XMLConfigNode *node) { this->radiusP->Load(node); + this->SetSize( this->radiusP->GetValue() ); +} +//////////////////////////////////////////////////////////////////////////////// +// Set the size +void SphereGeom::SetSize(const double &radius) +{ + this->radiusP->SetValue( radius ); + // Initialize box mass matrix - dMassSetSphereTotal(&this->mass, this->massP->GetValue(), this->radiusP->GetValue()); + dMassSetSphereTotal(&this->mass, this->massP->GetValue(), + this->radiusP->GetValue()); // Create the sphere geometry this->SetGeom( dCreateSphere(0, this->radiusP->GetValue()), true); } -////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Save sphere parameters void SphereGeom::SaveChild(std::string &prefix, std::ostream &stream) { Modified: code/gazebo/trunk/server/physics/SphereGeom.hh =================================================================== --- code/gazebo/trunk/server/physics/SphereGeom.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/physics/SphereGeom.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -78,6 +78,9 @@ /// \brief Destructor public: virtual ~SphereGeom(); + /// \brief Set the size + public: void SetSize(const double &radius); + /// \brief Load the sphere protected: void LoadChild(XMLConfigNode *node); Modified: code/gazebo/trunk/server/rendering/CameraManager.hh =================================================================== --- code/gazebo/trunk/server/rendering/CameraManager.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/rendering/CameraManager.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -78,7 +78,6 @@ public: void DecActiveCamera(); /// \brief Connect a boost::slot the the AddCamera signal - public: template<typename T> void ConnectAddCameraSignal( T subscriber ) { Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-09-09 13:05:16 UTC (rev 7006) @@ -74,9 +74,10 @@ //////////////////////////////////////////////////////////////////////////////// // Create a plane -void OgreCreator::CreatePlane(const Vector3 &normal, const Vector2<double> &size, const Vector2<double> &segments, const Vector2<double> &uvTile, const std::string &material, bool castShadows, OgreVisual *parent) +std::string OgreCreator::CreatePlane(const Vector3 &normal, const Vector2<double> &size, const Vector2<double> &segments, const Vector2<double> &uvTile, const std::string &material, bool castShadows, OgreVisual *parent, const std::string &name) { Vector3 n = normal; + std::string resultName; n.Normalize(); Vector3 perp = n.GetPerpendicular(); @@ -85,7 +86,13 @@ //FIXME: only one plane per parent //TODO:names and parents - Ogre::MeshManager::getSingleton().createPlane(parent->GetName() + "_PLANE", + + if (name.empty()) + resultName = parent->GetName() + "_PLANE"; + else + resultName = name; + + Ogre::MeshManager::getSingleton().createPlane(resultName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, size.x, size.y, (int)segments.x, (int)segments.y, @@ -97,6 +104,8 @@ parent->SetMaterial(material); parent->SetCastShadows(castShadows); + + return resultName; } @@ -533,6 +542,14 @@ } //////////////////////////////////////////////////////////////////////////////// +/// Remove a mesh by name +void OgreCreator::RemoveMesh(const std::string &name) +{ + if (!name.empty() && Ogre::MeshManager::getSingleton().resourceExists(name)) + Ogre::MeshManager::getSingleton().remove(name); +} + +//////////////////////////////////////////////////////////////////////////////// // Create a window for Ogre Ogre::RenderWindow *OgreCreator::CreateWindow(Fl_Window *flWindow, unsigned int width, unsigned int height) { Modified: code/gazebo/trunk/server/rendering/OgreCreator.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.hh 2008-09-09 02:52:01 UTC (rev 7005) +++ code/gazebo/trunk/server/rendering/OgreCreator.hh 2008-09-09 13:05:16 UTC (rev 7006) @@ -70,10 +70,10 @@ /// It adds itself to the Visual node parent, it will those change parent /// properties if needed, to avoid this create a child visual node for the /// plane - public: static void CreatePlane(const Vector3 &normal, + public: static std::string CreatePlane(const Vector3 &normal, const Vector2<double> &size, const Vector2<double> &segments, const Vector2<double> &uvTile, const std::string &material, - bool castShadows, OgreVisual *parent); + bool castShadows, OgreVisual *parent, const std::string &name); /// \brief Create a light source /// \return The name of the light source @@ -113,6 +113,9 @@ /// \brief Draw the uniform grid pattern public: static void DrawGrid(); + /// \brief Remove a mesh by name + public: static void RemoveMesh(const std::string &name); + private: static unsigned int lightCounter; private: static unsigned int windowCounter; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-09-09 09:22:43
|
Revision: 7012 http://playerstage.svn.sourceforge.net/playerstage/?rev=7012&view=rev Author: natepak Date: 2008-09-09 16:22:53 +0000 (Tue, 09 Sep 2008) Log Message: ----------- Added Entity browser Modified Paths: -------------- code/gazebo/trunk/server/controllers/opaque/SConscript code/gazebo/trunk/server/gui/Toolbar.cc code/gazebo/trunk/server/gui/Toolbar.hh Modified: code/gazebo/trunk/server/controllers/opaque/SConscript =================================================================== --- code/gazebo/trunk/server/controllers/opaque/SConscript 2008-09-09 14:25:39 UTC (rev 7011) +++ code/gazebo/trunk/server/controllers/opaque/SConscript 2008-09-09 16:22:53 UTC (rev 7012) @@ -1,7 +1,7 @@ #Import variable Import('env sharedObjs') -dirs = Split('jointforce contact') +dirs = Split('jointforce') for subdir in dirs : SConscript('%s/SConscript' % subdir) Modified: code/gazebo/trunk/server/gui/Toolbar.cc =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-09 14:25:39 UTC (rev 7011) +++ code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-09 16:22:53 UTC (rev 7012) @@ -30,6 +30,7 @@ #include <FL/Fl_Input.H> #include <FL/Fl_Button.H> +#include "World.hh" #include "Body.hh" #include "Geom.hh" #include "Entity.hh" @@ -42,52 +43,69 @@ using namespace gazebo; +//////////////////////////////////////////////////////////////////////////////// +// Constructor Toolbar::Toolbar(int x, int y, int w, int h, const char *l) : Fl_Group(x,y,w,h,l) { this->box(FL_UP_BOX); - this->columnWidths[0] = 80; - this->columnWidths[1] = 120; - this->columnWidths[2] = 0; - - this->entityBrowser = new Fl_Hold_Browser(x+10, y+20, w-20, 25*10, "Attributes"); + this->entityBrowser = new Fl_Hold_Browser(x+10, y+20, w-20, 25*5,"Models"); this->entityBrowser->align(FL_ALIGN_TOP); - this->entityBrowser->column_char('~'); - this->entityBrowser->column_widths( columnWidths ); - this->entityBrowser->callback(&Toolbar::AttributeBrowserCB, this); + this->entityBrowser->callback( &Toolbar::EntityBrowserCB, this ); + this->paramColumnWidths[0] = 80; + this->paramColumnWidths[1] = 120; + this->paramColumnWidths[2] = 0; + y = this->entityBrowser->y() + this->entityBrowser->h() + 20; - this->attributeInput = new Fl_Input(x+10, y, w-20, 20, "Input:"); - this->attributeInput->align(FL_ALIGN_TOP); - this->attributeInput->labelsize(12); - this->attributeInput->when( FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE ); - this->attributeInput->callback(&Toolbar::AttributeInputCB, this); + this->paramBrowser = new Fl_Hold_Browser(x+10, y, w-20,25*10,"Parameters"); + this->paramBrowser->align(FL_ALIGN_TOP); + this->paramBrowser->column_char('~'); + this->paramBrowser->column_widths( this->paramColumnWidths ); + this->paramBrowser->callback(&Toolbar::ParamBrowserCB, this); + y = this->paramBrowser->y() + this->paramBrowser->h() + 20; + this->paramInput = new Fl_Input(x+10, y, w-20, 20, "Param:"); + this->paramInput->align(FL_ALIGN_TOP); + this->paramInput->labelsize(12); + this->paramInput->when( FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE ); + this->paramInput->callback(&Toolbar::ParamInputCB, this); + this->end(); this->resizable(NULL); } +//////////////////////////////////////////////////////////////////////////////// +// Destructor Toolbar::~Toolbar() { - delete this->attributeInput; + delete this->paramBrowser; + delete this->paramInput; } + + //////////////////////////////////////////////////////////////////////////////// /// Update the toolbar data void Toolbar::Update() { + if (this->entityBrowser->size() == 0) + this->UpdateEntityBrowser(); + Entity *entity = Simulator::Instance()->GetSelectedEntity(); - this->attrCount = 0; + this->paramCount = 0; + if (entity) { std::string value = "@b@B52@s@cModel "; - this->AddToBrowser(value); - this->AddEntityToAttributeBrowser(entity, ""); + this->AddToParamBrowser(value); + this->AddEntityToParamBrowser(entity, ""); - Model *model = dynamic_cast<Model *>(entity); + Model *model = dynamic_cast<Model*>(entity); + if (model) { const std::map<std::string, Body *> *bodies = model->GetBodies(); @@ -99,24 +117,24 @@ for (iter = bodies->begin(); iter != bodies->end(); iter++) { value = "@b@B52@s-Body:~@b@B52@s" + iter->second->GetName(); - this->AddToBrowser(value); - this->AddEntityToAttributeBrowser( iter->second, " " ); + this->AddToParamBrowser(value); + this->AddEntityToParamBrowser( iter->second, " " ); geoms = iter->second->GetGeoms(); for (giter = geoms->begin(); giter != geoms->end(); giter++) { value = "@b@B52@s -Geom:~@b@B52@s" + giter->second->GetName(); - this->AddToBrowser(value); - this->AddEntityToAttributeBrowser( giter->second, " " ); + this->AddToParamBrowser(value); + this->AddEntityToParamBrowser( giter->second, " " ); } } } // Clear the remaining lines - while ( this->entityBrowser->text(this->attrCount+1) != NULL ) + while ( this->paramBrowser->text(this->paramCount+1) != NULL ) { - this->AddToBrowser(""); + this->AddToParamBrowser(""); } } @@ -125,7 +143,7 @@ //////////////////////////////////////////////////////////////////////////////// // Attribute browser callback -void Toolbar::AttributeBrowserCB( Fl_Widget * w, void *data) +void Toolbar::ParamBrowserCB( Fl_Widget * w, void *data) { Fl_Hold_Browser *browser = (Fl_Hold_Browser*)(w); Toolbar *toolbar = (Toolbar*)(data); @@ -139,11 +157,11 @@ if (lineText.find("-Body") != std::string::npos || lineText.find("-Geom") != std::string::npos) { - toolbar->attributeInput->deactivate(); + toolbar->paramInput->deactivate(); return; } else - toolbar->attributeInput->activate(); + toolbar->paramInput->activate(); endLbl = lineText.find("~"); while (lineText[beginLbl] == '@') beginLbl+=2; @@ -152,22 +170,22 @@ beginValue = endLbl+1; while (lineText[beginValue] == '@') beginValue+=2; - toolbar->attributeInputLbl = lineText.substr(beginLbl, endLbl-beginLbl); + toolbar->paramInputLbl = lineText.substr(beginLbl, endLbl-beginLbl); - toolbar->attributeInput->label(toolbar->attributeInputLbl.c_str()); + toolbar->paramInput->label(toolbar->paramInputLbl.c_str()); - toolbar->attributeInput->value( lineText.substr(beginValue, lineText.size() - beginValue).c_str() ); + toolbar->paramInput->value( lineText.substr(beginValue, lineText.size() - beginValue).c_str() ); - toolbar->attributeInput->redraw(); + toolbar->paramInput->redraw(); } //////////////////////////////////////////////////////////////////////////////// // Attribute modification callback -void Toolbar::AttributeInputCB( Fl_Widget *w, void *data) +void Toolbar::ParamInputCB( Fl_Widget *w, void *data) { Fl_Input *input = (Fl_Input*)(w); Toolbar *toolbar = (Toolbar*)(data); - Fl_Hold_Browser *browser = toolbar->entityBrowser; + Fl_Hold_Browser *browser = toolbar->paramBrowser; int selected = browser->value(); Model *model = dynamic_cast<Model*>(Simulator::Instance()->GetSelectedEntity()); Body *body = NULL; @@ -222,13 +240,23 @@ { param->SetFromString( value, true ); } +} - std::cout << "Label[" << label << "] Value[" << value << "]\n"; +//////////////////////////////////////////////////////////////////////////////// +/// Callback for entity browser +void Toolbar::EntityBrowserCB( Fl_Widget *w, void *data ) +{ + Fl_Hold_Browser *browser = (Fl_Hold_Browser*)(w); + int selected = browser->value(); + std::string lineText = browser->text(selected); + + Model *model = World::Instance()->GetModelByName(lineText); + Simulator::Instance()->SetSelectedEntity(model); } //////////////////////////////////////////////////////////////////////////////// // Add entity to browser -void Toolbar::AddEntityToAttributeBrowser(Entity *entity, std::string prefix) +void Toolbar::AddEntityToParamBrowser(Entity *entity, std::string prefix) { std::vector<Param*> *parameters; std::vector<Param*>::iterator iter; @@ -248,22 +276,35 @@ value = colorStr + "@b@s" + prefix + (*iter)->GetKey() + ":~" + colorStr + "@s" + (*iter)->GetAsString(); - this->AddToBrowser( value ); + this->AddToParamBrowser( value ); } } //////////////////////////////////////////////////////////////////////////////// // Add a line to the attribute browser -void Toolbar::AddToBrowser(const std::string &line) +void Toolbar::AddToParamBrowser(const std::string &line) { - if (!this->entityBrowser->text(this->attrCount+1)) + if (!this->paramBrowser->text(this->paramCount+1)) { - this->entityBrowser->add( line.c_str() ); + this->paramBrowser->add( line.c_str() ); } - else if (strcmp(this->entityBrowser->text(this->attrCount+1), line.c_str()) != 0) + else if (strcmp(this->paramBrowser->text(this->paramCount+1), line.c_str()) != 0) { - this->entityBrowser->text( this->attrCount+1, line.c_str() ); + this->paramBrowser->text( this->paramCount+1, line.c_str() ); } - this->attrCount++; + this->paramCount++; } + +//////////////////////////////////////////////////////////////////////////////// +/// Update entity browser +void Toolbar::UpdateEntityBrowser() +{ + std::vector<Model*>::iterator iter; + std::vector<Model*> models = World::Instance()->GetModels(); + + for (iter = models.begin(); iter != models.end(); iter++) + { + this->entityBrowser->add( (*iter)->GetName().c_str() ); + } +} Modified: code/gazebo/trunk/server/gui/Toolbar.hh =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-09 14:25:39 UTC (rev 7011) +++ code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-09 16:22:53 UTC (rev 7012) @@ -51,19 +51,33 @@ /// \brief Update the toolbar data public: void Update(); - public: static void AttributeBrowserCB( Fl_Widget * w, void *data); - public: static void AttributeInputCB( Fl_Widget * w, void *data); + /// \brief Callback for the parameter browser + public: static void ParamBrowserCB( Fl_Widget * w, void *data); - private: void AddEntityToAttributeBrowser(Entity *ent, std::string prefix); - private: void AddToBrowser(const std::string &line); + /// \brief Callback for parameter modification + public: static void ParamInputCB( Fl_Widget * w, void *data); + /// \brief Callback for entity browser + public: static void EntityBrowserCB( Fl_Widget *w, void *data ); + + /// \brief Add an entity ot the param browser + private: void AddEntityToParamBrowser(Entity *ent, std::string prefix); + + /// \brief Add a line to the param browser + private: void AddToParamBrowser(const std::string &line); + + + /// \brief Update entity browser + private: void UpdateEntityBrowser(); + private: Fl_Hold_Browser *entityBrowser; - private: int columnWidths[3]; - private: int attrCount; + private: Fl_Hold_Browser *paramBrowser; + private: Fl_Input *paramInput; + private: std::string paramInputLbl; - private: Fl_Input *attributeInput; - private: std::string attributeInputLbl; + private: int paramColumnWidths[3]; + private: int paramCount; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-09-09 20:51:03
|
Revision: 7018 http://playerstage.svn.sourceforge.net/playerstage/?rev=7018&view=rev Author: natepak Date: 2008-09-10 03:51:13 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Added a Common class for ease of processing parameters Modified Paths: -------------- code/gazebo/trunk/server/Entity.cc code/gazebo/trunk/server/Entity.hh code/gazebo/trunk/server/Param.cc code/gazebo/trunk/server/SConscript code/gazebo/trunk/server/gui/GLWindow.cc code/gazebo/trunk/server/gui/Toolbar.cc code/gazebo/trunk/server/gui/Toolbar.hh code/gazebo/trunk/server/physics/Geom.cc code/gazebo/trunk/server/physics/Geom.hh code/gazebo/trunk/server/physics/Joint.cc code/gazebo/trunk/server/physics/Joint.hh code/gazebo/trunk/server/rendering/OgreVisual.cc code/gazebo/trunk/server/rendering/OgreVisual.hh Added Paths: ----------- code/gazebo/trunk/server/Common.cc code/gazebo/trunk/server/Common.hh Added: code/gazebo/trunk/server/Common.cc =================================================================== --- code/gazebo/trunk/server/Common.cc (rev 0) +++ code/gazebo/trunk/server/Common.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -0,0 +1,101 @@ +/* + * 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: Base class shared by all classes in Gazebo. + * Author: Nate Koenig + * Date: 09 Sept. 2008 + * SVN: $Id:$ + */ + +#include "Common.hh" +#include "GazeboMessage.hh" + +using namespace gazebo; + +unsigned int Common::idCounter = 0; + +//////////////////////////////////////////////////////////////////////////////// +/// Constructor +Common::Common() +{ + this->id = ++idCounter; + + Param::Begin(&this->parameters); + this->nameP = new ParamT<std::string>("name","noname",1); + Param::End(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Destructor +Common::~Common() +{ + delete this->nameP; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the name of the entity +void Common::SetName(const std::string &name) +{ + this->nameP->SetValue( name ); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Return the name of the entity +std::string Common::GetName() const +{ + return this->nameP->GetValue(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Get the parameters +std::vector<Param*> *Common::GetParams() +{ + return &this->parameters; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Get a parameter by name +Param *Common::GetParam(const std::string &key) const +{ + std::vector<Param*>::const_iterator iter; + Param *result = NULL; + + for (iter = this->parameters.begin(); iter != this->parameters.end(); iter++) + { + if ((*iter)->GetKey() == key) + { + result = *iter; + break; + } + } + + if (result == NULL) + gzerr(0) << "Unable to find Param using key[" << key << "]\n"; + + return result; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Return the ID of this entity. This id is unique +int Common::GetId() const +{ + return this->id; +} Added: code/gazebo/trunk/server/Common.hh =================================================================== --- code/gazebo/trunk/server/Common.hh (rev 0) +++ code/gazebo/trunk/server/Common.hh 2008-09-10 03:51:13 UTC (rev 7018) @@ -0,0 +1,80 @@ +/* + * 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: Base class shared by all classes in Gazebo. + * Author: Nate Koenig + * Date: 09 Sept. 2008 + * SVN: $Id:$ + */ + +#ifndef COMMON_HH +#define COMMON_HH + +#include <vector> +#include <string> + +#include "Param.hh" + +namespace gazebo +{ + + class Common + { + /// \brief Constructor + public: Common(); + + /// \brief Destructor + public: virtual ~Common(); + + /// \brief Set the name of the entity + /// \param name Body name + public: void SetName(const std::string &name); + + /// \brief Return the name of the entity + /// \return Name of the entity + public: std::string GetName() const; + + /// \brief Get the parameters + public: std::vector<Param*> *GetParams(); + + /// \brief Get a parameter by name + public: Param *GetParam(const std::string &key) const; + + /// \brief Return the ID of this entity. This id is unique + /// \return Integer ID + public: int GetId() const; + + /// \brief This entities ID + private: unsigned int id; + + /// \brief Used to automaticaly chose a unique ID on creation + private: static unsigned int idCounter; + + /// Name of the entity + protected: ParamT<std::string> *nameP; + + /// List of all the parameters + protected: std::vector<Param*> parameters; + }; +} + +#endif + Modified: code/gazebo/trunk/server/Entity.cc =================================================================== --- code/gazebo/trunk/server/Entity.cc 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/Entity.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -34,16 +34,14 @@ #include "Entity.hh" using namespace gazebo; -unsigned int Entity::idCounter = 0; +//////////////////////////////////////////////////////////////////////////////// +// Constructor Entity::Entity(Entity *parent) -: parent(parent), - id(++idCounter), - visualNode(0) +: Common(), parent(parent), visualNode(0) { Param::Begin(&this->parameters); - this->nameP = new ParamT<std::string>("name","",1); this->staticP = new ParamT<bool>("static",false,0); //this->staticP->Callback( &Entity::SetStatic, this); Param::End(); @@ -65,39 +63,38 @@ World::Instance()->GetPhysicsEngine()->AddEntity(this); } +//////////////////////////////////////////////////////////////////////////////// +// Destructor Entity::~Entity() { - delete this->nameP; delete this->staticP; GZ_DELETE(this->visualNode); World::Instance()->GetPhysicsEngine()->RemoveEntity(this); } -int Entity::GetId() const -{ - return this->id; -} - +//////////////////////////////////////////////////////////////////////////////// // Return the ID of the parent int Entity::GetParentId() const { return this->parent == NULL ? 0 : this->parent->GetId(); } - +//////////////////////////////////////////////////////////////////////////////// // Set the parent void Entity::SetParent(Entity *parent) { this->parent = parent; } +//////////////////////////////////////////////////////////////////////////////// // Get the parent Entity *Entity::GetParent() const { return this->parent; } +//////////////////////////////////////////////////////////////////////////////// // Add a child to this entity void Entity::AddChild(Entity *child) { @@ -108,18 +105,21 @@ this->children.push_back(child); } +//////////////////////////////////////////////////////////////////////////////// // Get all children std::vector< Entity* > &Entity::GetChildren() { return this->children; } +//////////////////////////////////////////////////////////////////////////////// // Return this entitie's sceneNode OgreVisual *Entity::GetVisualNode() const { return this->visualNode; } +//////////////////////////////////////////////////////////////////////////////// // Set the scene node void Entity::SetVisualNode(OgreVisual *visualNode) { @@ -127,21 +127,6 @@ } //////////////////////////////////////////////////////////////////////////////// -// Set the name of the body -void Entity::SetName(const std::string &name) -{ - this->nameP->SetValue( name ); -} - -//////////////////////////////////////////////////////////////////////////////// -// Return the name of the body -std::string Entity::GetName() const -{ - return this->nameP->GetValue(); -} - - -//////////////////////////////////////////////////////////////////////////////// // Set whether this entity is static: immovable void Entity::SetStatic(const bool &s) { @@ -198,32 +183,3 @@ { return ent.GetName() == this->GetName(); } - -//////////////////////////////////////////////////////////////////////////////// -/// Get the parameters -std::vector<Param*> *Entity::GetParams() -{ - return &this->parameters; -} - -//////////////////////////////////////////////////////////////////////////////// -/// Get a parameter by name -Param *Entity::GetParam(const std::string &key) const -{ - std::vector<Param*>::const_iterator iter; - Param *result = NULL; - - for (iter = this->parameters.begin(); iter != this->parameters.end(); iter++) - { - if ((*iter)->GetKey() == key) - { - result = *iter; - break; - } - } - - if (result == NULL) - gzerr(0) << "Unable to find Param using key[" << key << "]\n"; - - return result; -} Modified: code/gazebo/trunk/server/Entity.hh =================================================================== --- code/gazebo/trunk/server/Entity.hh 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/Entity.hh 2008-09-10 03:51:13 UTC (rev 7018) @@ -18,8 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - -/* Desc: External interfaces for Gazebo +/* Desc: Base class for all physical entities * Author: Nate Koenig * Date: 03 Apr 2007 * SVN: $Id$ @@ -32,6 +31,7 @@ #include <string> #include <ode/ode.h> +#include "Common.hh" #include "Param.hh" namespace gazebo @@ -46,7 +46,7 @@ /* * Facilitates meshing of physics engine with rendering engine */ - class Entity + class Entity : public Common { /// \brief Constructor /// \param parent Parent of the entity. @@ -54,11 +54,7 @@ /// \brief Destructor public: virtual ~Entity(); - - /// \brief Return the ID of this entity. This id is unique - /// \return Integer ID - public: int GetId() const; - + /// \brief Return the ID of the parent /// \return Integer ID public: int GetParentId() const; @@ -86,15 +82,7 @@ /// \brief Set the scene node /// \param sceneNode Ogre scene node public: void SetVisualNode(OgreVisual *visualNode); - - /// \brief Set the name of the entity - /// \param name Body name - public: void SetName(const std::string &name); - - /// \brief Return the name of the entity - /// \return Name of the entity - public: std::string GetName() const; - + /// \brief Set whether this entity is static: immovable /// \param s Bool, true = static public: void SetStatic(const bool &s); @@ -113,24 +101,12 @@ /// \brief Returns true if the entities are the same. Checks only the name public: bool operator==(const Entity &ent) const; - /// \brief Get the parameters - public: std::vector<Param*> *GetParams(); - - /// \brief Get a parameter by name - public: Param *GetParam(const std::string &key) const; - /// \brief Parent of this entity protected: Entity *parent; /// \brief Children of this entity protected: std::vector< Entity* > children; - /// \brief This entities ID - private: unsigned int id; - - /// \brief Used to automaticaly chose a unique ID on creation - private: static unsigned int idCounter; - // is this an static entity protected: ParamT<bool> *staticP; @@ -140,14 +116,7 @@ /// \brief ODE Stuff (should be go somewhere else) public: dSpaceID spaceId; - /// \brief Name of the entity - protected: ParamT<std::string> *nameP; - - /// List of all the parameters - protected: std::vector<Param*> parameters; - private: bool selected; - }; /// \} Modified: code/gazebo/trunk/server/Param.cc =================================================================== --- code/gazebo/trunk/server/Param.cc 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/Param.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -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: Parameter class + * Author: Nate Koenig + * Date: 14 Aug 2008 + * SVN: $Id:$ + */ + #include "GazeboError.hh" #include "Param.hh" Modified: code/gazebo/trunk/server/SConscript =================================================================== --- code/gazebo/trunk/server/SConscript 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/SConscript 2008-09-10 03:51:13 UTC (rev 7018) @@ -7,6 +7,7 @@ SConscript('%s/SConscript' % subdir) sources = ['main.cc', + 'Common.cc', 'Vector3.cc', 'Vector4.cc', 'Quatern.cc', Modified: code/gazebo/trunk/server/gui/GLWindow.cc =================================================================== --- code/gazebo/trunk/server/gui/GLWindow.cc 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/gui/GLWindow.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -351,8 +351,6 @@ { this->keys[keyNum] = 0; - Simulator* sim = Simulator::Instance(); - // Handle all toggle keys switch (keyNum) { Modified: code/gazebo/trunk/server/gui/Toolbar.cc =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -30,13 +30,17 @@ #include <FL/Fl_Input.H> #include <FL/Fl_Button.H> +#include <boost/lexical_cast.hpp> + #include "World.hh" #include "Body.hh" #include "Geom.hh" #include "Entity.hh" +#include "Common.hh" #include "Model.hh" #include "Simulator.hh" #include "CameraManager.hh" +#include "OgreVisual.hh" #include "OgreCamera.hh" #include "Toolbar.hh" #include "Global.hh" @@ -127,6 +131,16 @@ value = "@b@B52@s -Geom:~@b@B52@s" + giter->second->GetName(); this->AddToParamBrowser(value); this->AddEntityToParamBrowser( giter->second, " " ); + + for (unsigned int i=0; i < giter->second->GetVisualCount(); i++) + { + OgreVisual *vis = giter->second->GetVisual(i); + std::ostringstream stream; + stream << vis->GetId(); + value = "@b@B52@s -Visual:~@b@B52@s" + stream.str(); + this->AddToParamBrowser(value); + this->AddEntityToParamBrowser( vis, " " ); + } } } } @@ -190,8 +204,10 @@ Model *model = dynamic_cast<Model*>(Simulator::Instance()->GetSelectedEntity()); Body *body = NULL; Geom *geom = NULL; - std::string geomName, bodyName, value, label; + OgreVisual *vis = NULL; + std::string geomName, bodyName, visNum, value, label; + // Make sure we have a valid model if (!model) { @@ -215,6 +231,8 @@ geomName = lineText.substr( lastAmp, lineText.size()-lastAmp ); else if (lineText.find("-Body:") != std::string::npos && bodyName.empty()) bodyName = lineText.substr( lastAmp, lineText.size()-lastAmp ); + else if (lineText.find("-Visual:") != std::string::npos && visNum.empty()) + visNum = lineText.substr( lastAmp, lineText.size()-lastAmp ); selected--; } @@ -227,9 +245,14 @@ if (!geomName.empty() && body) geom = body->GetGeom(geomName); + if (!visNum.empty() && geom) + vis = geom->GetVisualById(boost::lexical_cast<int>(visNum)); + // Get the parameter Param *param = NULL; - if (geom) + if (vis) + param = vis->GetParam(label); + else if (geom) param = geom->GetParam(label); else if (body) param = body->GetParam(label); @@ -256,7 +279,7 @@ //////////////////////////////////////////////////////////////////////////////// // Add entity to browser -void Toolbar::AddEntityToParamBrowser(Entity *entity, std::string prefix) +void Toolbar::AddEntityToParamBrowser(Common *entity, std::string prefix) { std::vector<Param*> *parameters; std::vector<Param*>::iterator iter; Modified: code/gazebo/trunk/server/gui/Toolbar.hh =================================================================== --- code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-10 03:51:13 UTC (rev 7018) @@ -37,7 +37,7 @@ namespace gazebo { - class Entity; + class Common; /// \brief Toolbar class Toolbar : public Fl_Group @@ -61,7 +61,7 @@ public: static void EntityBrowserCB( Fl_Widget *w, void *data ); /// \brief Add an entity ot the param browser - private: void AddEntityToParamBrowser(Entity *ent, std::string prefix); + private: void AddEntityToParamBrowser(Common *ent, std::string prefix); /// \brief Add a line to the param browser private: void AddToParamBrowser(const std::string &line); Modified: code/gazebo/trunk/server/physics/Geom.cc =================================================================== --- code/gazebo/trunk/server/physics/Geom.cc 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/physics/Geom.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -517,3 +517,32 @@ this->body->UpdateCoM(); } +//////////////////////////////////////////////////////////////////////////////// +/// Get the number of visuals +unsigned int Geom::GetVisualCount() const +{ + return this->visuals.size(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Get a visual +OgreVisual *Geom::GetVisual(unsigned int index) const +{ + if (index < this->visuals.size()) + return this->visuals[index]; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Get a visual +OgreVisual *Geom::GetVisualById(int id) const +{ + std::vector<OgreVisual*>::const_iterator iter; + + for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++) + { + if ( (*iter)->GetId() == id) + return *iter; + } + + return NULL; +} Modified: code/gazebo/trunk/server/physics/Geom.hh =================================================================== --- code/gazebo/trunk/server/physics/Geom.hh 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/physics/Geom.hh 2008-09-10 03:51:13 UTC (rev 7018) @@ -143,6 +143,15 @@ /// \brief Set the mass public: void SetMass(const double &mass); + /// \brief Get the number of visuals + public: unsigned int GetVisualCount() const; + + /// \brief Get a visual + public: OgreVisual *GetVisual(unsigned int index) const; + + /// \brief Get a visual by id + public: OgreVisual *GetVisualById( int id ) const; + /// Contact parameters public: ContactParams *contact; Modified: code/gazebo/trunk/server/physics/Joint.cc =================================================================== --- code/gazebo/trunk/server/physics/Joint.cc 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/physics/Joint.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -36,12 +36,12 @@ ////////////////////////////////////////////////////////////////////////////// // Constructor Joint::Joint() + : Common() { this->visual = NULL; this->model = NULL; Param::Begin(&this->parameters); - this->nameP = new ParamT<std::string>("name","",1); this->erpP = new ParamT<double>("erp",0.4,0); this->cfmP = new ParamT<double>("cfm",10e-3,0); this->suspensionCfmP = new ParamT<double>("suspensionCfm",0.0,0); @@ -59,7 +59,6 @@ Joint::~Joint() { dJointDestroy( this->jointId ); - delete this->nameP; delete this->erpP; delete this->cfmP; delete this->suspensionCfmP; Modified: code/gazebo/trunk/server/physics/Joint.hh =================================================================== --- code/gazebo/trunk/server/physics/Joint.hh 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/physics/Joint.hh 2008-09-10 03:51:13 UTC (rev 7018) @@ -29,6 +29,7 @@ #include <ode/ode.h> +#include "Common.hh" #include "Param.hh" #include "Vector3.hh" @@ -45,7 +46,7 @@ class OgreVisual; /// \brief Base class for all joints - class Joint + class Joint : public Common { /// \brief Type of joint public: enum Type {SLIDER, HINGE, HINGE2, BALL, UNIVERSAL}; @@ -153,7 +154,6 @@ private: Body *body2; /// Name of this joint - private: ParamT<std::string> *nameP; private: ParamT<double> *erpP; private: ParamT<double> *cfmP; private: ParamT<double> *suspensionCfmP; @@ -166,8 +166,6 @@ /// Feedback data for this joint private: dJointFeedback *feedback; - protected: std::vector<Param*> parameters; - private: OgreVisual *visual; private: Model *model; Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-09-10 03:51:13 UTC (rev 7018) @@ -39,6 +39,7 @@ //////////////////////////////////////////////////////////////////////////////// // Constructor OgreVisual::OgreVisual(OgreVisual *node, Entity *owner) + : Common() { std::ostringstream stream; @@ -60,10 +61,19 @@ Param::Begin(&this->parameters); this->xyzP = new ParamT<Vector3>("xyz", Vector3(0,0,0), 0); + this->xyzP->Callback( &OgreVisual::SetPosition, this ); + this->rpyP = new ParamT<Quatern>("rpy", Quatern(1,0,0,0), 0); + this->rpyP->Callback( &OgreVisual::SetRotation, this ); + this->meshNameP = new ParamT<std::string>("mesh","",1); + this->materialNameP = new ParamT<std::string>("material",std::string(),0); + this->materialNameP->Callback( &OgreVisual::SetMaterial, this ); + this->castShadowsP = new ParamT<bool>("castShadows",true,0); + this->castShadowsP->Callback( &OgreVisual::SetCastShadows, this ); + this->scaleP = new ParamT<Vector3>("scale", Vector3(1,1,1), 0); this->sizeP = new ParamT<Vector3>("size", Vector3(1,1,1), 0); Param::End(); @@ -277,7 +287,10 @@ // Clone the material. This will allow us to change the look of each geom // individually. - this->myMaterial = this->origMaterial->clone(myMaterialName); + if (Ogre::MaterialManager::getSingleton().resourceExists(myMaterialName)) + this->myMaterial = (Ogre::MaterialPtr)(Ogre::MaterialManager::getSingleton().getByName(myMaterialName)); + else + this->myMaterial = this->origMaterial->clone(myMaterialName); Ogre::Material::TechniqueIterator techniqueIt = this->myMaterial->getTechniqueIterator (); @@ -421,7 +434,7 @@ //////////////////////////////////////////////////////////////////////////////// /// Set whether the visual should cast shadows -void OgreVisual::SetCastShadows(bool shadows) +void OgreVisual::SetCastShadows(const bool &shadows) { for (int i=0; i < this->sceneNode->numAttachedObjects(); i++) { @@ -566,5 +579,3 @@ if (node) node->showBoundingBox(value); } - - Modified: code/gazebo/trunk/server/rendering/OgreVisual.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-09-09 23:48:33 UTC (rev 7017) +++ code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-09-10 03:51:13 UTC (rev 7018) @@ -33,6 +33,7 @@ #include "Pose3d.hh" #include "Quatern.hh" #include "Vector3.hh" +#include "Common.hh" #include "Param.hh" namespace gazebo @@ -42,7 +43,7 @@ class Entity; /// \brief Ogre Visual Object - class OgreVisual : public Ogre::UserDefinedObject + class OgreVisual : public Common, public Ogre::UserDefinedObject { /// \brief Constructor public: OgreVisual (OgreVisual *node, Entity *owner = NULL); @@ -82,7 +83,7 @@ public: void SetHighlight( bool highlight); /// \brief Set whether the visual should cast shadows - public: void SetCastShadows(bool shadows); + public: void SetCastShadows(const bool &shadows); /// \brief Set whether the visual is visible /// \param visible set this node visible @@ -123,7 +124,6 @@ // user selection public: void ShowSelectionBox( bool value ); - private: Ogre::MaterialPtr origMaterial; private: Ogre::MaterialPtr myMaterial; private: Ogre::SceneBlendType sceneBlendType; @@ -147,7 +147,6 @@ private: ParamT<bool> *castShadowsP; private: ParamT<Vector3> *sizeP; private: ParamT<Vector3> *scaleP; - private: std::vector<Param*> parameters; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-09-24 16:27:54
|
Revision: 7036 http://playerstage.svn.sourceforge.net/playerstage/?rev=7036&view=rev Author: natepak Date: 2008-09-24 16:27:10 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Fixed loading of heightmaps, and errors in mapgeom Modified Paths: -------------- code/gazebo/trunk/server/physics/MapGeom.cc code/gazebo/trunk/server/physics/MapGeom.hh code/gazebo/trunk/server/rendering/OgreAdaptor.cc Modified: code/gazebo/trunk/server/physics/MapGeom.cc =================================================================== --- code/gazebo/trunk/server/physics/MapGeom.cc 2008-09-23 10:25:38 UTC (rev 7035) +++ code/gazebo/trunk/server/physics/MapGeom.cc 2008-09-24 16:27:10 UTC (rev 7036) @@ -42,6 +42,8 @@ using namespace gazebo; +unsigned int MapGeom::geomCounter = 0; + ////////////////////////////////////////////////////////////////////////////// // Constructor MapGeom::MapGeom(Body *body) @@ -57,6 +59,7 @@ this->materialP = new ParamT<std::string>("material", "", 0); this->granularityP = new ParamT<int>("granularity", 5, 0); Param::End(); + } @@ -152,7 +155,10 @@ float ySize = (node->height) * this->scaleP->GetValue(); float zSize = this->wallHeightP->GetValue(); - stream << "<geom:box name='map_geom'>"; + char geomName[256]; + sprintf(geomName,"map_geom_%d",geomCounter++); + + stream << "<geom:box name='" << geomName << "'>"; stream << " <mass>0.0</mass>"; stream << " <xyz>" << x << " " << y << " " << z << "</xyz>"; stream << " <rpy>0 0 0</rpy>"; Modified: code/gazebo/trunk/server/physics/MapGeom.hh =================================================================== --- code/gazebo/trunk/server/physics/MapGeom.hh 2008-09-23 10:25:38 UTC (rev 7035) +++ code/gazebo/trunk/server/physics/MapGeom.hh 2008-09-24 16:27:10 UTC (rev 7036) @@ -146,6 +146,7 @@ private: QuadNode *root; private: bool merged; + private: static unsigned int geomCounter; }; @@ -186,6 +187,7 @@ public: bool leaf; public: bool valid; + }; /// \} Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2008-09-23 10:25:38 UTC (rev 7035) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2008-09-24 16:27:10 UTC (rev 7036) @@ -205,8 +205,8 @@ 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_CLOSE); + //this->sceneMgr = this->root->createSceneManager(Ogre::ST_EXTERIOR_FAR); } Param::Begin(&this->parameters); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-09-24 18:10:00
|
Revision: 7042 http://playerstage.svn.sourceforge.net/playerstage/?rev=7042&view=rev Author: natepak Date: 2008-09-24 18:09:46 +0000 (Wed, 24 Sep 2008) Log Message: ----------- add svn properties Modified Paths: -------------- code/gazebo/trunk/server/Angle.cc code/gazebo/trunk/server/Angle.hh code/gazebo/trunk/server/Common.cc code/gazebo/trunk/server/Common.hh code/gazebo/trunk/server/GazeboConfig.cc code/gazebo/trunk/server/GazeboConfig.hh code/gazebo/trunk/server/Param.cc code/gazebo/trunk/server/Param.hh code/gazebo/trunk/server/Vector4.cc code/gazebo/trunk/server/Vector4.hh Property Changed: ---------------- code/gazebo/trunk/server/ code/gazebo/trunk/server/Angle.cc code/gazebo/trunk/server/Angle.hh code/gazebo/trunk/server/Common.cc code/gazebo/trunk/server/Common.hh code/gazebo/trunk/server/Entity.cc code/gazebo/trunk/server/Entity.hh code/gazebo/trunk/server/GazeboConfig.cc code/gazebo/trunk/server/GazeboConfig.hh code/gazebo/trunk/server/GazeboError.cc code/gazebo/trunk/server/GazeboError.hh code/gazebo/trunk/server/GazeboMessage.cc code/gazebo/trunk/server/GazeboMessage.hh code/gazebo/trunk/server/Global.hh code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/Model.hh code/gazebo/trunk/server/Param.cc code/gazebo/trunk/server/Param.hh code/gazebo/trunk/server/Pose3d.cc code/gazebo/trunk/server/Pose3d.hh code/gazebo/trunk/server/Quatern.cc code/gazebo/trunk/server/Quatern.hh code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/Simulator.hh code/gazebo/trunk/server/SingletonT.hh code/gazebo/trunk/server/StaticPluginRegister.hh code/gazebo/trunk/server/Time.cc code/gazebo/trunk/server/Time.hh code/gazebo/trunk/server/Vector2.cc code/gazebo/trunk/server/Vector2.hh code/gazebo/trunk/server/Vector3.cc code/gazebo/trunk/server/Vector3.hh code/gazebo/trunk/server/Vector4.cc code/gazebo/trunk/server/Vector4.hh code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/World.hh code/gazebo/trunk/server/XMLConfig.cc code/gazebo/trunk/server/XMLConfig.hh code/gazebo/trunk/server/bindings/ code/gazebo/trunk/server/bindings/python/ code/gazebo/trunk/server/bindings/python/mygazebo.cc code/gazebo/trunk/server/main.cc Property changes on: code/gazebo/trunk/server ___________________________________________________________________ Modified: svn:ignore - *.os + .player *.os *.so *.o *.a config.log .scon* Ogre.log gazebo Doxyfile gazeborc *.pc .settings .cproject .project bandit Modified: code/gazebo/trunk/server/Angle.cc =================================================================== --- code/gazebo/trunk/server/Angle.cc 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Angle.cc 2008-09-24 18:09:46 UTC (rev 7042) @@ -21,7 +21,7 @@ /* Desc: Angle class * Author: Nate Koenig * Date: 18 Aug 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #include <math.h> Property changes on: code/gazebo/trunk/server/Angle.cc ___________________________________________________________________ Added: svn:keywords + Id Revision Modified: code/gazebo/trunk/server/Angle.hh =================================================================== --- code/gazebo/trunk/server/Angle.hh 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Angle.hh 2008-09-24 18:09:46 UTC (rev 7042) @@ -21,7 +21,7 @@ /* Desc: Angle class * Author: Nate Koenig * Date: 18 Aug 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #ifndef ANGLE_HH Property changes on: code/gazebo/trunk/server/Angle.hh ___________________________________________________________________ Added: svn:keywords + Id Revision Modified: code/gazebo/trunk/server/Common.cc =================================================================== --- code/gazebo/trunk/server/Common.cc 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Common.cc 2008-09-24 18:09:46 UTC (rev 7042) @@ -22,7 +22,7 @@ /* Desc: Base class shared by all classes in Gazebo. * Author: Nate Koenig * Date: 09 Sept. 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #include "Common.hh" Property changes on: code/gazebo/trunk/server/Common.cc ___________________________________________________________________ Added: svn:keywords + Id Revision Modified: code/gazebo/trunk/server/Common.hh =================================================================== --- code/gazebo/trunk/server/Common.hh 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Common.hh 2008-09-24 18:09:46 UTC (rev 7042) @@ -22,7 +22,7 @@ /* Desc: Base class shared by all classes in Gazebo. * Author: Nate Koenig * Date: 09 Sept. 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #ifndef COMMON_HH Property changes on: code/gazebo/trunk/server/Common.hh ___________________________________________________________________ Added: svn:keywords + Id Revision Property changes on: code/gazebo/trunk/server/Entity.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Entity.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Modified: code/gazebo/trunk/server/GazeboConfig.cc =================================================================== --- code/gazebo/trunk/server/GazeboConfig.cc 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/GazeboConfig.cc 2008-09-24 18:09:46 UTC (rev 7042) @@ -20,7 +20,7 @@ /* Desc: Local Gazebo configuration * Author: Jordi Polo * Date: 3 May 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #include <assert.h> #include <iostream> Property changes on: code/gazebo/trunk/server/GazeboConfig.cc ___________________________________________________________________ Added: svn:keywords + Id Revision Modified: code/gazebo/trunk/server/GazeboConfig.hh =================================================================== --- code/gazebo/trunk/server/GazeboConfig.hh 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/GazeboConfig.hh 2008-09-24 18:09:46 UTC (rev 7042) @@ -20,7 +20,7 @@ /* Desc: Gazebo configuration on this computer * Author: Jordi Polo * Date: 3 May 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #ifndef GAZEBOCONFIG_HH Property changes on: code/gazebo/trunk/server/GazeboConfig.hh ___________________________________________________________________ Added: svn:keywords + Id Revision Property changes on: code/gazebo/trunk/server/GazeboError.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/GazeboError.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/GazeboMessage.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/GazeboMessage.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Global.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Model.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Model.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Modified: code/gazebo/trunk/server/Param.cc =================================================================== --- code/gazebo/trunk/server/Param.cc 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Param.cc 2008-09-24 18:09:46 UTC (rev 7042) @@ -21,7 +21,7 @@ /* Desc: Parameter class * Author: Nate Koenig * Date: 14 Aug 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #include "GazeboError.hh" Property changes on: code/gazebo/trunk/server/Param.cc ___________________________________________________________________ Added: svn:keywords + Id Revision Modified: code/gazebo/trunk/server/Param.hh =================================================================== --- code/gazebo/trunk/server/Param.hh 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Param.hh 2008-09-24 18:09:46 UTC (rev 7042) @@ -21,7 +21,7 @@ /* Desc: A parameter * Author: Nate Koenig * Date: 14 Aug 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #ifndef PARAM_HH Property changes on: code/gazebo/trunk/server/Param.hh ___________________________________________________________________ Added: svn:keywords + Id Revision Property changes on: code/gazebo/trunk/server/Pose3d.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Pose3d.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Quatern.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Quatern.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Simulator.cc ___________________________________________________________________ Added: svn:keywords + Id Revision Property changes on: code/gazebo/trunk/server/Simulator.hh ___________________________________________________________________ Added: svn:keywords + Id Revision Property changes on: code/gazebo/trunk/server/SingletonT.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/StaticPluginRegister.hh ___________________________________________________________________ Added: svn:keywords + Id Revision Property changes on: code/gazebo/trunk/server/Time.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Time.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Vector2.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Vector2.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Vector3.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/Vector3.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Modified: code/gazebo/trunk/server/Vector4.cc =================================================================== --- code/gazebo/trunk/server/Vector4.cc 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Vector4.cc 2008-09-24 18:09:46 UTC (rev 7042) @@ -21,7 +21,7 @@ /* Desc: Vector 4 * Author: Andrew Howard and Nate Koenig * Date: 4 Apr 2007 - * SVN: $Id:$ + * SVN: $Id$ */ #include <math.h> Property changes on: code/gazebo/trunk/server/Vector4.cc ___________________________________________________________________ Added: svn:keywords + Id Revision Modified: code/gazebo/trunk/server/Vector4.hh =================================================================== --- code/gazebo/trunk/server/Vector4.hh 2008-09-24 18:08:09 UTC (rev 7041) +++ code/gazebo/trunk/server/Vector4.hh 2008-09-24 18:09:46 UTC (rev 7042) @@ -21,7 +21,7 @@ /* Desc: 4 tuple * Author: Nate Koenig * Date: 19 Aug 2008 - * SVN: $Id:$ + * SVN: $Id$ */ #ifndef VECTOR4_HH Property changes on: code/gazebo/trunk/server/Vector4.hh ___________________________________________________________________ Added: svn:keywords + Id Revision Property changes on: code/gazebo/trunk/server/World.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/World.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/XMLConfig.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/XMLConfig.hh ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/bindings ___________________________________________________________________ Added: svn:ignore + .player *.os *.so *.o *.a config.log .scon* Ogre.log gazebo Doxyfile gazeborc *.pc .settings .cproject .project bandit Property changes on: code/gazebo/trunk/server/bindings/python ___________________________________________________________________ Added: svn:ignore + .player *.os *.so *.o *.a config.log .scon* Ogre.log gazebo Doxyfile gazeborc *.pc .settings .cproject .project bandit Property changes on: code/gazebo/trunk/server/bindings/python/mygazebo.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision Property changes on: code/gazebo/trunk/server/main.cc ___________________________________________________________________ Modified: svn:keywords - Id + Id Revision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-09-29 18:43:34
|
Revision: 7052 http://playerstage.svn.sourceforge.net/playerstage/?rev=7052&view=rev Author: natepak Date: 2008-09-29 18:43:10 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Updated to work with ogre 1.6 Modified Paths: -------------- code/gazebo/trunk/server/rendering/MovableText.cc code/gazebo/trunk/server/rendering/MovableText.hh code/gazebo/trunk/server/rendering/OgreCamera.cc code/gazebo/trunk/server/rendering/SConscript code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc Modified: code/gazebo/trunk/server/rendering/MovableText.cc =================================================================== --- code/gazebo/trunk/server/rendering/MovableText.cc 2008-09-29 03:01:33 UTC (rev 7051) +++ code/gazebo/trunk/server/rendering/MovableText.cc 2008-09-29 18:43:10 UTC (rev 7052) @@ -8,7 +8,6 @@ * @update 2007 by independentCreations see ind...@gm... */ - #include "MovableText.hh" #include <OgreFontManager.h> @@ -17,6 +16,8 @@ #define POS_TEX_BINDING 0 #define COLOUR_BINDING 1 +using namespace gazebo; + //////////////////////////////////////////////////////////////////////////////// // Constructor MovableText::MovableText() @@ -685,3 +686,13 @@ queue->addRenderable(this, mRenderQueueID, OGRE_RENDERABLE_DEFAULT_PRIORITY); } } + +//////////////////////////////////////////////////////////////////////////////// +/// Method to allow a caller to abstractly iterate over the Renderable instances +void MovableText::visitRenderables( Ogre::Renderable::Visitor* /*visitor*/, + bool /*debug*/) +{ + return; +} + + Modified: code/gazebo/trunk/server/rendering/MovableText.hh =================================================================== --- code/gazebo/trunk/server/rendering/MovableText.hh 2008-09-29 03:01:33 UTC (rev 7051) +++ code/gazebo/trunk/server/rendering/MovableText.hh 2008-09-29 18:43:10 UTC (rev 7052) @@ -1,4 +1,3 @@ - /* * Gazebo - Outdoor Multi-Robot Simulator * Copyright (C) 2003 @@ -29,139 +28,150 @@ #define MOVABLETEXT_HH #include <Ogre.h> +#include <OgreMovableObject.h> +#include <OgreRenderable.h> +#include <OgreUserDefinedObject.h> #include <string> -/// \brief Movable text -class MovableText : public Ogre::MovableObject, public Ogre::Renderable +namespace gazebo { - /// \brief Horizontal alignment - public: enum HorizAlign {H_LEFT, H_CENTER}; + /// \brief Movable text + class MovableText : public Ogre::MovableObject, public Ogre::Renderable + { + /// \brief Horizontal alignment + public: enum HorizAlign {H_LEFT, H_CENTER}; + + /// \brief vertical alignment + public: enum VertAlign {V_BELOW, V_ABOVE}; + + /// \brief Constructor + public: MovableText(); + + /// \brief Destructor + public: virtual ~MovableText(); + + /// \brief Loads text and font info + public: void Load(const std::string &name, + const Ogre::UTFString &text, + const std::string &fontName = "Arial", + float charHeight = 1.0, + const Ogre::ColourValue &color = Ogre::ColourValue::White); + + /// \brief Set the font + public: void SetFontName(const std::string &font); + + /// \brief Get the font + public: const std::string &GetFont() const; + + /// \brief Set the text to display + public: void SetText(const Ogre::UTFString & caption); + + /// \brief Get the displayed text + public: const Ogre::UTFString & GetText() const; + + /// \brief Set the text color + public: void SetColor(const Ogre::ColourValue & color); + + /// \brief Get the text color + public: const Ogre::ColourValue & GetColor() const; + + /// \brief Set the height of a character + public: void SetCharHeight(float height); + + /// \brief Set the height of a characters + public: float GetCharHeight() const; + + /// \brief Set the width of a space + public:void SetSpaceWidth(float width); + + /// \brief Get the width of a space + public: float GetSpaceWidth() const; + + /// \brief Set the alignment of the text + public: void SetTextAlignment(const HorizAlign &hAlign, + const VertAlign &vAlign); + + /// \brief Set the baseline height of the text + public: void SetBaseline(float height); + + /// \brief Get the baseline height + public: float GetBaseline() const; + + /// \brief True=text always is displayed ontop + public: void SetShowOnTop(bool show); + + /// \brief True=text is displayed on top + public: bool GetShowOnTop() const; + + /// \brief Get the axis aligned bounding box of the text + public: Ogre::AxisAlignedBox GetAABB(); + + /// \brief Method to allow a caller to abstractly iterate over the + // Renderable instances + public: virtual void visitRenderables( Ogre::Renderable::Visitor* visitor, + bool debug = false ); + + /// \brief setup the geometry (from MovableText) + protected: void _setupGeometry(); + + /// \brief update the color(from MovableText) + protected: void _updateColors(); + + /// \brief Get the world transform (from MovableObject) + protected: void getWorldTransforms(Ogre::Matrix4 *xform) const; + + /// \brief Get the bounding radiu (from MovableObject) + protected: float getBoundingRadius() const; + + /// \brief Get the squared view depth (from MovableObject) + protected: float getSquaredViewDepth(const Ogre::Camera *cam) const; + + private: std::string fontName; + private: Ogre::UTFString text; + + private: Ogre::ColourValue color; + private: Ogre::RenderOperation renderOp; + private: Ogre::AxisAlignedBox aabb; + private: Ogre::LightList lightList; + + private: float charHeight; + + private: bool needUpdate; + + private: float radius; + + private: Ogre::Camera *camera; + private: Ogre::RenderWindow *renderWindow; + private: float viewportAspectCoef; + private: Ogre::Font *font; + private: float spaceWidth; + private: bool updateColors; + private: VertAlign vertAlign; + private: HorizAlign horizAlign; + private: bool onTop; + private: float baseline; + private: Ogre::MaterialPtr material; + private: Ogre::MaterialPtr backgroundMaterial; + + private: const Ogre::Quaternion &getWorldOrientation(void) const; + private: const Ogre::Vector3 &getWorldPosition(void) const; + private: const Ogre::AxisAlignedBox &getBoundingBox(void) const; + + private: const Ogre::String &getMovableType() const; + + private: void _notifyCurrentCamera(Ogre::Camera *cam); + private: void _updateRenderQueue(Ogre::RenderQueue* queue); + + /// \brief Get the render operation + protected: void getRenderOperation(Ogre::RenderOperation &op); + + /// \brief Get the material + protected: const Ogre::MaterialPtr &getMaterial(void) const; + + /// \brief Get the lights + protected: const Ogre::LightList &getLights(void) const; //{return mLList;}; + + }; + } - /// \brief vertical alignment - public: enum VertAlign {V_BELOW, V_ABOVE}; - - /// \brief Constructor - public: MovableText(); - - /// \brief Destructor - public: virtual ~MovableText(); - - /// \brief Loads text and font info - public: void Load(const std::string &name, - const Ogre::UTFString &text, - const std::string &fontName = "Arial", - float charHeight = 1.0, - const Ogre::ColourValue &color = Ogre::ColourValue::White); - - /// \brief Set the font - public: void SetFontName(const std::string &font); - - /// \brief Get the font - public: const std::string &GetFont() const; - - /// \brief Set the text to display - public: void SetText(const Ogre::UTFString & caption); - - /// \brief Get the displayed text - public: const Ogre::UTFString & GetText() const; - - /// \brief Set the text color - public: void SetColor(const Ogre::ColourValue & color); - - /// \brief Get the text color - public: const Ogre::ColourValue & GetColor() const; - - /// \brief Set the height of a character - public: void SetCharHeight(float height); - - /// \brief Set the height of a characters - public: float GetCharHeight() const; - - /// \brief Set the width of a space - public:void SetSpaceWidth(float width); - - /// \brief Get the width of a space - public: float GetSpaceWidth() const; - - /// \brief Set the alignment of the text - public: void SetTextAlignment(const HorizAlign &hAlign, - const VertAlign &vAlign); - - /// \brief Set the baseline height of the text - public: void SetBaseline(float height); - - /// \brief Get the baseline height - public: float GetBaseline() const; - - /// \brief True=text always is displayed ontop - public: void SetShowOnTop(bool show); - - /// \brief True=text is displayed on top - public: bool GetShowOnTop() const; - - /// \brief Get the axis aligned bounding box of the text - public: Ogre::AxisAlignedBox GetAABB(); - - /// \brief setup the geometry (from MovableText) - protected: void _setupGeometry(); - - /// \brief update the color(from MovableText) - protected: void _updateColors(); - - /// \brief Get the world transform (from MovableObject) - protected: void getWorldTransforms(Ogre::Matrix4 *xform) const; - - /// \brief Get the bounding radiu (from MovableObject) - protected: float getBoundingRadius() const; - - /// \brief Get the squared view depth (from MovableObject) - protected: float getSquaredViewDepth(const Ogre::Camera *cam) const; - - private: std::string fontName; - private: Ogre::UTFString text; - - private: Ogre::ColourValue color; - private: Ogre::RenderOperation renderOp; - private: Ogre::AxisAlignedBox aabb; - private: Ogre::LightList lightList; - - private: float charHeight; - - private: bool needUpdate; - - private: float radius; - - private: Ogre::Camera *camera; - private: Ogre::RenderWindow *renderWindow; - private: float viewportAspectCoef; - private: Ogre::Font *font; - private: float spaceWidth; - private: bool updateColors; - private: VertAlign vertAlign; - private: HorizAlign horizAlign; - private: bool onTop; - private: float baseline; - private: Ogre::MaterialPtr material; - private: Ogre::MaterialPtr backgroundMaterial; - - private: const Ogre::Quaternion &getWorldOrientation(void) const; - private: const Ogre::Vector3 &getWorldPosition(void) const; - private: const Ogre::AxisAlignedBox &getBoundingBox(void) const; - - private: const Ogre::String &getMovableType() const; - - private: void _notifyCurrentCamera(Ogre::Camera *cam); - private: void _updateRenderQueue(Ogre::RenderQueue* queue); - - /// \brief Get the render operation - protected: void getRenderOperation(Ogre::RenderOperation &op); - - /// \brief Get the material - protected: const Ogre::MaterialPtr &getMaterial(void) const; - - /// \brief Get the lights - protected: const Ogre::LightList &getLights(void) const; //{return mLList;}; - -}; - #endif Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-09-29 03:01:33 UTC (rev 7051) +++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-09-29 18:43:10 UTC (rev 7052) @@ -183,13 +183,13 @@ this->camera->setPolygonMode(Ogre::PM_SOLID); } - Ogre::Vector3 v = this->sceneNode->getWorldPosition(); + Ogre::Vector3 v = this->sceneNode->_getDerivedPosition(); this->pose.pos.x = v.x; this->pose.pos.y = v.y; this->pose.pos.z = v.z; - Ogre::Quaternion q = this->pitchNode->getWorldOrientation(); + Ogre::Quaternion q = this->pitchNode->_getDerivedOrientation(); this->pose.rot.u = q.w; this->pose.rot.x = q.x; Modified: code/gazebo/trunk/server/rendering/SConscript =================================================================== --- code/gazebo/trunk/server/rendering/SConscript 2008-09-29 03:01:33 UTC (rev 7051) +++ code/gazebo/trunk/server/rendering/SConscript 2008-09-29 18:43:10 UTC (rev 7052) @@ -1,14 +1,15 @@ #Import variable Import('env sharedObjs headers') -sources = ['OgreCreator.cc', +sources = [ + 'MovableText.cc', + 'OgreCreator.cc', 'OgreAdaptor.cc', 'OgreFrameListener.cc', 'OgreDynamicRenderable.cc', 'OgreDynamicLines.cc', 'OgreSimpleShape.cc', 'OgreHUD.cc', - 'MovableText.cc', 'OgreVisual.cc', 'OgreCamera.cc', 'CameraManager.cc', Modified: code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc =================================================================== --- code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc 2008-09-29 03:01:33 UTC (rev 7051) +++ code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc 2008-09-29 18:43:10 UTC (rev 7052) @@ -254,8 +254,8 @@ autoParamDataSource.setCurrentViewport(vp); autoParamDataSource.setCurrentRenderTarget(this->renderTargets[i]); autoParamDataSource.setCurrentSceneManager(sceneMgr); - autoParamDataSource.setCurrentCamera(this->GetOgreCamera()); - pass->_updateAutoParamsNoLights(autoParamDataSource); + autoParamDataSource.setCurrentCamera(this->GetOgreCamera(), true); + pass->_updateAutoParamsNoLights(&autoParamDataSource); // These two lines don't seem to do anything useful renderSys->_setProjectionMatrix(this->GetOgreCamera()->getProjectionMatrixRS()); @@ -381,9 +381,9 @@ fprintf( fp, "P6\n# Gazebo\n%d %d\n255\n", this->imageSizeP->GetValue().x, this->imageSizeP->GetValue().y); - for (unsigned int i = 0; i<this->imageSizeP->GetValue().x; i++) + for (unsigned int i = 0; i< (unsigned int)this->imageSizeP->GetValue().x; i++) { - for (unsigned int j =0; j<this->imageSizeP->GetValue().y; j++) + for (unsigned int j =0; j<(unsigned int)this->imageSizeP->GetValue().y; j++) { double f = this->depthBuffer[0][i*this->imageSizeP->GetValue().x+j]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-10-03 22:22:50
|
Revision: 7058 http://playerstage.svn.sourceforge.net/playerstage/?rev=7058&view=rev Author: natepak Date: 2008-10-03 22:22:42 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Fixed some problems with point lights. Improved UV tiling of boxes Modified Paths: -------------- code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/gui/GLWindow.cc code/gazebo/trunk/server/gui/Gui.cc code/gazebo/trunk/server/rendering/OgreCamera.cc code/gazebo/trunk/server/rendering/OgreCreator.cc code/gazebo/trunk/server/rendering/OgreSimpleShape.cc code/gazebo/trunk/server/rendering/OgreSimpleShape.hh code/gazebo/trunk/server/rendering/OgreVisual.cc code/gazebo/trunk/server/rendering/OgreVisual.hh code/gazebo/trunk/server/rendering/UserCamera.cc Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/Simulator.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -158,6 +158,8 @@ // Create the GUI this->gui = new Gui(x, y, width, height, "Gazebo"); + Fl::check(); + Fl::wait(0.3); this->gui->Load(childNode); } } Modified: code/gazebo/trunk/server/gui/GLWindow.cc =================================================================== --- code/gazebo/trunk/server/gui/GLWindow.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/gui/GLWindow.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -450,7 +450,7 @@ // Handle resizing the window void GLWindow::resize(int x, int y, int w, int h) { - Fl_Window::resize(x,y,w,h); + Fl_Gl_Window::resize(x,y,w,h); this->userCamera->Resize(w,h); this->redraw(); Modified: code/gazebo/trunk/server/gui/Gui.cc =================================================================== --- code/gazebo/trunk/server/gui/Gui.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/gui/Gui.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -29,6 +29,7 @@ #include <FL/Fl_Menu_Item.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Choice.H> +#include <FL/Fl_Gl_Window.H> #include "Global.hh" #include "XMLConfig.hh" @@ -89,6 +90,7 @@ this->show(); Fl::check(); + Fl::wait(0.3); // Create a dummy rendering window. This creates a context, and allows Ogre // to initialize properly Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -158,6 +158,7 @@ this->pitchNode = this->sceneNode->createChildSceneNode( this->cameraName + "PitchNode"); this->pitchNode->pitch(Ogre::Degree(0)); this->pitchNode->attachObject(this->camera); + this->camera->setAutoAspectRatio(true); this->saveCount = 0; Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -68,7 +68,8 @@ // Create some basic shapes OgreSimpleShape::CreateSphere("unit_sphere",1.0, 32, 32); OgreSimpleShape::CreateSphere("joint_anchor",0.01, 32, 32); - OgreSimpleShape::CreateBox("unit_box", Vector3(1,1,1)); + OgreSimpleShape::CreateBox("unit_box_U1V1", Vector3(1,1,1), + Vector2<double>(1,1)); OgreSimpleShape::CreateCylinder("unit_cylinder", 0.5, 1.0, 1, 32); } @@ -159,7 +160,7 @@ // Set the direction which the light points vec = node->GetVector3("direction", Vector3(0.0, 0.0, -1.0)); - light->setDirection(vec.x, vec.y, vec.z); + //light->setDirection(vec.x, vec.y, vec.z); // Absolute range of light in world coordinates range = node->GetTupleDouble("attenuation",0,1000); @@ -571,6 +572,7 @@ Ogre::RenderWindow *window = NULL; params["parentWindowHandle"] = Ogre::StringConverter::toString(display) + ":" + Ogre::StringConverter::toString(screen) + ":" + Ogre::StringConverter::toString(winId); + //params["FSAA"] = Ogre::StringConverter::toString(2); std::ostringstream stream; stream << "OgreWindow(" << windowCounter++ << ")"; Modified: code/gazebo/trunk/server/rendering/OgreSimpleShape.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreSimpleShape.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreSimpleShape.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -162,7 +162,8 @@ //////////////////////////////////////////////////////////////////////////////// /// Create a Box mesh -void OgreSimpleShape::CreateBox(const std::string &name, const Vector3 &sides) +void OgreSimpleShape::CreateBox(const std::string &name, const Vector3 &sides, + const Vector2<double> &uvCoords) { Ogre::MeshPtr mesh; Ogre::SubMesh *subMesh; @@ -237,33 +238,33 @@ // Vertex values float v[8][3] = { - {-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1}, - {-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1} + {-1, -1, -1}, {-1, -1, +1}, {+1, -1, +1}, {+1, -1, -1}, + {-1, +1, -1}, {-1, +1, +1}, {+1, +1, +1}, {+1, +1, -1} }; // Normals for each vertex float n[8][3]= { {-0.577350, -0.577350, -0.577350}, + {-0.577350, -0.577350, 0.577350}, + {0.577350, -0.577350, 0.577350}, {0.577350, -0.577350, -0.577350}, - {0.577350, 0.577350, -0.577350}, {-0.577350, 0.577350, -0.577350}, - {-0.577350, -0.577350, 0.577350}, - {0.577350, -0.577350, 0.577350}, + {-0.577350, 0.577350, 0.577350}, {0.577350, 0.577350, 0.577350}, - {-0.577350, 0.577350, 0.577350} + {0.577350, 0.577350, -0.577350} }; // Texture coords - int t[4][2] = + float t[4][2] = { - {0, 1}, {1,1}, {1, 0}, {0,0} + {uvCoords.x, 0}, {0, 0}, {0,uvCoords.y}, {uvCoords.x, uvCoords.y} }; // Vertices int faces[6][4] = { - {2, 1, 0, 3}, {6, 7, 4, 5}, + {2, 1, 0, 3}, {5, 6, 7, 4}, {2, 6, 5, 1}, {1, 5, 4, 0}, {0, 4, 7, 3}, {6, 2, 3, 7} }; @@ -275,14 +276,14 @@ 2, 3, 0, 4, 5, 7, 7, 5, 6, - 8, 9, 11, - 11, 9, 10, + 11,8,9, + 9,10,11, 12, 13, 15, 15, 13, 14, 16, 17, 18, 18, 19, 16, - 20, 21, 23, - 23, 21, 22 + 21,22,23, + 23,20,21, }; // Compute the vertices @@ -301,7 +302,9 @@ { // Set the vertex for (j=0; j<3; j++) + { *vertices++ = v[faces[i][k]][j]; + } // Set the normal for (j=0; j<3; j++) Modified: code/gazebo/trunk/server/rendering/OgreSimpleShape.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreSimpleShape.hh 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreSimpleShape.hh 2008-10-03 22:22:42 UTC (rev 7058) @@ -4,6 +4,7 @@ #include <Ogre.h> #include "Vector3.hh" +#include "Vector2.hh" namespace gazebo { @@ -23,7 +24,8 @@ public: static void CreateSphere(const std::string &name, float radius, int rings, int segments); /// \brief Create a Box mesh - public: static void CreateBox(const std::string &name, const Vector3 &sides); + public: static void CreateBox(const std::string &name, const Vector3 &sides, + const Vector2<double> &uvCoords); /// \brief Create a cylinder mesh public: static void CreateCylinder(const std::string &name, float radius, float height, int rings, int segments); Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -24,6 +24,7 @@ * SVN: $Id$ */ #include <Ogre.h> +#include "OgreSimpleShape.hh" #include "Entity.hh" #include "GazeboMessage.hh" #include "GazeboError.hh" @@ -67,6 +68,8 @@ this->rpyP->Callback( &OgreVisual::SetRotation, this ); this->meshNameP = new ParamT<std::string>("mesh","",1); + this->meshTileP = new ParamT< Vector2<double> >("uvTile", + Vector2<double>(1.0, 1.0), 0 ); this->materialNameP = new ParamT<std::string>("material",std::string(),0); this->materialNameP->Callback( &OgreVisual::SetMaterial, this ); @@ -89,6 +92,7 @@ delete this->xyzP; delete this->rpyP; delete this->meshNameP; + delete this->meshTileP; delete this->materialNameP; delete this->castShadowsP; } @@ -106,6 +110,7 @@ this->xyzP->Load(node); this->rpyP->Load(node); this->meshNameP->Load(node); + this->meshTileP->Load(node); this->materialNameP->Load(node); this->castShadowsP->Load(node); @@ -117,7 +122,21 @@ { // Create the entity stream << "ENTITY_" << this->sceneNode->getName(); - obj = (Ogre::MovableObject*)this->sceneNode->getCreator()->createEntity(stream.str(), this->meshNameP->GetValue()); + std::string meshName = (**this->meshNameP); + + if ( meshName == "unit_box") + { + meshName += "_U" + + boost::lexical_cast<std::string>(this->meshTileP->GetValue().x) + "V" + + boost::lexical_cast<std::string>(this->meshTileP->GetValue().y); + + if (!this->sceneNode->getCreator()->hasEntity(meshName)) + { + OgreSimpleShape::CreateBox(meshName, Vector3(1,1,1), **this->meshTileP); + } + } + + obj = (Ogre::MovableObject*)this->sceneNode->getCreator()->createEntity(stream.str(), meshName); } catch (Ogre::Exception e) { @@ -537,7 +556,7 @@ this->boundingBoxNode = this->sceneNode->createChildSceneNode(nodeName.str()); this->boundingBoxNode->setInheritScale(false); - Ogre::MovableObject *odeObj = (Ogre::MovableObject*)(this->sceneNode->getCreator()->createEntity(nodeName.str()+"_OBJ", "unit_box")); + Ogre::MovableObject *odeObj = (Ogre::MovableObject*)(this->sceneNode->getCreator()->createEntity(nodeName.str()+"_OBJ", "unit_box_U1V1")); this->boundingBoxNode->attachObject(odeObj); Vector3 diff = max-min; Modified: code/gazebo/trunk/server/rendering/OgreVisual.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-10-03 22:22:42 UTC (rev 7058) @@ -147,6 +147,7 @@ private: ParamT<bool> *castShadowsP; private: ParamT<Vector3> *sizeP; private: ParamT<Vector3> *scaleP; + private: ParamT<Vector2<double> > *meshTileP; }; } Modified: code/gazebo/trunk/server/rendering/UserCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -98,9 +98,14 @@ /// Resize the camera void UserCamera::Resize(unsigned int w, unsigned int h) { - this->window->resize(w, h); - this->viewport->setDimensions(0,0,1,1); - this->SetAspectRatio( Ogre::Real(this->viewport->getActualWidth()) / Ogre::Real(this->viewport->getActualHeight()) ); + //this->window->resize(w, h); + //this->viewport->setDimensions(0,0,1,1); + //this->SetAspectRatio( Ogre::Real(this->viewport->getActualWidth()) / Ogre::Real(this->viewport->getActualHeight()) ); + //this->viewport->update(); + //this->viewport->_updateDimensions(); + + this->window->windowMovedOrResized(); + printf("Resize[%d %d] new[%d %d]\n", w, h, this->window->getWidth(), this->window->getHeight()); } //////////////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-10-21 21:46:19
|
Revision: 7110 http://playerstage.svn.sourceforge.net/playerstage/?rev=7110&view=rev Author: natepak Date: 2008-10-21 21:46:11 +0000 (Tue, 21 Oct 2008) Log Message: ----------- Added the ability to save frames from a user camera Modified Paths: -------------- code/gazebo/trunk/server/gui/GLFrame.cc code/gazebo/trunk/server/gui/GLFrame.hh code/gazebo/trunk/server/rendering/OgreCamera.cc code/gazebo/trunk/server/rendering/OgreCamera.hh code/gazebo/trunk/server/rendering/UserCamera.cc code/gazebo/trunk/server/rendering/UserCamera.hh Modified: code/gazebo/trunk/server/gui/GLFrame.cc =================================================================== --- code/gazebo/trunk/server/gui/GLFrame.cc 2008-10-20 20:02:26 UTC (rev 7109) +++ code/gazebo/trunk/server/gui/GLFrame.cc 2008-10-21 21:46:11 UTC (rev 7110) @@ -107,11 +107,14 @@ // Load the frame void GLFrame::Load( XMLConfigNode *node ) { + this->saveFrames = false; if (node) { this->startPose.pos = node->GetVector3("xyz", Vector3(0,0,0)); this->startPose.rot = node->GetRotation("rpy", Quatern()); + this->saveFrames = node->GetBool("saveFrames",false,0); + this->savePathname = node->GetString("saveFramePath","",0); } } @@ -122,6 +125,8 @@ { this->glWindow->Init(); this->glWindow->GetCamera()->SetWorldPose(this->startPose); + this->glWindow->GetCamera()->EnableSaveFrame(this->saveFrames); + this->glWindow->GetCamera()->SetSaveFramePathname(this->savePathname); CameraManager::Instance()->ConnectAddCameraSignal( boost::bind(&GLFrame::CameraAddedSlot, this, _1) ); } Modified: code/gazebo/trunk/server/gui/GLFrame.hh =================================================================== --- code/gazebo/trunk/server/gui/GLFrame.hh 2008-10-20 20:02:26 UTC (rev 7109) +++ code/gazebo/trunk/server/gui/GLFrame.hh 2008-10-21 21:46:11 UTC (rev 7110) @@ -96,6 +96,9 @@ /// Starting pose of the camera private: Pose3d startPose; + + private: bool saveFrames; + private: std::string savePathname; }; } Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-20 20:02:26 UTC (rev 7109) +++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-21 21:46:11 UTC (rev 7110) @@ -313,6 +313,21 @@ } ////////////////////////////////////////////////////////////////////////////// +// Set the save frame pathname +void OgreCamera::SetSaveFramePathname(const std::string &pathname) +{ + this->savePathnameP->SetValue( pathname ); + + // Create the directory to store frames + if (this->saveFramesP->GetValue()) + { + std::string command; + command = "mkdir " + this->savePathnameP->GetValue() + " 2>>/dev/null"; + system(command.c_str()); + } +} + +////////////////////////////////////////////////////////////////////////////// /// Toggle saving of frames void OgreCamera::ToggleSaveFrame() { Modified: code/gazebo/trunk/server/rendering/OgreCamera.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.hh 2008-10-20 20:02:26 UTC (rev 7109) +++ code/gazebo/trunk/server/rendering/OgreCamera.hh 2008-10-21 21:46:11 UTC (rev 7110) @@ -141,7 +141,10 @@ /// \brief Enable or disable saving public: void EnableSaveFrame(bool enable); - + + /// \brief Set the save frame pathname + public: void SetSaveFramePathname(const std::string &pathname); + /// \brief Toggle saving of frames public: void ToggleSaveFrame(); Modified: code/gazebo/trunk/server/rendering/UserCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-20 20:02:26 UTC (rev 7109) +++ code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-21 21:46:11 UTC (rev 7110) @@ -36,13 +36,21 @@ using namespace gazebo; +int UserCamera::count = 0; + //////////////////////////////////////////////////////////////////////////////// /// Constructor UserCamera::UserCamera(GLWindow *parentWindow) : OgreCamera("UserCamera") { + std::stringstream stream; + this->window = OgreCreator::CreateWindow(parentWindow, parentWindow->w(), parentWindow->h()); + + + stream << "UserCamera_" << this->count++; + this->name = stream.str(); } //////////////////////////////////////////////////////////////////////////////// @@ -75,6 +83,7 @@ this->SetAspectRatio( Ogre::Real(this->viewport->getActualWidth()) / Ogre::Real(this->viewport->getActualHeight()) ); this->viewport->setVisibilityMask(this->visibilityMask); + } //////////////////////////////////////////////////////////////////////////////// @@ -84,6 +93,25 @@ OgreCamera::UpdateCam(); OgreAdaptor::Instance()->UpdateWindow(this->window, this); + + + if (this->saveFramesP->GetValue()) + { + char tmp[1024]; + if (!this->savePathnameP->GetValue().empty()) + { + sprintf(tmp, "%s/%s-%04d.jpg", this->savePathnameP->GetValue().c_str(), + this->name.c_str(), this->saveCount); + } + else + { + sprintf(tmp, "%s-%04d.jpg", this->name.c_str(), this->saveCount); + } + + this->window->writeContentsToFile(tmp); + + this->saveCount++; + } } Modified: code/gazebo/trunk/server/rendering/UserCamera.hh =================================================================== --- code/gazebo/trunk/server/rendering/UserCamera.hh 2008-10-20 20:02:26 UTC (rev 7109) +++ code/gazebo/trunk/server/rendering/UserCamera.hh 2008-10-21 21:46:11 UTC (rev 7110) @@ -80,6 +80,7 @@ private: std::string name; private: static unsigned int cameraCount; + private: static int count; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-10-29 22:03:02
|
Revision: 7120 http://playerstage.svn.sourceforge.net/playerstage/?rev=7120&view=rev Author: natepak Date: 2008-10-29 21:43:23 +0000 (Wed, 29 Oct 2008) Log Message: ----------- Added ability to turn saving of frames on and off Modified Paths: -------------- code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc Modified: code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc =================================================================== --- code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc 2008-10-29 19:20:33 UTC (rev 7119) +++ code/gazebo/trunk/server/controllers/camera/generic/Generic_Camera.cc 2008-10-29 21:43:23 UTC (rev 7120) @@ -135,6 +135,8 @@ memcpy(dst, src, data->image_size); + this->myParent->EnableSaveFrame( data->saveFrames ); + this->cameraIface->Unlock(); // New data is available Modified: code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc =================================================================== --- code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc 2008-10-29 19:20:33 UTC (rev 7119) +++ code/gazebo/trunk/server/sensors/camera/MonoCameraSensor.cc 2008-10-29 21:43:23 UTC (rev 7120) @@ -27,6 +27,7 @@ #include <sstream> #include <OgreImageCodec.h> #include <Ogre.h> +#include <dirent.h> #include "Controller.hh" #include "Global.hh" @@ -177,7 +178,9 @@ if (this->saveFramesP->GetValue()) + { this->SaveFrame(); + } } //////////////////////////////////////////////////////////////////////////////// @@ -210,6 +213,15 @@ this->GetImageData(); + // Create a directory if not present + DIR *dir = opendir( this->savePathnameP->GetValue().c_str() ); + if (!dir) + { + std::string command; + command = "mkdir " + this->savePathnameP->GetValue() + " 2>>/dev/null"; + system(command.c_str()); + } + // Get access to the buffer and make an image and write it to file mBuffer = this->renderTexture->getBuffer(0, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-12-08 23:33:41
|
Revision: 7196 http://playerstage.svn.sourceforge.net/playerstage/?rev=7196&view=rev Author: natepak Date: 2008-12-08 23:33:35 +0000 (Mon, 08 Dec 2008) Log Message: ----------- Fixed seg fault on quit, and removed some printfs Modified Paths: -------------- code/gazebo/trunk/server/controllers/Controller.cc code/gazebo/trunk/server/rendering/OgreCreator.cc code/gazebo/trunk/server/rendering/OgreVisual.cc code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc Modified: code/gazebo/trunk/server/controllers/Controller.cc =================================================================== --- code/gazebo/trunk/server/controllers/Controller.cc 2008-12-08 06:42:11 UTC (rev 7195) +++ code/gazebo/trunk/server/controllers/Controller.cc 2008-12-08 23:33:35 UTC (rev 7196) @@ -82,14 +82,6 @@ childNode = node->GetChildByNSPrefix("interface"); - Entity * test = this->parent; - while(test->GetParent()!=NULL) - { - test = test->GetParent(); - } - - - // Create the interfaces while (childNode) { @@ -116,9 +108,6 @@ continue; } - - ifaceName = test->GetName()+"-" + ifaceName; - // Create the iface try { Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-12-08 06:42:11 UTC (rev 7195) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-12-08 23:33:35 UTC (rev 7196) @@ -587,7 +587,14 @@ std::ostringstream stream; stream << "OgreWindow(" << windowCounter++ << ")"; - window = OgreAdaptor::Instance()->root->createRenderWindow( stream.str(), width, height, false, ¶ms); + try + { + window = OgreAdaptor::Instance()->root->createRenderWindow( stream.str(), width, height, false, ¶ms); + } + catch (...) + { + gzerr(0) << " Unable to create the rendering window\n"; + } window->setActive(true); window->setAutoUpdated(true); Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-12-08 06:42:11 UTC (rev 7195) +++ code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-12-08 23:33:35 UTC (rev 7196) @@ -96,10 +96,15 @@ delete this->materialNameP; delete this->castShadowsP; - if (this->parentNode) - this->parentNode->removeChild( this->sceneNode ); + // Having this chunk of code causes a segfault when closing the + // application. + /*if (this->parentNode && this->sceneNode) + { + this->parentNode->removeChild( this->sceneNode ); + } this->sceneNode->removeAndDestroyAllChildren(); + */ if (this->sceneNode) OgreAdaptor::Instance()->sceneMgr->destroySceneNode(this->sceneNode); Modified: code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc =================================================================== --- code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc 2008-12-08 06:42:11 UTC (rev 7195) +++ code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc 2008-12-08 23:33:35 UTC (rev 7196) @@ -181,7 +181,7 @@ this->rgbBuffer[1] = new unsigned char[this->rgbBufferSize]; // Uncomment this section to create a debug overaly - /*{ + { Ogre::Overlay *overlay = Ogre::OverlayManager::getSingletonPtr()->create("__GAZEBO_STEREO_DEBUG_OVERLAY__"); Ogre::OverlayContainer *overlayPanel = (Ogre::OverlayContainer*)(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "__GAZEBO_PANEL")); @@ -192,7 +192,7 @@ overlay->add2D(overlayPanel); overlay->show(); - }*/ + } } ////////////////////////////////////////////////////////////////////////////// @@ -365,12 +365,6 @@ this->imageSizeP->GetValue().y, 1, PF_FLOAT, this->depthBuffer[i-2]) ); - - for (int i=0; i < this->depthBufferSize; i++) - { - printf("%f ",this->depthBuffer[i]); - } - printf("\n"); } hardwareBuffer->unlock(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2008-12-12 02:15:58
|
Revision: 7202 http://playerstage.svn.sourceforge.net/playerstage/?rev=7202&view=rev Author: natepak Date: 2008-12-12 02:15:53 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Fixed stereo camera depth computation. Fixed Pose3d subtraction Modified Paths: -------------- code/gazebo/trunk/server/Pose3d.cc code/gazebo/trunk/server/Quatern.cc code/gazebo/trunk/server/Quatern.hh code/gazebo/trunk/server/physics/Body.cc code/gazebo/trunk/server/physics/Geom.cc code/gazebo/trunk/server/physics/ode/ODEPhysics.cc code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc Modified: code/gazebo/trunk/server/Pose3d.cc =================================================================== --- code/gazebo/trunk/server/Pose3d.cc 2008-12-11 01:10:35 UTC (rev 7201) +++ code/gazebo/trunk/server/Pose3d.cc 2008-12-12 02:15:53 UTC (rev 7202) @@ -183,7 +183,9 @@ // Subtract one rotation from another: result = this->rot - rot Quatern Pose3d::CoordRotationSub(const Quatern &rot) const { - return rot.GetInverse() * this->rot; + Quatern result(rot.GetInverse() * this->rot); + result.Normalize(); + return result; } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/Quatern.cc =================================================================== --- code/gazebo/trunk/server/Quatern.cc 2008-12-11 01:10:35 UTC (rev 7201) +++ code/gazebo/trunk/server/Quatern.cc 2008-12-12 02:15:53 UTC (rev 7202) @@ -102,6 +102,8 @@ q.y = -this->y; q.z = -this->z; + //q.Normalize(); + return q; } @@ -240,15 +242,33 @@ } //////////////////////////////////////////////////////////////////////////////// +/// Addition operator +Quatern Quatern::operator+( const Quatern &qt ) const +{ + Quatern result(this->u + qt.u, this->x + qt.x, + this->y + qt.y, this->z + qt.z); + return result; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Substraction operator +Quatern Quatern::operator-( const Quatern &qt ) const +{ + Quatern result(this->u - qt.u, this->x - qt.x, + this->y - qt.y, this->z - qt.z); + return result; +} + +//////////////////////////////////////////////////////////////////////////////// // Multiplication operator Quatern Quatern::operator*( const Quatern &qt ) const { Quatern c; - c.u = this->u * qt.u - this->x * qt.x - this->y * qt.y - this->z * qt.z; c.x = this->u * qt.x + this->x * qt.u + this->y * qt.z - this->z * qt.y; c.y = this->u * qt.y - this->x * qt.z + this->y * qt.u + this->z * qt.x; c.z = this->u * qt.z + this->x * qt.y - this->y * qt.x + this->z * qt.u; + c.u = this->u * qt.u - this->x * qt.x - this->y * qt.y - this->z * qt.z; return c; } Modified: code/gazebo/trunk/server/Quatern.hh =================================================================== --- code/gazebo/trunk/server/Quatern.hh 2008-12-11 01:10:35 UTC (rev 7201) +++ code/gazebo/trunk/server/Quatern.hh 2008-12-12 02:15:53 UTC (rev 7202) @@ -110,6 +110,16 @@ /// \param scale Amount to scale this rotation public: void Scale(double scale); + /// \brief Addition operator + /// \param qt Quatern for addition + /// \return This quatern + qt + public: Quatern operator+( const Quatern &qt ) const; + + /// \brief Substraction operator + /// \param qt Quatern for substraction + /// \return This quatern - qt + public: Quatern operator-( const Quatern &qt ) const; + /// \brief Multiplication operator /// \param qt Quatern for multiplication /// \return This quatern multiplied by the parameter Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2008-12-11 01:10:35 UTC (rev 7201) +++ code/gazebo/trunk/server/physics/Body.cc 2008-12-12 02:15:53 UTC (rev 7202) @@ -287,7 +287,6 @@ // Set the pose of the body void Body::SetPose(const Pose3d &pose) { - this->pose = pose; if (this->IsStatic()) @@ -298,17 +297,13 @@ std::map<std::string, Geom*>::iterator iter; - this->SetPosition(this->staticPose.pos); - this->SetRotation(this->staticPose.rot); - // This loop doesn't work properly when rotating objects - /*for (iter = this->geoms.begin(); iter != this->geoms.end(); iter++) + for (iter = this->geoms.begin(); iter != this->geoms.end(); iter++) { - //newPose = (*iter)->GetPose() - this->staticPose; newPose = iter->second->GetPose() - oldPose; newPose += this->staticPose; iter->second->SetPose(newPose); - }*/ + } } else { Modified: code/gazebo/trunk/server/physics/Geom.cc =================================================================== --- code/gazebo/trunk/server/physics/Geom.cc 2008-12-11 01:10:35 UTC (rev 7201) +++ code/gazebo/trunk/server/physics/Geom.cc 2008-12-12 02:15:53 UTC (rev 7202) @@ -287,7 +287,7 @@ //////////////////////////////////////////////////////////////////////////////// // Set the pose relative to the body -void Geom::SetPose(const Pose3d &pose, bool updateCoM) +void Geom::SetPose(const Pose3d &newPose, bool updateCoM) { if (this->placeable && this->geomId) { @@ -295,7 +295,7 @@ dQuaternion q; // Transform into CoM relative Pose - localPose = pose - this->body->GetCoMPose(); + localPose = newPose - this->body->GetCoMPose(); q[0] = localPose.rot.u; q[1] = localPose.rot.x; @@ -307,7 +307,7 @@ dGeomSetPosition(this->geomId, localPose.pos.x, localPose.pos.y, localPose.pos.z); dGeomSetQuaternion(this->geomId, q); - this->visualNode->SetPose(pose); + this->visualNode->SetPose(newPose); if (updateCoM) { Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2008-12-11 01:10:35 UTC (rev 7201) +++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2008-12-12 02:15:53 UTC (rev 7202) @@ -138,7 +138,7 @@ // Update the dynamical model dWorldStep( this->worldId, this->stepTimeP->GetValue() ); - //dWorldQuickStep(this->worldId, this->stepTime); + //dWorldQuickStep(this->worldId, this->stepTimeP->GetValue()); // Very important to clear out the contact group dJointGroupEmpty( this->contactGroup ); Modified: code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc =================================================================== --- code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc 2008-12-11 01:10:35 UTC (rev 7201) +++ code/gazebo/trunk/server/sensors/camera/StereoCameraSensor.cc 2008-12-12 02:15:53 UTC (rev 7202) @@ -43,7 +43,7 @@ #include "CameraManager.hh" #include "StereoCameraSensor.hh" -#define PF_FLOAT Ogre::PF_FLOAT16_R +#define PF_FLOAT Ogre::PF_FLOAT32_R #define PF_RGB Ogre::PF_B8G8R8 using namespace gazebo; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-01-16 04:32:15
|
Revision: 7275 http://playerstage.svn.sourceforge.net/playerstage/?rev=7275&view=rev Author: natepak Date: 2009-01-16 04:32:09 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Added audio_video directory Modified Paths: -------------- code/gazebo/trunk/server/SConscript code/gazebo/trunk/server/rendering/UserCamera.cc Added Paths: ----------- code/gazebo/trunk/server/audio_video/ code/gazebo/trunk/server/audio_video/AudioDecoder.cc code/gazebo/trunk/server/audio_video/AudioDecoder.hh code/gazebo/trunk/server/audio_video/OpenAL.cc code/gazebo/trunk/server/audio_video/OpenAL.hh code/gazebo/trunk/server/audio_video/SConscript Modified: code/gazebo/trunk/server/SConscript =================================================================== --- code/gazebo/trunk/server/SConscript 2009-01-15 23:15:17 UTC (rev 7274) +++ code/gazebo/trunk/server/SConscript 2009-01-16 04:32:09 UTC (rev 7275) @@ -1,7 +1,7 @@ #Import variables Import('env install_prefix sharedObjs headers') -dirs = Split('physics rendering sensors controllers gui')# bindings') +dirs = Split('physics rendering sensors controllers gui audio_video')# bindings') for subdir in dirs: SConscript('%s/SConscript' % subdir) Added: code/gazebo/trunk/server/audio_video/AudioDecoder.cc =================================================================== --- code/gazebo/trunk/server/audio_video/AudioDecoder.cc (rev 0) +++ code/gazebo/trunk/server/audio_video/AudioDecoder.cc 2009-01-16 04:32:09 UTC (rev 7275) @@ -0,0 +1,173 @@ +#include <stdlib.h> +#include <string.h> + +#include "AudioDecoder.hh" + +bool AudioDecoder::initialized = false; + +//////////////////////////////////////////////////////////////////////////////// +/// Constructor +AudioDecoder::AudioDecoder() +{ + this->formatCtx = NULL; + this->codecCtx = NULL; + this->codec = NULL; + this->audioStream = 0; + + // Initialize the ffmpeg library only once + if (!initialized) + { + initialized = true; + avcodec_init(); + avcodec_register_all(); + + // Register all formats and codecs + av_register_all(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// Destructor +AudioDecoder::~AudioDecoder() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +/// Decode and audio file +int AudioDecoder::Decode(uint8_t **outBuffer, unsigned int *outBufferSize) +{ + AVPacket packet; + char tmpBuf[AVCODEC_MAX_AUDIO_FRAME_SIZE]; + int tmpBufsize = 0; + int bytesDecoded = 0; + unsigned int maxBufferSize = 0; + + if (this->codec == NULL) + { + printf("Set and audio file before decoding.\n"); + return -1; + } + + if (outBufferSize == NULL) + { + printf("outBufferSize is NULL!!\n"); + return -1; + } + + *outBufferSize = 0; + + if (*outBuffer) + { + delete [] *outBuffer; + *outBuffer = NULL; + } + + // Read the next frame of a stream + while (av_read_frame(this->formatCtx, &packet) >=0) + { + if (packet.stream_index == this->audioStream) + { + tmpBufsize = sizeof(tmpBuf); + + // Decode the frame + bytesDecoded = avcodec_decode_audio2( this->codecCtx, (int16_t*)tmpBuf, + &tmpBufsize, packet.data, packet.size ); + + if (bytesDecoded < 0) + { + printf("Error decoding audio\n"); + return -1; + } + + if (tmpBufsize <= 0) + { + printf("No data yet\n"); + return -1; + } + + // Resize the audio buffer as necessary + if (*outBufferSize + tmpBufsize > maxBufferSize) + { + maxBufferSize += tmpBufsize * 10; + *outBuffer = (uint8_t*)realloc(*outBuffer, + maxBufferSize * sizeof(*outBuffer[0]) ); + } + + memcpy(*outBuffer + *outBufferSize, tmpBuf, tmpBufsize); + *outBufferSize += tmpBufsize; + } + } + + av_free_packet(&packet); + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Get the sample rate from the latest decoded file +int AudioDecoder::GetSampleRate() +{ + return this->codecCtx->sample_rate; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Helper function to read in an audio file +int AudioDecoder::SetFile(const std::string &filename) +{ + unsigned int i; + + // Open file + if (av_open_input_file(&this->formatCtx, filename.c_str(), NULL, 0, NULL) != 0) + { + printf("Unable to open input file\n"); + return -1; + } + + // Retrieve some information + if (av_find_stream_info(this->formatCtx) < 0) + { + printf("Unable to find stream info\n"); + return -1; + } + + // Dump information about file onto standard error + //dump_format(formatCtx, 0, "dump.txt", false); + + // Find audio stream; + this->audioStream = -1; + for (i=0; i < this->formatCtx->nb_streams; i++) + { + if (this->formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) + { + this->audioStream = i; + break; + } + } + + if (this->audioStream == -1) + { + printf("Couldn't find audio stream\n"); + return -1; + } + + // Get the audio stream codec + this->codecCtx = this->formatCtx->streams[audioStream]->codec; + + // Find a decoder + this->codec = avcodec_find_decoder(codecCtx->codec_id); + + if (this->codec == NULL) + { + perror("couldn't find codec"); + return -1; + } + + if (this->codec->capabilities & CODEC_CAP_TRUNCATED) + this->codecCtx->flags |= CODEC_FLAG_TRUNCATED; + + // Open codec + if (avcodec_open(this->codecCtx, this->codec) < 0) + perror("couldn't open codec"); + + return 0; +} Added: code/gazebo/trunk/server/audio_video/AudioDecoder.hh =================================================================== --- code/gazebo/trunk/server/audio_video/AudioDecoder.hh (rev 0) +++ code/gazebo/trunk/server/audio_video/AudioDecoder.hh 2009-01-16 04:32:09 UTC (rev 7275) @@ -0,0 +1,40 @@ +#ifndef AUDIODECODER_HH +#define AUDIODECODER_HH + +extern "C" { +#include <libavformat/avformat.h> +#include <libavcodec/avcodec.h> +} + +#include <string> + +class AudioDecoder +{ + /// \brief Constructor + public: AudioDecoder(); + + /// \brief Destructor + public: virtual ~AudioDecoder(); + + /// \brief Set the file to decode + public: int SetFile(const std::string &filename); + + /// \brief Decode and audio file + public: int Decode(uint8_t **outBuffer, unsigned int *outBufferSize); + + /// \brief Get the sample rate from the latest decoded file + public: int GetSampleRate(); + + private: AVFormatContext *formatCtx; + private: AVCodecContext *codecCtx; + + // libavcodec audio codec + private: AVCodec *codec; + + // Index of the audio stream + private: int audioStream; + + private: static bool initialized; +}; + +#endif Added: code/gazebo/trunk/server/audio_video/OpenAL.cc =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.cc (rev 0) +++ code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-01-16 04:32:09 UTC (rev 7275) @@ -0,0 +1,396 @@ +#include <stdio.h> +#include <unistd.h> +#include <iostream> + +#include <AL/alut.h> +#include <AL/alc.h> + +#include "AudioDecoder.hh" +#include "OpenAL.hh" + +#ifndef NULL +#define NULL 0 +#endif + + +//////////////////////////////////////////////////////////////////////////////// +///// Constructor +OpenAL::OpenAL() +{ + this->context = NULL; + this->audioDevice = NULL; + + this->pos[0] = this->pos[1] = this->pos[2] = 0.0; + this->pos[0] = -10.0; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Destructor +OpenAL::~OpenAL() +{ + if (this->context && this->audioDevice) + { + this->context = alcGetCurrentContext(); + this->audioDevice = alcGetContextsDevice(this->context); + alcMakeContextCurrent(NULL); + alcDestroyContext(this->context); + alcCloseDevice(this->audioDevice); + } + + this->sources.clear(); + this->buffers.clear(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Initialize +int OpenAL::Init() +{ + // Open the default audio device + this->audioDevice = alcOpenDevice("ALSA Software on HDA Intel"); + if (this->audioDevice == NULL) + { + printf("Unable to open audio device\n"); + return -1; + } + + this->context = alcCreateContext(this->audioDevice, NULL); + + alcMakeContextCurrent(this->context); + + //Clear error code + alGetError(); + + // TODO: put in function to set distance model + //alDistanceModel(AL_EXPONENT_DISTANCE); + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Create a sound source +unsigned int OpenAL::CreateSource() +{ + unsigned int source; + + //Create 1 source + alGenSources(1, &source); + + this->sources.push_back(source); + + return this->sources.size()-1; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Create an audio data buffer +unsigned int OpenAL::CreateBuffer(const std::string &audioFile) +{ + unsigned int buffer; + uint8_t *dataBuffer = NULL; + unsigned int dataBufferSize; + + // Create an audio decoder + AudioDecoder audioDecoder; + + // Create and openAL audio buffer + alGenBuffers(1, &buffer); + + // Store the openAL buffer + this->buffers.push_back(buffer); + + // Set the audio file to decode + audioDecoder.SetFile(audioFile); + audioDecoder.Decode(&dataBuffer, &dataBufferSize); + + // Fill the openAL data buffer + this->SetData(buffer, dataBuffer, dataBufferSize, + audioDecoder.GetSampleRate() ); + + if (dataBuffer) + delete [] dataBuffer; + + return this->buffers.size()-1; +} + + +//////////////////////////////////////////////////////////////////////////////// +/// Update all the sources and the listener +void OpenAL::Update() +{ + //ALfloat pos[3]; + ALfloat vel[3]; + + //for (int i=0; i< this->sourceCount; i++) + { + + //alGetSourcefv(0, AL_VELOCITY, vel); + //alGetSourcefv(0, AL_POSITION, pos); + + vel[0] = 0.1; + vel[1] = 0.0; + vel[2] = 0.0; + + this->pos[0] += 0.01; + this->pos[1] = 0; + this->pos[2] = 0; + + //printf("p[%f %f %f] v[%f %f %f]\n", pos[0], pos[1], pos[2], vel[0], vel[1], vel[2]); + this->SetSourcePos(0, this->pos[0], this->pos[1], this->pos[2] ); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the data +int OpenAL::SetData(unsigned int index, uint8_t *data, unsigned int dataSize, unsigned int freq) +{ + // Clear the error buffer; + alGetError(); + + printf("Set Data Freq[%d] DataSize[%d]\n",freq, dataSize); + + // Copy raw buffer into AL buffer 0 + // AL_FORMAT_MONO8, AL_FORMAT_MONO16, AL_FORMAT_STEREO8, + // AL_FORMAT_STEREO16 + alBufferData( this->buffers[0], AL_FORMAT_MONO16, data, dataSize, freq); + + if ( alGetError() != AL_NO_ERROR) + { + printf("Unable to copy data into openAL buffer\n"); + + alDeleteBuffers(1, &this->buffers[index]); + return -1; + } + + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +/// \brief Attach a buffer to a source +int OpenAL::SetSourceBuffer(unsigned int sourceIndex, unsigned int bufferIndex) +{ + if (sourceIndex >= this->sources.size()) + { + std::cerr << "Invalid source index\n"; + return -1; + } + + if (bufferIndex >= this->buffers.size()) + { + std::cerr << "Invalid buffer index\n"; + return -1; + } + + // Buffer data must be set before calling this function + + // Attach buffer to source + alSourcei(this->sources[sourceIndex], AL_BUFFER, this->buffers[bufferIndex] ); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL SetSourceBuffer Error: [%d]\n" << this->error << "\n"; + return -1; + } + + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Play the source +void OpenAL::Play( unsigned int index ) +{ + // Play the source + alSourcePlay( this->sources[index] ); + + + // Wait until finished + /*ALint state; + do + { + usleep(100000); + alGetSourcei(this->sources[index], AL_SOURCE_STATE, &state); + } while ( state == AL_PLAYING); + */ + +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the listener position +int OpenAL::SetListenerPos( float x, float y, float z ) +{ + // Clear error state + alGetError(); + + alListener3f(AL_POSITION, x, y, z); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL SetListenerPos Error: [%d]\n" << this->error << "\n"; + return -1; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the listener velocity +int OpenAL::SetListenerVel( float x, float y, float z ) +{ + // Clear error state + alGetError(); + + alListener3f(AL_VELOCITY, x, y, z); + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL SetListenerVel Error: [%d]" << this->error << "\n"; + return -1; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the listener orientation +int OpenAL::SetListenerOrient( float cx, float cy, float cz, + float ux, float uy, float uz ) +{ + ALfloat orient[]={cx, cy, cz, ux, uy, uz}; + + // Clear error state + alGetError(); + + alListenerfv( AL_ORIENTATION, orient ); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL SetListenerOrientation Error: [%d]" << this->error << "\n"; + return -1; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the position of the source +int OpenAL::SetSourcePos(unsigned int index, float x, float y, float z) +{ + ALfloat p[3] = {x, y, z}; + + if (index >= this->sources.size()) + { + std::cerr << "Invalid source index[" << index <<" ]\n"; + return -1; + } + + // Clear error state + alGetError(); + + alSourcefv( this->sources[index], AL_POSITION, p); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL::SetSourcePos Error: [%d]" << this->error << "\n"; + return -1; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the position of the source +int OpenAL::SetSourceVel(unsigned int index, float x, float y, float z) +{ + ALfloat v[3] = {x, y, z}; + + if (index >= this->sources.size()) + { + std::cerr << "Invalid source index[" << index <<" ]\n"; + return -1; + } + + // Clear error state + alGetError(); + + alSourcefv( this->sources[index], AL_VELOCITY, v); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL::SetSourceVel Error: [%d]" << this->error << "\n"; + return -1; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the pitch of the source +int OpenAL::SetSourcePitch(unsigned int index, float p) +{ + if (index >= this->sources.size()) + { + std::cerr << "Invalid source index[" << index <<" ]\n"; + return -1; + } + + // clear error state + alGetError(); + + alSourcef(this->sources[index], AL_PITCH, p); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL::SetSourcePitch Error: [%d]\n" << this->error; + return -1; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the pitch of the source +int OpenAL::SetSourceGain(unsigned int index, float g) +{ + if (index >= this->sources.size()) + { + std::cerr << "Invalid source index[" << index <<" ]\n"; + return -1; + } + + // clear error state + alGetError(); + + alSourcef(this->sources[index], AL_GAIN, g); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL::SetSourceGain Error: [%d]\n" << this->error; + return -1; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set whether the source loops the audio +int OpenAL::SetSourceLoop(unsigned int index, bool state) +{ + if (index >= this->sources.size()) + { + std::cerr << "Invalid source index[" << index <<" ]\n"; + return -1; + } + + // clear error state + alGetError(); + + // Set looping state + alSourcei(this->sources[index], AL_LOOPING, state); + + if ((this->error = alGetError()) != AL_NO_ERROR) + { + std::cerr << "OpenAL::SetSourceLoop Error: [%d]\n" << this->error << "\n"; + return -1; + } + + + return 0; +} Added: code/gazebo/trunk/server/audio_video/OpenAL.hh =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.hh (rev 0) +++ code/gazebo/trunk/server/audio_video/OpenAL.hh 2009-01-16 04:32:09 UTC (rev 7275) @@ -0,0 +1,81 @@ +#ifndef OPENAL_HH +#define OPENAL_HH + +#include <AL/al.h> +#include <AL/alc.h> +#include <AL/alext.h> +#include <stdint.h> + +#include <deque> + + +class OpenAL +{ + /// \brief Constructor + public: OpenAL(); + + /// \brief Destructor + public: virtual ~OpenAL(); + + /// \brief Initialize + public: int Init(); + + /// \brief Update all the sources and the listener + public: void Update(); + + /// \brief Create a sound source + public: unsigned int CreateSource(); + + /// \brief Create an audio data buffer + public: unsigned int CreateBuffer(const std::string &audioFile); + + /// \brief Set the data + public: int SetData(unsigned int index, uint8_t *data, unsigned int dataSize, unsigned int freq); + + /// \brief Attach a buffer to a source + public: int SetSourceBuffer(unsigned int sourceIndex, unsigned int bufferIndex); + + /// \brief Play a sound + public: void Play(unsigned int source); + + /// \brief Set the listener position + public: int SetListenerPos( float x, float y, float z ); + + /// \brief Set the listener velocity + public: int SetListenerVel( float x, float y, float z ); + + /// \brief Set the listener orientation + public: int SetListenerOrient(float cx, float cy, float cz, + float ux, float uy, float uz); + + /// \brief Set the position of the source + public: int SetSourcePos(unsigned int index, float x, float y, float z); + + /// \brief Set the position of the source + public: int SetSourceVel(unsigned int index, float x, float y, float z); + + /// \brief Set the pitch of the source + public: int SetSourcePitch(unsigned int index, float p); + + /// \brief Set the pitch of the source + public: int SetSourceGain(unsigned int index, float g); + + /// \brief Set whether the source loops the audio + public: int SetSourceLoop(unsigned int index, bool state); + + private: ALCcontext *context; + private: ALCdevice *audioDevice; + + // OpenAL error code + private: ALenum error; + + // Audio sources. + private: std::deque<unsigned int> sources; + + // Audio data buffers + private: std::deque<unsigned int> buffers; + + private: ALfloat pos[3]; +}; + +#endif Added: code/gazebo/trunk/server/audio_video/SConscript =================================================================== --- code/gazebo/trunk/server/audio_video/SConscript (rev 0) +++ code/gazebo/trunk/server/audio_video/SConscript 2009-01-16 04:32:09 UTC (rev 7275) @@ -0,0 +1,41 @@ +#Import variable +Import('env sharedObjs headers') + +parseConfigs = [ + 'pkg-config --cflags --libs libavformat', + 'pkg-config --cflags --libs libavcodec', + 'pkg-config --cflags --libs openal', + 'pkg-config --cflags --libs freealut' +] + +myEnv = env.Clone() + +sources = ['AudioDecoder.cc', + 'OpenAL.cc' + ] + +headers.append( + ['server/audio_video/AudioDecoder.hh', + 'server/audio_video/OpenAL.hh', + ] ) +# +# Parse all the pacakge configurations +# +if not myEnv.GetOption('clean'): + for cfg in parseConfigs: + print "Checking for ["+cfg+"]" + try: + myEnv.ParseConfig(cfg) + print " Success" + except OSError,e: + print "Unable to parse config ["+cfg+"]" + if cfg.find("OpenAL") >= 0: + print "OpenAL not found. 3D audio is disabled." + print " http://connect.creativelabs.com/" + Exit(1) + if cfg.find("avcodec") >= 0 or cfg.find("avformat") >= 0: + print "FFMpeg not found. Audio decoding disabled." + print " http://ffmpeg.mplayerhq.hu/" + Exit(1) + +myEnv.SharedLibrary('gazeboav', sources) Modified: code/gazebo/trunk/server/rendering/UserCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/UserCamera.cc 2009-01-15 23:15:17 UTC (rev 7274) +++ code/gazebo/trunk/server/rendering/UserCamera.cc 2009-01-16 04:32:09 UTC (rev 7275) @@ -65,7 +65,7 @@ { OgreCamera::LoadCam(node); - this->SetClipDist(0.1, 100); + this->SetClipDist(0.1, 50); this->SetFOV( DTOR(60) ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-02-10 18:16:22
|
Revision: 7326 http://playerstage.svn.sourceforge.net/playerstage/?rev=7326&view=rev Author: natepak Date: 2009-02-10 18:16:15 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Fixes to openal Modified Paths: -------------- code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/audio_video/AudioDecoder.hh code/gazebo/trunk/server/audio_video/OpenAL.cc code/gazebo/trunk/server/gui/GLFrame.cc Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-02-10 08:14:48 UTC (rev 7325) +++ code/gazebo/trunk/server/World.cc 2009-02-10 18:16:15 UTC (rev 7326) @@ -125,7 +125,8 @@ } // Load OpenAL audio - OpenAL::Instance()->Load( rootNode->GetChild("openal", "audio") ); + if (rootNode->GetChild("openal","audio")) + OpenAL::Instance()->Load( rootNode->GetChild("openal", "audio") ); this->physicsEngine = new ODEPhysics(); //TODO: use exceptions here Modified: code/gazebo/trunk/server/audio_video/AudioDecoder.hh =================================================================== --- code/gazebo/trunk/server/audio_video/AudioDecoder.hh 2009-02-10 08:14:48 UTC (rev 7325) +++ code/gazebo/trunk/server/audio_video/AudioDecoder.hh 2009-02-10 18:16:15 UTC (rev 7326) @@ -2,8 +2,8 @@ #define AUDIODECODER_HH extern "C" { -#include <libavformat/avformat.h> -#include <libavcodec/avcodec.h> +#include <avformat.h> +#include <avcodec.h> } #include <string> Modified: code/gazebo/trunk/server/audio_video/OpenAL.cc =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-02-10 08:14:48 UTC (rev 7325) +++ code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-02-10 18:16:15 UTC (rev 7326) @@ -121,17 +121,17 @@ /// Finalize void OpenAL::Fini() { + if (this->audioDevice) + { + alcCloseDevice(this->audioDevice); + } + if (this->context) { this->context = alcGetCurrentContext(); alcMakeContextCurrent(NULL); alcDestroyContext(this->context); } - - if (this->audioDevice) - { - alcCloseDevice(this->audioDevice); - } } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/gui/GLFrame.cc =================================================================== --- code/gazebo/trunk/server/gui/GLFrame.cc 2009-02-10 08:14:48 UTC (rev 7325) +++ code/gazebo/trunk/server/gui/GLFrame.cc 2009-02-10 18:16:15 UTC (rev 7326) @@ -95,6 +95,8 @@ // Set default starting pose of the camera this->startPose.pos.Set(-2, 0, 2); this->startPose.rot.SetFromEuler( Vector3(0, DTOR(30), 0) ); + + this->saveFrames = false; } //////////////////////////////////////////////////////////////////////////////// @@ -107,6 +109,7 @@ // Load the frame void GLFrame::Load( XMLConfigNode *node ) { + this->saveFrames = false; if (node) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-14 01:29:31
|
Revision: 7653 http://playerstage.svn.sourceforge.net/playerstage/?rev=7653&view=rev Author: natepak Date: 2009-05-14 01:29:27 +0000 (Thu, 14 May 2009) Log Message: ----------- More updates to the cmakelists files Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt code/gazebo/trunk/server/audio_video/CMakeLists.txt code/gazebo/trunk/server/controllers/CMakeLists.txt code/gazebo/trunk/server/gui/CMakeLists.txt code/gazebo/trunk/server/physics/CMakeLists.txt code/gazebo/trunk/server/rendering/CMakeLists.txt code/gazebo/trunk/server/sensors/CMakeLists.txt code/gazebo/trunk/server/sensors/camera/CMakeLists.txt code/gazebo/trunk/server/sensors/contact/CMakeLists.txt code/gazebo/trunk/server/sensors/imu/CMakeLists.txt code/gazebo/trunk/server/sensors/ir/CMakeLists.txt code/gazebo/trunk/server/sensors/ray/CMakeLists.txt Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -19,6 +19,8 @@ sensors/imu sensors/ir sensors/ray + ${LIBAVCODEC_PATH} + ${LIBAVFORMAT_PATH} ${gazeboserver_include_dirs} ${boost_include_dirs} ${freeimage_include_dir} @@ -91,9 +93,9 @@ APPEND_TO_SERVER_HEADERS(${headers}) APPEND_TO_SERVER_SOURCES(${sources}) -#ADD_LIBRARY(gazeboserver STATIC ${gazeboserver_sources}) +ADD_LIBRARY(gazebo_server SHARED ${gazeboserver_sources}) -ADD_EXECUTABLE(gazebo-exec ${gazeboserver_sources} main.cc) +ADD_EXECUTABLE(gazebo-exec main.cc) SET_TARGET_PROPERTIES(gazebo-exec PROPERTIES OUTPUT_NAME "gazebo") LIST_TO_STRING(GAZEBO_CFLAGS "${gazeboserver_cflags}") @@ -105,19 +107,18 @@ ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}}) ENDIF (CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}) -TARGET_LINK_LIBRARIES( gazebo-exec gazebo_gui - gazebo_sensors - gazebo_physics - gazebo_rendering - gazebo_av - ${gazeboserver_link_libs} +TARGET_LINK_LIBRARIES( gazebo-exec ${gazeboserver_link_libs} ${FLTK_LIBRARIES} ${boost_libraries} ${freeimage_library} + gazebo_server gazebo ) +TARGET_LINK_LIBRARIES( gazebo_server ${gazeboserver_link_libs} ) + INSTALL (TARGETS gazebo-exec DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +INSTALL (TARGETS gazebo_server DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) INSTALL (FILES ${gazeboserver_headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gazebo COMPONENT headers) ######################################## Modified: code/gazebo/trunk/server/audio_video/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -1,11 +1,3 @@ -INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/server - ${LIBAVCODEC_PATH} - ${LIBAVFORMAT_PATH} - ${gazeboserver_include_dirs} - ${boost_include_dirs} -) - SET (sources AudioDecoder.cc OpenAL.cc ) @@ -14,6 +6,7 @@ OpenAL.hh ) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) -ADD_LIBRARY(gazebo_av STATIC ${sources}) +#ADD_LIBRARY(gazebo_av STATIC ${sources}) Modified: code/gazebo/trunk/server/controllers/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/controllers/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/controllers/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -1,21 +1,5 @@ include (${gazebo_cmake_dir}/GazeboUtils.cmake) -INCLUDE_DIRECTORIES( - . - ${CMAKE_SOURCE_DIR}/libgazebo - ${CMAKE_SOURCE_DIR}/server - ${CMAKE_SOURCE_DIR}/server/audio_video - ${CMAKE_SOURCE_DIR}/server/physics - ${CMAKE_SOURCE_DIR}/server/rendering - ${CMAKE_SOURCE_DIR}/server/sensors - ${CMAKE_SOURCE_DIR}/server/sensors/camera - ${CMAKE_SOURCE_DIR}/server/sensors/contact - ${CMAKE_SOURCE_DIR}/server/sensors/imu - ${CMAKE_SOURCE_DIR}/server/sensors/ir - ${CMAKE_SOURCE_DIR}/server/sensors/ray - ${gazeboserver_include_dirs} -) - ADD_SUBDIRECTORY(actarray) ADD_SUBDIRECTORY(bumper) ADD_SUBDIRECTORY(camera) Modified: code/gazebo/trunk/server/gui/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -1,12 +1,3 @@ -INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/libgazebo - ${CMAKE_SOURCE_DIR}/server - ${CMAKE_SOURCE_DIR}/server/rendering - ${CMAKE_SOURCE_DIR}/server/physics - ${gazeboserver_include_dirs} - ${boost_include_dirs} -) - SET (sources Gui.cc GLWindow.cc MainMenu.cc @@ -24,6 +15,7 @@ GLFrameManager.hh GLFrame.hh ) -ADD_LIBRARY(gazebo_gui STATIC ${sources}) +#ADD_LIBRARY(gazebo_gui STATIC ${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/physics/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/physics/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/physics/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -1,14 +1,5 @@ include (${gazebo_cmake_dir}/GazeboUtils.cmake) -INCLUDE_DIRECTORIES(. - ode - ${CMAKE_SOURCE_DIR}/libgazebo - ${CMAKE_SOURCE_DIR}/server - ${CMAKE_SOURCE_DIR}/server/rendering - ${CMAKE_SOURCE_DIR}/server/sensors - ${gazeboserver_include_dirs} - ${boost_include_dirs} -) SET (sources BallJoint.cc Body.cc @@ -52,5 +43,6 @@ ode/ODEPhysics.hh ) -ADD_LIBRARY(gazebo_physics STATIC ${sources}) +#ADD_LIBRARY(gazebo_physics STATIC ${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/rendering/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/rendering/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/rendering/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -1,11 +1,5 @@ include (${gazebo_cmake_dir}/GazeboUtils.cmake) -INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/server - ${CMAKE_SOURCE_DIR}/server/gui - ${gazeboserver_include_dirs} - ${boost_include_dirs} -) SET (sources OgreMovableText.cc OgreCreator.cc @@ -41,5 +35,6 @@ OgreHeightmap.hh ) -ADD_LIBRARY(gazebo_rendering ${sources}) +#ADD_LIBRARY(gazebo_rendering ${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/sensors/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/sensors/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/sensors/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -1,22 +1,5 @@ include (${gazebo_cmake_dir}/GazeboUtils.cmake) -INCLUDE_DIRECTORIES ( - . - ${CMAKE_SOURCE_DIR}/libgazebo - ${CMAKE_SOURCE_DIR}/server - ${CMAKE_SOURCE_DIR}/server/controllers - ${CMAKE_SOURCE_DIR}/server/physics - ${CMAKE_SOURCE_DIR}/server/physics/ode - ${CMAKE_SOURCE_DIR}/server/rendering - ${gazeboserver_include_dirs} - ${boost_include_dirs} -) - -LINK_DIRECTORIES( - - ${CMAKE_SOURCE_DIR}/libgazebo - ) - ADD_SUBDIRECTORY(camera) ADD_SUBDIRECTORY(contact) ADD_SUBDIRECTORY(imu) @@ -31,5 +14,6 @@ SensorFactory.hh ) -ADD_LIBRARY(gazebo_sensors STATIC ${gazebosensor_sources} ${sources}) +#ADD_LIBRARY(gazebo_sensors STATIC ${gazebosensor_sources} ${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/sensors/camera/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/sensors/camera/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/sensors/camera/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -9,5 +9,5 @@ ) -APPEND_TO_SENSOR_SOURCES(${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/sensors/contact/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/sensors/contact/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/sensors/contact/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -3,5 +3,5 @@ set (sources ContactSensor.cc) set (headers ContactSensor.hh) -APPEND_TO_SENSOR_SOURCES(${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/sensors/imu/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/sensors/imu/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/sensors/imu/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -3,5 +3,5 @@ set (sources ImuSensor.cc) set (headers ImuSensor.hh) -APPEND_TO_SENSOR_SOURCES(${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/sensors/ir/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/sensors/ir/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/sensors/ir/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -3,5 +3,5 @@ set (sources IRSensor.cc) set (headers IRSensor.hh) -APPEND_TO_SENSOR_SOURCES(${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) Modified: code/gazebo/trunk/server/sensors/ray/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/sensors/ray/CMakeLists.txt 2009-05-14 00:34:36 UTC (rev 7652) +++ code/gazebo/trunk/server/sensors/ray/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) @@ -3,5 +3,5 @@ set (sources RaySensor.cc) set (headers RaySensor.hh) -APPEND_TO_SENSOR_SOURCES(${sources}) +APPEND_TO_SERVER_SOURCES(${sources}) APPEND_TO_SERVER_HEADERS(${headers}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-14 02:14:29
|
Revision: 7654 http://playerstage.svn.sourceforge.net/playerstage/?rev=7654&view=rev Author: natepak Date: 2009-05-14 01:42:00 +0000 (Thu, 14 May 2009) Log Message: ----------- Removed gui stuff from libgazebo_server Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt code/gazebo/trunk/server/gui/CMakeLists.txt Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 01:42:00 UTC (rev 7654) @@ -107,7 +107,8 @@ ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}}) ENDIF (CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}) -TARGET_LINK_LIBRARIES( gazebo-exec ${gazeboserver_link_libs} +TARGET_LINK_LIBRARIES( gazebo-exec gazebo_gui + ${gazeboserver_link_libs} ${FLTK_LIBRARIES} ${boost_libraries} ${freeimage_library} Modified: code/gazebo/trunk/server/gui/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 01:29:27 UTC (rev 7653) +++ code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 01:42:00 UTC (rev 7654) @@ -15,7 +15,7 @@ GLFrameManager.hh GLFrame.hh ) -#ADD_LIBRARY(gazebo_gui STATIC ${sources}) +ADD_LIBRARY(gazebo_gui STATIC ${sources}) -APPEND_TO_SERVER_SOURCES(${sources}) -APPEND_TO_SERVER_HEADERS(${headers}) +#APPEND_TO_SERVER_SOURCES(${sources}) +#APPEND_TO_SERVER_HEADERS(${headers}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-14 04:32:12
|
Revision: 7656 http://playerstage.svn.sourceforge.net/playerstage/?rev=7656&view=rev Author: natepak Date: 2009-05-14 04:32:05 +0000 (Thu, 14 May 2009) Log Message: ----------- More changes to the cmake files Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt code/gazebo/trunk/server/physics/Body.cc code/gazebo/trunk/server/physics/Body.hh code/gazebo/trunk/server/physics/ode/ODEPhysics.cc code/gazebo/trunk/server/physics/ode/ODEPhysics.hh Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 03:14:25 UTC (rev 7655) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 04:32:05 UTC (rev 7656) @@ -61,7 +61,6 @@ GazeboError.cc GazeboMessage.cc Model.cc - Simulator.cc Angle.cc Param.cc GraphicsIfaceHandler.cc @@ -75,7 +74,6 @@ Model.hh Pose3d.hh Quatern.hh - Simulator.hh SingletonT.hh StaticPluginRegister.hh Time.hh @@ -95,7 +93,7 @@ ADD_LIBRARY(gazebo_server SHARED ${gazeboserver_sources}) -ADD_EXECUTABLE(gazebo-exec main.cc) +ADD_EXECUTABLE(gazebo-exec Simulator.cc main.cc) SET_TARGET_PROPERTIES(gazebo-exec PROPERTIES OUTPUT_NAME "gazebo") LIST_TO_STRING(GAZEBO_CFLAGS "${gazeboserver_cflags}") Modified: code/gazebo/trunk/server/physics/Body.cc =================================================================== --- code/gazebo/trunk/server/physics/Body.cc 2009-05-14 03:14:25 UTC (rev 7655) +++ code/gazebo/trunk/server/physics/Body.cc 2009-05-14 04:32:05 UTC (rev 7656) @@ -62,15 +62,17 @@ //////////////////////////////////////////////////////////////////////////////// // Constructor -Body::Body(Entity *parent, dWorldID worldId) +Body::Body(Entity *parent) : Entity(parent) { this->physicsEngine = World::Instance()->GetPhysicsEngine(); if ( !this->IsStatic() ) { - this->bodyId = dBodyCreate(worldId); + ODEPhysics *odePhysics = (ODEPhysics*)(this->physicsEngine); + this->bodyId = dBodyCreate(odePhysics->GetWorldId()); + dMassSetZero( &this->mass ); } else @@ -164,7 +166,7 @@ { //std::cout << "setting self collide: " << this->nameP->GetValue() << std::endl; ODEPhysics* pe = dynamic_cast<ODEPhysics*>(World::Instance()->GetPhysicsEngine()); - this->spaceId = dSimpleSpaceCreate( pe->spaceId); + this->spaceId = dSimpleSpaceCreate( pe->GetSpaceId()); } // option to enter full mass matrix Modified: code/gazebo/trunk/server/physics/Body.hh =================================================================== --- code/gazebo/trunk/server/physics/Body.hh 2009-05-14 03:14:25 UTC (rev 7655) +++ code/gazebo/trunk/server/physics/Body.hh 2009-05-14 04:32:05 UTC (rev 7656) @@ -51,7 +51,7 @@ class Body : public Entity { /// \brief Constructor - public: Body(Entity *parent, dWorldID worldId); + public: Body(Entity *parent); /// \brief Destructor public: virtual ~Body(); Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-05-14 03:14:25 UTC (rev 7655) +++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-05-14 04:32:05 UTC (rev 7656) @@ -255,10 +255,17 @@ // Create a new body Body *ODEPhysics::CreateBody(Entity *parent) { - return new Body(parent, this->worldId); + return new Body(parent); } //////////////////////////////////////////////////////////////////////////////// +// Get the world id +dWorldID ODEPhysics::GetWorldId() +{ + return this->worldId; +} + +//////////////////////////////////////////////////////////////////////////////// // Create a new joint Joint *ODEPhysics::CreateJoint(Joint::Type type) { Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.hh =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEPhysics.hh 2009-05-14 03:14:25 UTC (rev 7655) +++ code/gazebo/trunk/server/physics/ode/ODEPhysics.hh 2009-05-14 04:32:05 UTC (rev 7656) @@ -125,6 +125,9 @@ /// \brief Return the space id public: dSpaceID GetSpaceId() const; + /// \brief Get the world id + public: dWorldID GetWorldId(); + /// \brief Do collision detection private: static void CollisionCallback( void *data, dGeomID o1, dGeomID o2); @@ -132,7 +135,7 @@ private: dWorldID worldId; /// \brief Top-level space for all sub-spaces/geoms - public: dSpaceID spaceId; + private: dSpaceID spaceId; /// \brief Collision attributes private: dJointGroupID contactGroup; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2009-05-14 14:22:12
|
Revision: 7660 http://playerstage.svn.sourceforge.net/playerstage/?rev=7660&view=rev Author: robotos Date: 2009-05-14 13:50:38 +0000 (Thu, 14 May 2009) Log Message: ----------- we are not using integers as error detectors but exceptions so change functions to return void Modified Paths: -------------- code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/Model.hh code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/Simulator.hh code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/World.hh code/gazebo/trunk/server/XMLConfig.cc code/gazebo/trunk/server/XMLConfig.hh code/gazebo/trunk/server/controllers/imu/Generic_Imu.cc code/gazebo/trunk/server/gui/Gui.cc code/gazebo/trunk/server/main.cc Modified: code/gazebo/trunk/server/Model.cc =================================================================== --- code/gazebo/trunk/server/Model.cc 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/Model.cc 2009-05-14 13:50:38 UTC (rev 7660) @@ -151,7 +151,7 @@ //////////////////////////////////////////////////////////////////////////////// // Load the model -int Model::Load(XMLConfigNode *node, bool removeDuplicate) +void Model::Load(XMLConfigNode *node, bool removeDuplicate) { XMLConfigNode *childNode; Pose3d pose; @@ -249,7 +249,6 @@ this->graphicsHandler = new GraphicsIfaceHandler(); this->graphicsHandler->Load(this->GetName(), this); - return 0; // Get the name of the python module /*this->pName.reset(PyString_FromString(node->GetString("python","",0).c_str())); @@ -363,7 +362,7 @@ //////////////////////////////////////////////////////////////////////////////// // Initialize the model -int Model::Init() +void Model::Init() { std::map<std::string, Body* >::iterator biter; std::map<std::string, Controller* >::iterator contIter; @@ -385,12 +384,12 @@ this->sceneNode->attachObject(this->mtext); */ - return this->InitChild(); + this->InitChild(); } //////////////////////////////////////////////////////////////////////////////// // Update the model -int Model::Update() +void Model::Update() { std::map<std::string, Body* >::iterator bodyIter; std::map<std::string, Controller* >::iterator contIter; @@ -466,21 +465,21 @@ << tmpT5-tmpT4 << ")" << std::endl; std::cout << " Models::Update() (" << this->GetName() << ") Total DT (" << tmpT5-tmpT1 << ")" << std::endl; - return update_error; + gzthrow( update_error ); #else - return this->UpdateChild(); + this->UpdateChild(); #endif - return this->UpdateChild(); + this->UpdateChild(); } //////////////////////////////////////////////////////////////////////////////// // Finalize the model -int Model::Fini() +void Model::Fini() { std::map<std::string, Body* >::iterator biter; std::map<std::string, Controller* >::iterator contIter; @@ -502,7 +501,7 @@ this->graphicsHandler = NULL; } - return this->FiniChild(); + this->FiniChild(); } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/Model.hh =================================================================== --- code/gazebo/trunk/server/Model.hh 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/Model.hh 2009-05-14 13:50:38 UTC (rev 7660) @@ -71,32 +71,32 @@ /// \brief Load the model /// \param removeDuplicate Remove existing model of same name - public: int Load(XMLConfigNode *node, bool removeDuplicate); + public: void Load(XMLConfigNode *node, bool removeDuplicate); /// \brief Save the model public: void Save(std::string &prefix, std::ostream &stream); /// \brief Initialize the model - public: int Init(); + public: void Init(); /// \brief Update the model /// \param params Update parameters - public: int Update(); + public: void Update(); /// \brief Finalize the model - public: int Fini(); + public: void Fini(); /// \brief Reset the model public: void Reset(); /// \brief Initialize the child model - protected: virtual int InitChild() {return 0;} + protected: virtual void InitChild() {} /// \brief Update the child model - protected: virtual int UpdateChild() {return 0;} + protected: virtual void UpdateChild() {} /// \brief Finilaize thie child model - protected: virtual int FiniChild() {return 0;} + protected: virtual void FiniChild() {} /// \brief Get the type of the model public: const std::string &GetType() const; Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/Simulator.cc 2009-05-14 13:50:38 UTC (rev 7660) @@ -245,15 +245,20 @@ //////////////////////////////////////////////////////////////////////////////// /// Initialize the simulation -int Simulator::Init() +void Simulator::Init() { this->startTime = this->GetWallTime(); //Initialize the world - if (gazebo::World::Instance()->Init() != 0) - return -1; + try + { + gazebo::World::Instance()->Init(); + } + catch (GazeboError e) + { + gzthrow("Failed to Initialize the World\n" << e); + } - return 0; } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/Simulator.hh =================================================================== --- code/gazebo/trunk/server/Simulator.hh 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/Simulator.hh 2009-05-14 13:50:38 UTC (rev 7660) @@ -77,7 +77,7 @@ public: void Save(const std::string& filename=std::string()); /// \brief Initialize the simulation - public: int Init( ); + public: void Init( ); /// \brief Finalize the simulation public: void Fini( ); Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/World.cc 2009-05-14 13:50:38 UTC (rev 7660) @@ -187,7 +187,7 @@ //////////////////////////////////////////////////////////////////////////////// // Initialize the world -int World::Init() +void World::Init() { std::vector< Model* >::iterator miter; @@ -212,12 +212,11 @@ this->graphics->Init(); - return 0; } //////////////////////////////////////////////////////////////////////////////// // Update the world -int World::Update() +void World::Update() { if (this->simPauseTime > 0) @@ -270,7 +269,6 @@ std::cout << " World::Update() Physics engine DT(" << tmpT4-tmpT2 << ")" << std::endl; #endif - return 0; } //////////////////////////////////////////////////////////////////////////////// @@ -282,7 +280,7 @@ //////////////////////////////////////////////////////////////////////////////// // Finilize the world -int World::Fini() +void World::Fini() { std::vector< Model* >::iterator miter; @@ -303,7 +301,7 @@ this->simIface->Destroy(); } catch (std::string e) - { + { gzmsg(-1) << "Problem destroying simIface[" << e << "]\n"; } @@ -320,8 +318,6 @@ #ifdef HAVE_OPENAL OpenAL::Instance()->Fini(); #endif - - return 0; } //////////////////////////////////////////////////////////////////////////////// @@ -341,7 +337,7 @@ /////////////////////////////////////////////////////////////////////////////// // Load a model -int World::LoadEntities(XMLConfigNode *node, Model *parent, bool removeDuplicate) +void World::LoadEntities(XMLConfigNode *node, Model *parent, bool removeDuplicate) { XMLConfigNode *cnode; Model *model = NULL; @@ -358,12 +354,9 @@ // Load children for (cnode = node->GetChild(); cnode != NULL; cnode = cnode->GetNext()) { - if (this->LoadEntities( cnode, model, removeDuplicate ) != 0) - return -1; + this->LoadEntities( cnode, model, removeDuplicate ); } - - return 0; } //////////////////////////////////////////////////////////////////////////////// @@ -393,8 +386,7 @@ //model->SetParent(parent); // Load the model - if (model->Load( node, removeDuplicate ) != 0) - return NULL; + model->Load( node, removeDuplicate ); // Set the model's pose (relative to parent) this->SetModelPose(model, model->GetInitPose()); Modified: code/gazebo/trunk/server/World.hh =================================================================== --- code/gazebo/trunk/server/World.hh 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/World.hh 2009-05-14 13:50:38 UTC (rev 7660) @@ -74,16 +74,13 @@ public: void Save(std::string &prefix, std::ostream &stream); /// Initialize the world - /// \return 0 on success - public: int Init(); + public: void Init(); /// Update the world - /// \return 0 on success - public: int Update(); + public: void Update(); /// Finilize the world - /// \return 0 on success - public: int Fini(); + public: void Fini(); /// Retun the libgazebo server /// \return Pointer the the libgazebo server @@ -117,8 +114,7 @@ /// \param node XMLConfg node pointer /// \param parent Parent of the model to load /// \param removeDuplicate Remove existing model of same name - /// \return 0 on success - public: int LoadEntities(XMLConfigNode *node, Model *parent, bool removeDuplicate); + public: void LoadEntities(XMLConfigNode *node, Model *parent, bool removeDuplicate); /// \brief Delete an entity by name /// \param name The name of the entity to delete Modified: code/gazebo/trunk/server/XMLConfig.cc =================================================================== --- code/gazebo/trunk/server/XMLConfig.cc 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/XMLConfig.cc 2009-05-14 13:50:38 UTC (rev 7660) @@ -88,14 +88,17 @@ //////////////////////////////////////////////////////////////////////////// // Save config back into file -int XMLConfig::Save(const std::string &filename ) +void XMLConfig::Save(const std::string &filename ) { int result=0; if (filename == std::string()) result=xmlSaveFileEnc(this->filename.c_str(), this->xmlDoc, "UTF-8"); else result=xmlSaveFileEnc(filename.c_str(), this->xmlDoc, "UTF-8"); - return result; + if ( result != 0) + { + gzthrow( "Error saving the XML file back to the disk " ); + } } Modified: code/gazebo/trunk/server/XMLConfig.hh =================================================================== --- code/gazebo/trunk/server/XMLConfig.hh 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/XMLConfig.hh 2009-05-14 13:50:38 UTC (rev 7660) @@ -63,7 +63,7 @@ /// \brief Save config back into file /// Set filename to NULL to save back into the original file - public: int Save(const std::string &filename ); + public: void Save(const std::string &filename ); /// \brief Get the root node public: XMLConfigNode *GetRootNode() const; Modified: code/gazebo/trunk/server/controllers/imu/Generic_Imu.cc =================================================================== --- code/gazebo/trunk/server/controllers/imu/Generic_Imu.cc 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/controllers/imu/Generic_Imu.cc 2009-05-14 13:50:38 UTC (rev 7660) @@ -30,7 +30,6 @@ #include "Global.hh" #include "XMLConfig.hh" -#include "Model.hh" #include "World.hh" #include "gazebo.h" #include "GazeboError.hh" Modified: code/gazebo/trunk/server/gui/Gui.cc =================================================================== --- code/gazebo/trunk/server/gui/Gui.cc 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/gui/Gui.cc 2009-05-14 13:50:38 UTC (rev 7660) @@ -97,6 +97,9 @@ OgreCreator::Instance()->CreateWindow(this, 1, 1); this->hasFocus = true; + + Fl::check(); + Fl::wait(0.3); } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/main.cc =================================================================== --- code/gazebo/trunk/server/main.cc 2009-05-14 13:35:55 UTC (rev 7659) +++ code/gazebo/trunk/server/main.cc 2009-05-14 13:50:38 UTC (rev 7660) @@ -297,7 +297,7 @@ { std::cerr << "Error Loading Gazebo" << std::endl; std::cerr << e << std::endl; - gazebo::Simulator::Instance()->Fini(); + gazebo::Simulator::Instance()->Close(); 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-14 15:54:38
|
Revision: 7661 http://playerstage.svn.sourceforge.net/playerstage/?rev=7661&view=rev Author: natepak Date: 2009-05-14 15:54:32 +0000 (Thu, 14 May 2009) Log Message: ----------- Added GuiAPI Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/Simulator.hh code/gazebo/trunk/server/gui/CMakeLists.txt code/gazebo/trunk/server/physics/MapGeom.cc Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 13:50:38 UTC (rev 7660) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 15:54:32 UTC (rev 7661) @@ -28,11 +28,10 @@ LINK_DIRECTORIES( ${CMAKE_BINARY_DIR}/libgazebo + ${CMAKE_BINARY_DIR}/server/gui ${boost_library_dirs} ${freeimage_library_dir} ${gazeboserver_link_dirs} - sensors - controllers ) ######################################## @@ -64,6 +63,8 @@ Angle.cc Param.cc GraphicsIfaceHandler.cc + GuiAPI.cc + Simulator.cc ) SET (headers Common.hh @@ -86,6 +87,8 @@ Angle.hh Param.hh GraphicsIfaceHandler.hh + GuiAPI.hh + Simulator.hh ) APPEND_TO_SERVER_HEADERS(${headers}) @@ -93,7 +96,7 @@ ADD_LIBRARY(gazebo_server SHARED ${gazeboserver_sources}) -ADD_EXECUTABLE(gazebo-exec Simulator.cc main.cc) +ADD_EXECUTABLE(gazebo-exec main.cc) SET_TARGET_PROPERTIES(gazebo-exec PROPERTIES OUTPUT_NAME "gazebo") LIST_TO_STRING(GAZEBO_CFLAGS "${gazeboserver_cflags}") @@ -105,16 +108,17 @@ ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}}) ENDIF (CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}) -TARGET_LINK_LIBRARIES( gazebo-exec gazebo_gui +TARGET_LINK_LIBRARIES( gazebo-exec ${gazeboserver_link_libs} ${FLTK_LIBRARIES} ${boost_libraries} ${freeimage_library} gazebo_server + gazebo_gui gazebo ) -TARGET_LINK_LIBRARIES( gazebo_server ${gazeboserver_link_libs} ) +TARGET_LINK_LIBRARIES( gazebo_server ${ODE_LIBRARIES} gazebo) INSTALL (TARGETS gazebo-exec DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) INSTALL (TARGETS gazebo_server DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-05-14 13:50:38 UTC (rev 7660) +++ code/gazebo/trunk/server/Simulator.cc 2009-05-14 15:54:32 UTC (rev 7661) @@ -36,9 +36,8 @@ #include "Entity.hh" #include "OgreVisual.hh" #include "World.hh" -#include "Gui.hh" #include "XMLConfig.hh" -#include "Gui.hh" +#include "GuiAPI.hh" #include "GazeboConfig.hh" #include "gazebo.h" #include "PhysicsEngine.hh" @@ -191,12 +190,11 @@ int x = childNode->GetTupleInt("pos",0,0); int y = childNode->GetTupleInt("pos",1,0); - //gzmsg(1) << "Creating GUI: Pos[" << x << " " << y << "] Size[" << width << " " << height << "]\n"; + //gzmsg(1) << "Creating GUI: Pos[" << x << " " << y + // << "] Size[" << width << " " << height << "]\n"; // Create the GUI - this->gui = new Gui(x, y, width, height, "Gazebo"); - Fl::check(); - Fl::wait(0.3); + this->gui = new GuiAPI(x, y, width, height, "Gazebo"); this->gui->Load(childNode); } } @@ -381,13 +379,6 @@ } //////////////////////////////////////////////////////////////////////////////// -/// Gets our current GUI interface -Gui *Simulator::GetUI() const -{ - return this->gui; -} - -//////////////////////////////////////////////////////////////////////////////// /// Gets local configuration for this computer GazeboConfig *Simulator::GetGazeboConfig() const { Modified: code/gazebo/trunk/server/Simulator.hh =================================================================== --- code/gazebo/trunk/server/Simulator.hh 2009-05-14 13:50:38 UTC (rev 7660) +++ code/gazebo/trunk/server/Simulator.hh 2009-05-14 15:54:32 UTC (rev 7661) @@ -43,7 +43,7 @@ /// \{ // Forward declarations - class Gui; + class GuiAPI; class Server; class SimulationIface; class XMLConfig; @@ -85,9 +85,6 @@ /// \brief Main simulation loop, when this loop ends the simulation finish public: void MainLoop(); - /// \brief Gets our current GUI interface - public: Gui *GetUI() const; - /// \brief Gets the local configuration for this computer public: GazeboConfig *GetGazeboConfig() const; @@ -191,11 +188,10 @@ private: XMLConfig *xmlFile; /// Pointer to the selected Gui - private: Gui *gui; + private: GuiAPI *gui; private: OgreAdaptor *renderEngine; - /// Pointer to the selected Gui private: GazeboConfig *gazeboConfig; /// Flag to know if we have a simulation loaded Modified: code/gazebo/trunk/server/gui/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 13:50:38 UTC (rev 7660) +++ code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 15:54:32 UTC (rev 7661) @@ -15,7 +15,11 @@ GLFrameManager.hh GLFrame.hh ) + ADD_LIBRARY(gazebo_gui STATIC ${sources}) +ADD_LIBRARY(gazebo_gui-shared SHARED ${sources}) -#APPEND_TO_SERVER_SOURCES(${sources}) -#APPEND_TO_SERVER_HEADERS(${headers}) +#SET_TARGET_PROPERTIES(gazebo_gui-static 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) Modified: code/gazebo/trunk/server/physics/MapGeom.cc =================================================================== --- code/gazebo/trunk/server/physics/MapGeom.cc 2009-05-14 13:50:38 UTC (rev 7660) +++ code/gazebo/trunk/server/physics/MapGeom.cc 2009-05-14 15:54:32 UTC (rev 7661) @@ -326,7 +326,7 @@ //int diff = labs(freePixels - occPixels); - if (node->width*node->height > this->granularityP->GetValue()) + if ((int)(node->width*node->height) > (**this->granularityP)) { float newX, newY; float newW, newH; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-14 15:55:27
|
Revision: 7662 http://playerstage.svn.sourceforge.net/playerstage/?rev=7662&view=rev Author: natepak Date: 2009-05-14 15:55:25 +0000 (Thu, 14 May 2009) Log Message: ----------- Added GuiAPI files Added Paths: ----------- code/gazebo/trunk/server/GuiAPI.cc code/gazebo/trunk/server/GuiAPI.hh code/gazebo/trunk/server/physics/ODEBody.cc code/gazebo/trunk/server/physics/ODEBody.hh Added: code/gazebo/trunk/server/GuiAPI.cc =================================================================== --- code/gazebo/trunk/server/GuiAPI.cc (rev 0) +++ code/gazebo/trunk/server/GuiAPI.cc 2009-05-14 15:55:25 UTC (rev 7662) @@ -0,0 +1,47 @@ +#include "Gui.hh" +#include "XMLConfig.hh" +#include "GuiAPI.hh" + +using namespace gazebo; + +//////////////////////////////////////////////////////////////////////////////// +// Constructor +GuiAPI::GuiAPI(int x, int y, int w, int h, const std::string &t) +{ + this->gui = new Gui(x,y,w,h,t); +} + +//////////////////////////////////////////////////////////////////////////////// +// Destructor +GuiAPI::~GuiAPI() +{ + delete this->gui; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Load the gui +void GuiAPI::Load(XMLConfigNode *node) +{ + this->gui->Load(node); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Save the gui params in xml format +void GuiAPI::Save(std::string &prefix, std::ostream &stream) +{ + this->gui->Save(prefix, stream); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Initalize the gui +void GuiAPI::Init() +{ + this->gui->Init(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Update +void GuiAPI::Update() +{ + this->gui->Update(); +} Added: code/gazebo/trunk/server/GuiAPI.hh =================================================================== --- code/gazebo/trunk/server/GuiAPI.hh (rev 0) +++ code/gazebo/trunk/server/GuiAPI.hh 2009-05-14 15:55:25 UTC (rev 7662) @@ -0,0 +1,58 @@ +/* + * 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: Base gui + * Author: Nate Koenig + * Date: 14 May 2009 + * SVN: $Id:$ + */ + +#include <string> +#include <iostream> + +namespace gazebo +{ + class XMLConfigNode; + class Gui; + + class GuiAPI + { + /// \brief Constructor + public: GuiAPI(int x, int y, int w, int h, const std::string &t); + + /// \brief Destructor + public: virtual ~GuiAPI(); + + /// \brief Load the gui + public: void Load(XMLConfigNode *node); + + /// \brief Save the gui params in xml format + public: void Save(std::string &prefix, std::ostream &stream); + + /// \brief Initalize the gui + public: void Init(); + + /// \brief Update the gui + public: void Update(); + + private: Gui *gui; + }; + +} Added: code/gazebo/trunk/server/physics/ODEBody.cc =================================================================== --- code/gazebo/trunk/server/physics/ODEBody.cc (rev 0) +++ code/gazebo/trunk/server/physics/ODEBody.cc 2009-05-14 15:55:25 UTC (rev 7662) @@ -0,0 +1,696 @@ +/* + * 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: Body class + * Author: Nate Koenig + * Date: 13 Feb 2006 + * SVN: $Id: Body.cc 7640 2009-05-13 02:06:08Z natepak $ + */ + +#include <sstream> + +#include "XMLConfig.hh" +#include "GazeboMessage.hh" + +#include "Quatern.hh" +#include "GazeboError.hh" +#include "ODEPhysics.hh" +#include "PhysicsEngine.hh" + +#include "Body.hh" + +using namespace gazebo; + +//////////////////////////////////////////////////////////////////////////////// +// Constructor +ODEBody::ODEBody(Entity *parent) + : Body(parent) +{ + ODEPhysics *odePhysics = dynamic_cast<ODEPhysics*>(this->physicsEngine); + if (odePhysics == NULL) + gzthrow("Not using the ode physics engine"); + + if ( !this->IsStatic() ) + { + this->bodyId = dBodyCreate(odePhyics->GetWorldId()); + + dMassSetZero( &this->mass ); + } + else + { + this->bodyId = NULL; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// Destructor +ODEBody::~ODEBody() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +// Load the body based on an XMLConfig node +void ODEBody::LoadChild(XMLConfigNode *node) +{ + // before loading child geometry, we have to figure out of selfCollide is true + // and modify parent class Entity so this body has its own spaceId + if (**this->selfCollideP) + { + //std::cout << "setting self collide: " << this->nameP->GetValue() << std::endl; + ODEPhysics* pe = dynamic_cast<ODEPhysics*>(World::Instance()->GetPhysicsEngine()); + this->spaceId = dSimpleSpaceCreate( pe->spaceId); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Init the ODE body +void ODEBody::InitChild() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +/// Finalize the body +void ODEBody::FiniChild() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +// Update the body +void ODEBody::UpdateChild() +{ + if(this->GetId()) + { + this->physicsEngine->LockMutex(); + + force = this->dampingFactorP->GetValue() * this->mass.mass; + vel = this->GetLinearVel(); + dBodyAddForce(this->GetId(), -((vel.x * fabs(vel.x)) * force), + -((vel.y * fabs(vel.y)) * force), + -((vel.z * fabs(vel.z)) * force)); + + avel = this->GetAngularVel(); + dBodyAddTorque(this->GetId(), -avel.x * force, -avel.y * force, + -avel.z * force); + + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Set whether gravity affects this body +void ODEBody::SetGravityMode(bool mode) +{ + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + dBodySetGravityMode(this->bodyId, mode ? 1: 0); + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Attach a geom to this body +void ODEBody::AttachGeomChild( Geom *geom ) +{ + if ( this->bodyId ) + { + if (geom->IsPlaceable()) + { + this->physicsEngine->LockMutex(); + + if (geom->GetTransId()) + dGeomSetBody(geom->GetTransId(), this->bodyId); + else if (geom->GetGeomId()) + dGeomSetBody(geom->GetGeomId(), this->bodyId); + + this->physicsEngine->UnlockMutex(); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the position of the body +void ODEBody::SetPosition(const Vector3 &pos) +{ + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + dBodySetPosition(this->bodyId, pos.x, pos.y, pos.z); + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the rotation of the body +void ODEBody::SetRotation(const Quatern &rot) +{ + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + + dQuaternion q; + q[0] = rot.u; + q[1] = rot.x; + q[2] = rot.y; + q[3] = rot.z; + + // Set the rotation of the ODE body + dBodySetQuaternion(this->bodyId, q); + + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Return the position of the body. in global CS +Vector3 ODEBody::GetPosition() const +{ + Vector3 pos; + + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + const dReal *p; + + p = dBodyGetPosition(this->bodyId); + + pos.x = p[0]; + pos.y = p[1]; + pos.z = p[2]; + + // check for NaN + if (std::isnan(pos.x) || std::isnan(pos.y) || std::isnan(pos.z)) + { + std::cout << "Your simulation has exploded, position of body(" << this->GetName() << ") has NaN(" << pos << ")" << std::endl; + //pos = this->pose.pos; + assert(0); + } + + this->physicsEngine->UnlockMutex(); + } + else + { + pos = this->staticPose.pos; + } + + return pos; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Return the rotation +Quatern ODEBody::GetRotation() const +{ + Quatern rot; + + if (this->bodyId) + { + const dReal *r; + + this->physicsEngine->LockMutex(); + r = dBodyGetQuaternion(this->bodyId); + this->physicsEngine->UnlockMutex(); + + rot.u = r[0]; + rot.x = r[1]; + rot.y = r[2]; + rot.z = r[3]; + + // check for NaN + if (std::isnan(rot.u) || std::isnan(rot.x) || std::isnan(rot.y) || std::isnan(rot.z)) + { + std::cout << "Your simulation has exploded, rotation of body(" << this->GetName() << ") has NaN(" << rot << ")" << std::endl; + //rot = this->pose.rot; + assert(0); + } + } + else + { + rot = this->staticPose.rot; + } + + return rot; +} + +//////////////////////////////////////////////////////////////////////////////// +// Return the position of the body. in global CS +Vector3 ODEBody::GetPositionRate() const +{ + Vector3 vel; + + if (this->bodyId) + { + const dReal *v; + + this->physicsEngine->LockMutex(); + v = dBodyGetLinearVel(this->bodyId); + this->physicsEngine->UnlockMutex(); + + vel.x = v[0]; + vel.y = v[1]; + vel.z = v[2]; + } + else + { + vel.x = 0; + vel.y = 0; + vel.z = 0; + } + + return vel; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Return the rotation +Quatern ODEBody::GetRotationRate() const +{ + Quatern velQ; + Vector3 vel; + + if (this->bodyId) + { + const dReal *v; + + this->physicsEngine->LockMutex(); + v = dBodyGetAngularVel(this->bodyId); + this->physicsEngine->UnlockMutex(); + + vel.x = v[0]; + vel.y = v[1]; + vel.z = v[2]; + + velQ.SetFromEuler(vel); + } + else + { + vel.x = 0; + vel.y = 0; + vel.z = 0; + velQ.SetFromEuler(vel); + } + + return velQ; +} + +//////////////////////////////////////////////////////////////////////////////// +// Return the rotation +Vector3 ODEBody::GetEulerRate() const +{ + Vector3 vel; + + if (this->bodyId) + { + const dReal *v; + + this->physicsEngine->LockMutex(); + v = dBodyGetAngularVel(this->bodyId); + this->physicsEngine->UnlockMutex(); + vel.x = v[0]; + vel.y = v[1]; + vel.z = v[2]; + + } + else + { + vel.x = 0; + vel.y = 0; + vel.z = 0; + } + + return vel; +} + +//////////////////////////////////////////////////////////////////////////////// +// Return the ID of this body +dBodyID ODEBody::GetId() const +{ + return this->bodyId; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Set whether this body is enabled +void ODEBody::SetEnabled(bool enable) const +{ + if (!this->bodyId) + return; + + this->physicsEngine->LockMutex(); + + if (enable) + dBodyEnable(this->bodyId); + else + dBodyDisable(this->bodyId); + + this->physicsEngine->UnlockMutex(); +} + +///////////////////////////////////////////////////////////////////// +// Update the CoM and mass matrix +/* + What's going on here? In ODE the CoM of a body corresponds to the + origin of the body-fixed coordinate system. In Gazebo, however, we + want to have arbitrary body coordinate systems (i.e., CoM may be + displaced from the body-fixed cs). To get around this limitation in + ODE, we have an extra fudge-factor (comPose), describing the pose of + the CoM relative to Gazebo's body-fixed cs. When using low-level + ODE functions, one must use apply this factor appropriately. + + The UpdateCoM() function is used to compute this offset, based on + the mass distribution of attached geoms. This function also shifts + the ODE-pose of the geoms, to keep everything in the same place in the + Gazebo cs. Simple, neh? + + TODO: messes up if you call it twice; should fix. +*/ +void ODEBody::UpdateCoM() +{ + if (!this->bodyId) + return; + + // user can specify custom mass matrix or alternatively, UpdateCoM will calculate CoM for + // combined mass of all children geometries. + if (this->customMassMatrix) + { + // Old pose for the CoM + Pose3d oldPose, newPose, tmpPose; + + // oldPose is the last comPose + // newPose is mass CoM + oldPose = this->comPose; + + //std::cout << " in UpdateCoM, name: " << this->GetName() << std::endl; + //std::cout << " in UpdateCoM, comPose or oldPose: " << this->comPose << std::endl; + + // New pose for the CoM + newPose.pos.x = this->cx; + newPose.pos.y = this->cy; + newPose.pos.z = this->cz; + + std::map< std::string, Geom* >::iterator giter; + // Fixup the poses of the geoms (they are attached to the CoM) + for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) + { + if (giter->second->IsPlaceable()) + { + // FOR GEOMS: + // get pose with comPose set to oldPose + this->comPose = oldPose; + tmpPose = giter->second->GetPose(); + + // get pose with comPose set to newPose + this->comPose = newPose; + giter->second->SetPose(tmpPose, false); + } + } + + // FOR BODY: Fixup the pose of the CoM (ODE body) + // get pose with comPose set to oldPose + this->comPose = oldPose; + tmpPose = this->GetPose(); + // get pose with comPose set to newPose + this->comPose = newPose; + this->SetPose(tmpPose); + + // Settle on the new CoM pose + this->comPose = newPose; + + + + // comPose is zero in this case, we'll keep cx, cy, cz + this->comPose.Reset(); + + this->comPose.pos.x = this->cx; + this->comPose.pos.y = this->cy; + this->comPose.pos.z = this->cz; + + this->physicsEngine->LockMutex(); + // setup this->mass as well + dMassSetParameters(&this->mass, this->bodyMass, + this->cx, this->cy, this->cz, + //0,0,0, + this->ixx,this->iyy,this->izz, + this->ixy,this->ixz,this->iyz); + + dMassTranslate( &this->mass, -this->cx, -this->cy, -this->cz); + + // dMatrix3 rot; + // dMassRotate(&this->mass, rot); + + // Set the mass matrix + if (this->mass.mass > 0) + dBodySetMass( this->bodyId, &this->mass ); + + // std::cout << " c[0] " << this->mass.c[0] << std::endl; + // std::cout << " c[1] " << this->mass.c[1] << std::endl; + // std::cout << " c[2] " << this->mass.c[2] << std::endl; + // std::cout << " I[0] " << this->mass.I[0] << std::endl; + // std::cout << " I[1] " << this->mass.I[1] << std::endl; + // std::cout << " I[2] " << this->mass.I[2] << std::endl; + // std::cout << " I[3] " << this->mass.I[3] << std::endl; + // std::cout << " I[4] " << this->mass.I[4] << std::endl; + // std::cout << " I[5] " << this->mass.I[5] << std::endl; + // std::cout << " I[6] " << this->mass.I[6] << std::endl; + // std::cout << " I[7] " << this->mass.I[7] << std::endl; + // std::cout << " I[8] " << this->mass.I[8] << std::endl; + + this->physicsEngine->UnlockMutex(); + } + else + { + + // original gazebo subroutine that gathers mass from all geoms and sums into one single mass matrix + + const dMass *lmass; + std::map< std::string, Geom* >::iterator giter; + + this->physicsEngine->LockMutex(); + // Construct the mass matrix by combining all the geoms + dMassSetZero( &this->mass ); + + for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) + { + lmass = giter->second->GetBodyMassMatrix(); + if (giter->second->IsPlaceable() && giter->second->GetGeomId()) + { + dMassAdd( &this->mass, lmass ); + } + } + + // Old pose for the CoM + Pose3d oldPose, newPose, tmpPose; + + // oldPose is the last comPose + // newPose is mass CoM + oldPose = this->comPose; + + if (std::isnan(this->mass.c[0])) + this->mass.c[0] = 0; + + if (std::isnan(this->mass.c[1])) + this->mass.c[1] = 0; + + if (std::isnan(this->mass.c[2])) + this->mass.c[2] = 0; + + // New pose for the CoM + newPose.pos.x = this->mass.c[0]; + newPose.pos.y = this->mass.c[1]; + newPose.pos.z = this->mass.c[2]; + + // Fixup the poses of the geoms (they are attached to the CoM) + for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++) + { + if (giter->second->IsPlaceable()) + { + // FOR GEOMS: + // get pose with comPose set to oldPose + this->comPose = oldPose; + tmpPose = giter->second->GetPose(); + + // get pose with comPose set to newPose + this->comPose = newPose; + giter->second->SetPose(tmpPose, false); + } + } + + // FOR BODY: Fixup the pose of the CoM (ODE body) + // get pose with comPose set to oldPose + this->comPose = oldPose; + tmpPose = this->GetPose(); + // get pose with comPose set to newPose + this->comPose = newPose; + this->SetPose(tmpPose); + + + // Settle on the new CoM pose + this->comPose = newPose; + + // My Cheap Hack, to put the center of mass at the origin + this->mass.c[0] = this->mass.c[1] = this->mass.c[2] = 0; + + // Set the mass matrix + if (this->mass.mass > 0) + dBodySetMass( this->bodyId, &this->mass ); + + this->physicsEngine->UnlockMutex(); + } + +} + + +//////////////////////////////////////////////////////////////////////////////// +/// Set the velocity of the body +void ODEBody::SetLinearVel(const Vector3 &vel) +{ + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + dBodySetLinearVel(this->bodyId, vel.x, vel.y, vel.z); + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// Get the velocity of the body +Vector3 ODEBody::GetLinearVel() const +{ + Vector3 vel; + + if (this->bodyId) + { + const dReal *dvel; + + this->physicsEngine->LockMutex(); + dvel = dBodyGetLinearVel(this->bodyId); + this->physicsEngine->UnlockMutex(); + + vel.x = dvel[0]; + vel.y = dvel[1]; + vel.z = dvel[2]; + } + + return vel; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Set the velocity of the body +void ODEBody::SetAngularVel(const Vector3 &vel) +{ + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + dBodySetAngularVel(this->bodyId, vel.x, vel.y, vel.z); + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// Get the velocity of the body +Vector3 ODEBody::GetAngularVel() const +{ + Vector3 vel; + + if (this->bodyId) + { + const dReal *dvel; + + this->physicsEngine->LockMutex(); + dvel = dBodyGetAngularVel(this->bodyId); + this->physicsEngine->UnlockMutex(); + + vel.x = dvel[0]; + vel.y = dvel[1]; + vel.z = dvel[2]; + } + + return vel; +} + +//////////////////////////////////////////////////////////////////////////////// +/// \brief Set the force applied to the body +void ODEBody::SetForce(const Vector3 &force) +{ + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + dBodyAddForce(this->bodyId, force.x, force.y, force.z); + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// \brief Get the force applied to the body +Vector3 ODEBody::GetForce() const +{ + Vector3 force; + + if (this->bodyId) + { + const dReal *dforce; + + this->physicsEngine->LockMutex(); + dforce = dBodyGetForce(this->bodyId); + this->physicsEngine->UnlockMutex(); + + force.x = dforce[0]; + force.y = dforce[1]; + force.z = dforce[2]; + } + + return force; +} + +//////////////////////////////////////////////////////////////////////////////// +/// \brief Set the torque applied to the body +void ODEBody::SetTorque(const Vector3 &torque) +{ + if (this->bodyId) + { + this->physicsEngine->LockMutex(); + dBodySetTorque(this->bodyId, torque.x, torque.y, torque.z); + this->physicsEngine->UnlockMutex(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// \brief Get the torque applied to the body +Vector3 ODEBody::GetTorque() const +{ + Vector3 torque; + + if (this->bodyId) + { + const dReal *dtorque; + + this->physicsEngine->LockMutex(); + dtorque = dBodyGetTorque(this->bodyId); + this->physicsEngine->UnlockMutex(); + + torque.x = dtorque[0]; + torque.y = dtorque[1]; + torque.z = dtorque[2]; + } + + return torque; +} + Added: code/gazebo/trunk/server/physics/ODEBody.hh =================================================================== --- code/gazebo/trunk/server/physics/ODEBody.hh (rev 0) +++ code/gazebo/trunk/server/physics/ODEBody.hh 2009-05-14 15:55:25 UTC (rev 7662) @@ -0,0 +1,149 @@ +/* + * 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: Body class + * Author: Nate Koenig + * Date: 13 Feb 2006 + * SVN: $Id: Body.hh 7640 2009-05-13 02:06:08Z natepak $ + */ + +#ifndef BODY_HH +#define BODY_HH + +#include <ode/ode.h> + +#include "Body.hh" + +namespace gazebo +{ + class XMLConfigNode; + + /// \addtogroup gazebo_physics + /// \brief The body class + /// \{ + + /// Body class + class ODEBody : public Body + { + /// \brief Constructor + public: ODEBody(Entity *parent); + + /// \brief Destructor + public: virtual ~ODEBody(); + + /// \brief Load the body based on an XMLConfig node + /// \param node XMLConfigNode pointer + public: virtual void LoadChild(XMLConfigNode *node); + + /// \brief Initialize the body + public: virtual void InitChild(); + + /// \brief Finalize the body + public: virtual void FiniChild(); + + /// \brief Update the body + public: virtual void UpdateChild(); + + /// \brief Attach a geom to this body + /// \param geom Geometery to attach to this body + public: virtual void AttachGeom( Geom *geom ); + + /// \brief Set the position of the body + /// \param pos Vector position + public: virtual void SetPosition(const Vector3 &pos); + + /// \brief Set the rotation of the body + /// \param rot Quaternion rotation + public: virtual void SetRotation(const Quatern &rot); + + /// \brief Return the position of the body + /// \return Position vector + public: virtual Vector3 GetPosition() const; + + /// \brief Return the rotation + /// \return Rotation quaternion + public: virtual Quatern GetRotation() const; + + /// \brief Return the velocity of the body + /// \return Velocity vector + public: virtual Vector3 GetPositionRate() const; + + /// \brief Return the rotation rates + /// \return Rotation Rate quaternion + public: virtual Quatern GetRotationRate() const; + + /// \brief Return the rotation rates + /// \return Rotation Rate Euler Angles RPY + public: virtual Vector3 GetEulerRate() const; + + /// \brief Return the ID of this body + /// \return ODE body id + public: dBodyID GetId() const; + + /// \brief Set whether this body is enabled + public: virtual void SetEnabled(bool enable) const; + + /// \brief Update the center of mass + public: virtual void UpdateCoM(); + + /// \brief Set the linear velocity of the body + public: virtual void SetLinearVel(const Vector3 &vel); + + /// \brief Get the linear velocity of the body + public: virtual Vector3 GetLinearVel() const; + + /// \brief Set the angular velocity of the body + public: virtual void SetAngularVel(const Vector3 &vel); + + /// \brief Get the angular velocity of the body + public: virtual Vector3 GetAngularVel() const; + + /// \brief Set the force applied to the body + public: virtual void SetForce(const Vector3 &force); + + /// \brief Get the force applied to the body + public: virtual Vector3 GetForce() const; + + /// \brief Set the angular acceleration of the body + public: virtual void SetAngularAccel(const Vector3 &accel); + + /// \brief Get the angular acceleration of the body + public: virtual Vector3 GetAngularAccel() const; + + /// \brief Set the torque applied to the body + public: virtual void SetTorque(const Vector3 &force); + + /// \brief Get the torque applied to the body + public: virtual Vector3 GetTorque() const; + + /// \brief Set whether gravity affects this body + public: virtual void SetGravityMode(bool mode); + + /// ODE body handle + private: dBodyID bodyId; + + /// Mass properties of the object + private: dMass mass; + }; + + /// \} +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-14 16:41:46
|
Revision: 7663 http://playerstage.svn.sourceforge.net/playerstage/?rev=7663&view=rev Author: natepak Date: 2009-05-14 16:41:37 +0000 (Thu, 14 May 2009) Log Message: ----------- Added gazebo_av library Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt code/gazebo/trunk/server/audio_video/CMakeLists.txt code/gazebo/trunk/server/audio_video/OpenAL.cc code/gazebo/trunk/server/audio_video/OpenAL.hh Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 15:55:25 UTC (rev 7662) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 16:41:37 UTC (rev 7663) @@ -114,6 +114,7 @@ ${boost_libraries} ${freeimage_library} gazebo_server + gazebo_av gazebo_gui gazebo ) Modified: code/gazebo/trunk/server/audio_video/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-14 15:55:25 UTC (rev 7662) +++ code/gazebo/trunk/server/audio_video/CMakeLists.txt 2009-05-14 16:41:37 UTC (rev 7663) @@ -6,7 +6,11 @@ OpenAL.hh ) -APPEND_TO_SERVER_SOURCES(${sources}) -APPEND_TO_SERVER_HEADERS(${headers}) +#APPEND_TO_SERVER_SOURCES(${sources}) +#APPEND_TO_SERVER_HEADERS(${headers}) -#ADD_LIBRARY(gazebo_av STATIC ${sources}) +ADD_LIBRARY(gazebo_av STATIC ${sources}) +ADD_LIBRARY(gazebo_av-shared SHARED ${sources}) + +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 15:55:25 UTC (rev 7662) +++ code/gazebo/trunk/server/audio_video/OpenAL.cc 2009-05-14 16:41:37 UTC (rev 7663) @@ -28,7 +28,10 @@ #include <unistd.h> #include <iostream> + +#include <AL/al.h> #include <AL/alc.h> +#include <AL/alext.h> #include "XMLConfig.hh" #include "GazeboError.hh" Modified: code/gazebo/trunk/server/audio_video/OpenAL.hh =================================================================== --- code/gazebo/trunk/server/audio_video/OpenAL.hh 2009-05-14 15:55:25 UTC (rev 7662) +++ code/gazebo/trunk/server/audio_video/OpenAL.hh 2009-05-14 16:41:37 UTC (rev 7663) @@ -27,15 +27,14 @@ #ifndef OPENAL_HH #define OPENAL_HH -#include <AL/al.h> -#include <AL/alc.h> -#include <AL/alext.h> - #include <stdint.h> #include <string> #include "Vector3.hh" +struct ALCcontext_struct; +struct ALCdevice_struct; + namespace gazebo { @@ -78,8 +77,8 @@ public: void SetListenerOrient(float cx, float cy, float cz, float ux, float uy, float uz); - private: ALCcontext *context; - private: ALCdevice *audioDevice; + private: ALCcontext_struct *context; + private: ALCdevice_struct *audioDevice; private: static OpenAL *myself; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-14 18:53:31
|
Revision: 7665 http://playerstage.svn.sourceforge.net/playerstage/?rev=7665&view=rev Author: natepak Date: 2009-05-14 18:53:16 +0000 (Thu, 14 May 2009) Log Message: ----------- Put openal stuff into a separate library Modified Paths: -------------- code/gazebo/trunk/server/CMakeLists.txt code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/World.hh code/gazebo/trunk/server/gui/CMakeLists.txt Modified: code/gazebo/trunk/server/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 18:44:51 UTC (rev 7664) +++ code/gazebo/trunk/server/CMakeLists.txt 2009-05-14 18:53:16 UTC (rev 7665) @@ -1,7 +1,6 @@ INCLUDE (${gazebo_cmake_dir}/GazeboUtils.cmake) -#${FLTK_INCLUDE_DIR} ######################################## # Include all the search paths for headers INCLUDE_DIRECTORIES( @@ -64,6 +63,7 @@ Param.cc GraphicsIfaceHandler.cc GuiAPI.cc + OpenALAPI.cc Simulator.cc ) @@ -88,6 +88,7 @@ Param.hh GraphicsIfaceHandler.hh GuiAPI.hh + OpenALAPI.hh Simulator.hh ) @@ -110,7 +111,6 @@ TARGET_LINK_LIBRARIES( gazebo-exec ${gazeboserver_link_libs} - ${FLTK_LIBRARIES} ${boost_libraries} ${freeimage_library} gazebo_server Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-05-14 18:44:51 UTC (rev 7664) +++ code/gazebo/trunk/server/World.cc 2009-05-14 18:53:16 UTC (rev 7665) @@ -41,9 +41,7 @@ #include "gazebo.h" #include "World.hh" -#ifdef HAVE_OPENAL -#include "OpenAL.hh" -#endif +#include "OpenALAPI.hh" #include "Geom.hh" @@ -63,6 +61,7 @@ this->physicsEngine = NULL; this->server = NULL; this->graphics = NULL; + this->openAL = NULL; } //////////////////////////////////////////////////////////////////////////////// @@ -113,6 +112,10 @@ gzthrow(e); } + if (this->openAL) + delete this->openAL; + this->openAL = NULL; + } //////////////////////////////////////////////////////////////////////////////// @@ -146,11 +149,12 @@ this->graphics = new GraphicsIfaceHandler(); this->graphics->Load("default"); -#ifdef HAVE_OPENAL // Load OpenAL audio if (rootNode->GetChild("openal","audio")) - OpenAL::Instance()->Load( rootNode->GetChild("openal", "audio") ); -#endif + { + this->openAL = new OpenALAPI(); + this->openAL->Load(rootNode->GetChild("openal", "audio")); + } this->physicsEngine = new ODEPhysics(); //TODO: use exceptions here @@ -203,9 +207,8 @@ this->physicsEngine->Init(); // Initialize openal -#ifdef HAVE_OPENAL - OpenAL::Instance()->Init(); -#endif + if (this->openAL) + this->openAL->Init(); this->toAddModels.clear(); this->toDeleteModels.clear(); @@ -315,9 +318,8 @@ } // Close the openal server -#ifdef HAVE_OPENAL - OpenAL::Instance()->Fini(); -#endif + if (this->openAL) + this->openAL->Fini(); } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/World.hh =================================================================== --- code/gazebo/trunk/server/World.hh 2009-05-14 18:44:51 UTC (rev 7664) +++ code/gazebo/trunk/server/World.hh 2009-05-14 18:53:16 UTC (rev 7665) @@ -47,6 +47,7 @@ class PhysicsEngine; class XMLConfigNode; class GraphicsIfaceHandler; + class OpenALAPI; /// \brief The World /* @@ -211,6 +212,8 @@ /// Length of time to run before receiving a "go" command private: double simPauseTime; + private: OpenALAPI *openAL; + private: friend class DestroyerT<World>; private: friend class SingletonT<World>; Modified: code/gazebo/trunk/server/gui/CMakeLists.txt =================================================================== --- code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 18:44:51 UTC (rev 7664) +++ code/gazebo/trunk/server/gui/CMakeLists.txt 2009-05-14 18:53:16 UTC (rev 7665) @@ -1,3 +1,7 @@ +INCLUDE_DIRECTORIES( + ${FLTK_INCLUDE_DIR} +) + SET (sources Gui.cc GLWindow.cc MainMenu.cc @@ -19,6 +23,9 @@ 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-shared ${FLTK_LIBRARIES} ) + #SET_TARGET_PROPERTIES(gazebo_gui-static PROPERTIES OUTPUT_NAME "gazebo_gui") SET_TARGET_PROPERTIES(gazebo_gui-shared PROPERTIES OUTPUT_NAME "gazebo_gui") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2009-05-14 19:00:13
|
Revision: 7666 http://playerstage.svn.sourceforge.net/playerstage/?rev=7666&view=rev Author: natepak Date: 2009-05-14 18:59:59 +0000 (Thu, 14 May 2009) Log Message: ----------- Added OpenALAPI Added Paths: ----------- code/gazebo/trunk/server/OpenALAPI.cc code/gazebo/trunk/server/OpenALAPI.hh Added: code/gazebo/trunk/server/OpenALAPI.cc =================================================================== --- code/gazebo/trunk/server/OpenALAPI.cc (rev 0) +++ code/gazebo/trunk/server/OpenALAPI.cc 2009-05-14 18:59:59 UTC (rev 7666) @@ -0,0 +1,43 @@ +#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 +} Added: code/gazebo/trunk/server/OpenALAPI.hh =================================================================== --- code/gazebo/trunk/server/OpenALAPI.hh (rev 0) +++ code/gazebo/trunk/server/OpenALAPI.hh 2009-05-14 18:59:59 UTC (rev 7666) @@ -0,0 +1,48 @@ +/* + * 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$ + */ + +namespace gazebo +{ + 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 Finalize + public: void Fini(); + }; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |