Revision: 8478 http://playerstage.svn.sourceforge.net/playerstage/?rev=8478&view=rev Author: natepak Date: 2009-12-22 06:17:23 +0000 (Tue, 22 Dec 2009)
Log Message: ----------- Fixed more issues with 64bit machines Modified Paths: -------------- code/gazebo/trunk/server/Mesh.cc code/gazebo/trunk/server/STLLoader.cc code/gazebo/trunk/server/STLLoader.hh code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/physics/PhysicsEngine.cc code/gazebo/trunk/server/physics/PhysicsEngine.hh code/gazebo/trunk/server/physics/ode/ODEBody.cc code/gazebo/trunk/server/physics/ode/ODEPhysics.cc code/gazebo/trunk/server/rendering/OgreAdaptor.cc code/gazebo/trunk/server/rendering/OgreCreator.cc code/gazebo/trunk/server/rendering/OgreCreator.hh Modified: code/gazebo/trunk/server/Mesh.cc =================================================================== --- code/gazebo/trunk/server/Mesh.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/Mesh.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -178,7 +178,7 @@ if (i < this->submeshes.size()) return this->submeshes[i]; else - gzthrow("Invalid index\n"); + gzthrow("Invalid index: " << i << " >= " << this->submeshes.size() << "\n"); } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/STLLoader.cc =================================================================== --- code/gazebo/trunk/server/STLLoader.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/STLLoader.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -279,11 +279,11 @@ //////////////////////////////////////////////////////////////////////////////// /// Reads a long int from a binary file. -long int STLLoader::LongIntRead ( FILE *filein ) +uint32_t STLLoader::LongIntRead ( FILE *filein ) { union { - long int yint; + uint32_t yint; char ychar[4]; } y; @@ -297,11 +297,11 @@ //////////////////////////////////////////////////////////////////////////////// /// Reads a short int from a binary file. -short int STLLoader::ShortIntRead ( FILE *filein ) +uint16_t STLLoader::ShortIntRead ( FILE *filein ) { - unsigned char c1; - unsigned char c2; - short int ival; + uint8_t c1; + uint8_t c2; + uint16_t ival; c1 = fgetc ( filein ); c2 = fgetc ( filein ); Modified: code/gazebo/trunk/server/STLLoader.hh =================================================================== --- code/gazebo/trunk/server/STLLoader.hh 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/STLLoader.hh 2009-12-22 06:17:23 UTC (rev 8478) @@ -1,6 +1,8 @@ #ifndef STLLOADER_HH #define STLLOADER_HH +#include <stdint.h> + #include "MeshLoader.hh" #define LINE_MAX_LEN 256 @@ -36,10 +38,10 @@ private: int RcolFind ( float a[][COR3_MAX], int m, int n, float r[] ); /// Reads a long int from a binary file. - private: long int LongIntRead ( FILE *filein ); + private: uint32_t LongIntRead ( FILE *filein ); /// Reads a short int from a binary file. - private: short int ShortIntRead ( FILE *filein ); + private: uint16_t ShortIntRead ( FILE *filein ); /// Read 1 float from a binary file. private: float FloatRead ( FILE *filein ); Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/Simulator.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -632,6 +632,7 @@ { //DiagnosticTimer timer("PhysicsLoop Timer "); + currTime = this->GetRealTime(); userStepped = false; Modified: code/gazebo/trunk/server/physics/PhysicsEngine.cc =================================================================== --- code/gazebo/trunk/server/physics/PhysicsEngine.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/physics/PhysicsEngine.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -26,6 +26,8 @@ #include <boost/thread/recursive_mutex.hpp> +#include "OgreVisual.hh" +#include "OgreCreator.hh" #include "Shape.hh" #include "PhysicsEngine.hh" @@ -42,12 +44,18 @@ Param::End(); this->mutex = new boost::recursive_mutex(); + this->visual = OgreCreator::Instance()->CreateVisual("Physics_Engine_Visual"); + this->visual->SetCastShadows(false); + this->visual->SetPosition(Vector3(0,0,0)); + this->visual->AttachMesh("joint_anchor"); + this->visual->SetVisible(false); } //////////////////////////////////////////////////////////////////////////////// // Destructor PhysicsEngine::~PhysicsEngine() { + delete this->visual; delete this->gravityP; delete this->updateRateP; delete this->stepTimeP; @@ -101,3 +109,10 @@ return NULL; } + +//////////////////////////////////////////////////////////////////////////////// +/// Add a contact visual +void PhysicsEngine::AddContactVisual(Vector3 pos, Vector3 norm) +{ + this->visual->SetDirty(true, Pose3d(pos, Quatern())); +} Modified: code/gazebo/trunk/server/physics/PhysicsEngine.hh =================================================================== --- code/gazebo/trunk/server/physics/PhysicsEngine.hh 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/physics/PhysicsEngine.hh 2009-12-22 06:17:23 UTC (rev 8478) @@ -44,6 +44,7 @@ class Entity; class Body; class XMLConfigNode; + class OgreVisual; /// \addtogroup gazebo_physics_engine /** \{ @@ -149,6 +150,9 @@ /// \brief Convert a Gazebo mass to an engine specific mass public: virtual void ConvertMass(void *engineMass, const Mass &mass) = 0; + /// \brief Add a contact visual + protected: void AddContactVisual(Vector3 pos, Vector3 norm); + /// The gravity vector protected: ParamT<Vector3> *gravityP; @@ -163,6 +167,8 @@ protected: std::vector<Param*> parameters; private: boost::recursive_mutex *mutex; + + protected: OgreVisual *visual; }; /** \}*/ Modified: code/gazebo/trunk/server/physics/ode/ODEBody.cc =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEBody.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/physics/ode/ODEBody.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -101,7 +101,6 @@ const dReal *r; ODEBody *self = (ODEBody*)(dBodyGetData(id)); - self->physicsEngine->LockMutex(); p = dBodyGetPosition(id); r = dBodyGetQuaternion(id); @@ -111,7 +110,6 @@ Pose3d pp = self->comEntity->GetRelativePose().GetInverse() + pose; self->SetAbsPose(pp, false); - self->physicsEngine->UnlockMutex(); } //////////////////////////////////////////////////////////////////////////////// Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc =================================================================== --- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -65,6 +65,7 @@ ODEPhysics::ODEPhysics() : PhysicsEngine() { + // Collision detection init dInitODE2(0); @@ -192,11 +193,11 @@ // Update the ODE collisions, create joints void ODEPhysics::UpdateCollision() { - DiagnosticTimer timer("ODEPhysics Collision Update"); + //DiagnosticTimer timer("ODEPhysics Collision Update"); std::vector<ContactFeedback>::iterator iter; std::vector<dJointFeedback>::iterator jiter; - timer.Start(); + //timer.Start(); // Do collision detection; this will add contacts to the contact group this->LockMutex(); @@ -247,18 +248,23 @@ this->LockMutex(); - DiagnosticTimer timer("ODEPhysics Step Update"); + //DiagnosticTimer timer("ODEPhysics Step Update"); // Update the dynamical model - if (this->quickStepP->GetValue()) + if (**this->quickStepP) + { dWorldQuickStep(this->worldId, (**this->stepTimeP).Double()); + } else + { dWorldStep( this->worldId, (**this->stepTimeP).Double() ); + } // Very important to clear out the contact group dJointGroupEmpty( this->contactGroup ); this->UnlockMutex(); + } @@ -514,18 +520,21 @@ dJointID c = dJointCreateContact (self->worldId, self->contactGroup, &contact); + Vector3 contactPos(contact.geom.pos[0], contact.geom.pos[1], + contact.geom.pos[2]); + Vector3 contactNorm(contact.geom.normal[0], contact.geom.normal[1], + contact.geom.normal[2]); + + self->AddContactVisual(contactPos, contactNorm); + // Store the contact info if (geom1->GetContactsEnabled() || geom2->GetContactsEnabled()) { (*self->contactFeedbackIter).contact.depths.push_back( contact.geom.depth); - (*self->contactFeedbackIter).contact.positions.push_back( - Vector3(contact.geom.pos[0], contact.geom.pos[1], - contact.geom.pos[2]) ); - (*self->contactFeedbackIter).contact.normals.push_back( - Vector3(contact.geom.normal[0], contact.geom.normal[1], - contact.geom.normal[2]) ); + (*self->contactFeedbackIter).contact.positions.push_back(contactPos); + (*self->contactFeedbackIter).contact.normals.push_back(contactNorm); (*self->contactFeedbackIter).contact.time = Simulator::Instance()->GetSimTime(); dJointSetFeedback(c, &((*self->contactFeedbackIter).feedbacks[i])); Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -23,6 +23,7 @@ * Date: 13 Feb 2006 * CVS: $Id$ */ +#include <stdint.h> #include <Ogre.h> #include <OgreDataStream.h> @@ -178,7 +179,7 @@ glXMakeCurrent(this->dummyDisplay, this->dummyWindowId, this->dummyContext); OgreCreator::Instance()->CreateWindow(this->dummyDisplay, screen, - (long)this->dummyWindowId,1,1); + (int32_t)this->dummyWindowId,1,1); } // Set default mipmap level (NB some APIs ignore this) Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-12-22 06:17:23 UTC (rev 8478) @@ -555,7 +555,7 @@ XSync(fl_display, false); win = OgreCreator::CreateWindow( fl_display, fl_visual->screen, - (long)(Fl_X::i(flWindow)->xid), width, height); + (int32_t)(Fl_X::i(flWindow)->xid), width, height); if (win) this->windows.push_back(win); } @@ -566,8 +566,7 @@ //////////////////////////////////////////////////////////////////////////////// // Create a window for Ogre Ogre::RenderWindow *OgreCreator::CreateWindow(Display *display, int screen, - long winId, unsigned int width, - unsigned int height) + int32_t winId, unsigned int width, unsigned int height) { if (!Simulator::Instance()->GetRenderEngineEnabled()) return NULL; @@ -741,15 +740,11 @@ // Update the text for (titer = this->text.begin(); titer != this->text.end(); titer++) - { (*titer)->Update(); - } // Update the lines for (iter = this->lines.begin(); iter != this->lines.end(); iter++) - { (*iter)->Update(); - } // We only need this loop because we are using threads. The physics engine // can't reliably set the pose of the visuals when it's running in a @@ -977,6 +972,6 @@ } catch (Ogre::Exception e) { - std::cerr << "Unable to create a basic Unit cylinder object" << std::endl; + gzerr(0) << "Unable to create a basic Unit cylinder object" << std::endl; } } Modified: code/gazebo/trunk/server/rendering/OgreCreator.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.hh 2009-12-22 05:40:16 UTC (rev 8477) +++ code/gazebo/trunk/server/rendering/OgreCreator.hh 2009-12-22 06:17:23 UTC (rev 8478) @@ -26,6 +26,7 @@ #ifndef OGRECREATOR #define OGRECREATOR +#include <stdint.h> #include <string> #include <vector> @@ -103,7 +104,7 @@ /// \brief Create a window for Ogre public: Ogre::RenderWindow *CreateWindow(Display *display, int screen, - long winId, + int32_t winId, unsigned int width, unsigned int height); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit