From: <he...@us...> - 2010-03-28 08:27:29
|
Revision: 189 http://simspark.svn.sourceforge.net/simspark/?rev=189&view=rev Author: hedayat Date: 2010-03-28 08:27:22 +0000 (Sun, 28 Mar 2010) Log Message: ----------- Fixed a race condition in MonitorServer->GetMonitorData() Fixed the shared_ptr.hpp path Removed some extra cin/cout Modified Paths: -------------- trunk/spark/ChangeLog trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp trunk/spark/lib/oxygen/monitorserver/monitorserver.h trunk/spark/lib/oxygen/physicsserver/int/jointint.h trunk/spark/lib/oxygen/physicsserver/int/physicsobjectint.h trunk/spark/lib/oxygen/physicsserver/int/sliderjointint.h trunk/spark/plugin/odeimps/odejoint.cpp Modified: trunk/spark/ChangeLog =================================================================== --- trunk/spark/ChangeLog 2010-03-10 06:24:22 UTC (rev 188) +++ trunk/spark/ChangeLog 2010-03-28 08:27:22 UTC (rev 189) @@ -1,3 +1,17 @@ +2010-03-28 Hedayat Vatankhah <he...@gr...> + + * lib/oxygen/monitorserver/monitorserver.h (MonitorServer): + * lib/oxygen/monitorserver/monitorserver.cpp (MonitorServer::GetMonitorData): + - protect GetMonitorData() on simultaneous access + + * lib/oxygen/physicsserver/int/sliderjointint.h: + * lib/oxygen/physicsserver/int/jointint.h: + * lib/oxygen/physicsserver/int/physicsobjectint.h: + - fixed the shared_ptr.hpp include path + + * plugin/odeimps/odejoint.cpp (JointImp::EnableFeedback): + - removed extra cin/cout commands + 2010-02-28 Marian Buchta <mar...@gm...> * lib/kerosin/fontserver/fontserver.cpp: Modified: trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp =================================================================== --- trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp 2010-03-10 06:24:22 UTC (rev 188) +++ trunk/spark/lib/oxygen/monitorserver/monitorserver.cpp 2010-03-28 08:27:22 UTC (rev 189) @@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <boost/thread/locks.hpp> #include <zeitgeist/logserver/logserver.h> #include <oxygen/simulationserver/simulationserver.h> #include "monitorserver.h" @@ -176,10 +177,12 @@ string MonitorServer::GetMonitorData() { int cycle = mSimulationServer->GetCycle(); + boost::mutex::scoped_lock dataLock(mDataMutex); + if ( cycle == mDataCycle ){ return mData; } - + boost::shared_ptr<MonitorSystem> monitorSystem = GetMonitorSystem(); if (monitorSystem.get() == 0) Modified: trunk/spark/lib/oxygen/monitorserver/monitorserver.h =================================================================== --- trunk/spark/lib/oxygen/monitorserver/monitorserver.h 2010-03-10 06:24:22 UTC (rev 188) +++ trunk/spark/lib/oxygen/monitorserver/monitorserver.h 2010-03-28 08:27:22 UTC (rev 189) @@ -22,6 +22,7 @@ #ifndef OXYGEN_MONITORSERVER_H #define OXYGEN_MONITORSERVER_H +#include <boost/thread/mutex.hpp> #include <oxygen/oxygen_defines.h> #include <zeitgeist/class.h> #include <zeitgeist/node.h> @@ -90,6 +91,9 @@ /** the cycle of cacahed data */ int mDataCycle; + + /** a mutex to protect mData and mDataCycle variables */ + boost::mutex mDataMutex; }; DECLARE_CLASS(MonitorServer); Modified: trunk/spark/lib/oxygen/physicsserver/int/jointint.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/int/jointint.h 2010-03-10 06:24:22 UTC (rev 188) +++ trunk/spark/lib/oxygen/physicsserver/int/jointint.h 2010-03-28 08:27:22 UTC (rev 189) @@ -24,7 +24,7 @@ #define OXYGEN_JOINTINT_H #include <oxygen/physicsserver/genericphysicsobjects.h> -#include <boost/smart_ptr/shared_ptr.hpp> +#include <boost/shared_ptr.hpp> #include <salt/vector.h> #include <oxygen/oxygen_defines.h> #include <string> @@ -41,22 +41,22 @@ specified by \param jointID. */ virtual Joint* GetJoint(long jointID) = 0; - - /** Checks if two bodies, specified by \param bodyID1 and + + /** Checks if two bodies, specified by \param bodyID1 and \param bodyID2, are connected by a joint. */ virtual bool AreConnected(long bodyID1, long bodyID2) = 0; - - /** Checks if two bodies, specified by \param bodyID1 and + + /** Checks if two bodies, specified by \param bodyID1 and \param bodyID2, are connected by a joint that is not of the type specified by \param joint_type. */ virtual bool AreConnectedExcluding(long bodyID1, long bodyID2, int joint_type) = 0; - + /** Destroys the Joint specified by \param jointID */ virtual void DestroyJoint(long jointID, boost::shared_ptr<GenericJointFeedback> feedback) = 0; - + /** attaches the joint to some new bodies. If the joint is already attached, it will be detached from the old bodies first. To attach this joint to only one body, set body1 or body2 to @@ -65,21 +65,21 @@ have no effect on the simulation. */ virtual void Attach(long bodyID1, long bodiID2, long jointID) = 0; - + /** returns the type of the managed joint, possible return values from ODE are dJointTypeNone, dJointTypeBall, dJointTypeHinge, dJointTypeSlider, dJointTypeContact, dJointTypeUniversal, dJointTypeHinge2, dJointTypeFixed or dJointTypeAMotor. */ virtual int GetType(long jointID) const = 0; - - /** Returns the ID of one of the bodies the joint specified + + /** Returns the ID of one of the bodies the joint specified by \param jointID is connected to. Since a joint is always connected to two bodies, use \param idx to address the first or second body. */ virtual long GetBodyID(int idx, long jointID) = 0; - + /** during the world time step, the forces that are applied by each joint are added directly to the joined bodies, and the user normally has no way of telling which joint contributed @@ -89,80 +89,80 @@ */ virtual void EnableFeedback(bool enable, long jointID, boost::shared_ptr<GenericJointFeedback> feedback) = 0; - + /** returns true if the joint is set to collect feedback - information + information */ virtual bool FeedbackEnabled(long jointID) const = 0; - + /** queries the force that the joint applied to one body attached to it during the last timestep. */ virtual salt::Vector3f GetFeedbackForce(int idx, boost::shared_ptr<GenericJointFeedback> feedback) const = 0; - + /** queries the torque that the joint applied to one body attached to it during the last timestep. */ virtual salt::Vector3f GetFeedbackTorque(int idx, boost::shared_ptr<GenericJointFeedback> feedback) const = 0; - + /** sets the fudgefactor parameter, making this value too small can prevent the motor from being able to move the joint away from a stop */ virtual void SetFudgeFactor(int idx, float fudge_factor, long jointID) = 0; - + /** returns the fudgefactor paramter */ virtual float GetFudgeFactor(int idx, long jointID) const = 0; - + /** sets the bouncyness of the stops. This is a restitution parameter in the range 0..1. 0 means the stops are not bouncy at all, 1 means maximum bouncyness. */ virtual void SetBounce(int idx, float bounce, long jointID) = 0; - + /** returns the bouncyness of the stops */ virtual float GetBounce(int idx, long jointID) const = 0; - + /** sets the low stop angle in degrees, this stop must be greater than -180 to be effective */ virtual void SetLowStopDeg(int idx, float deg, long jointID) = 0; - + /** returns the low stop angle in degrees */ virtual float GetLowStopDeg(int idx, long jointID) const = 0; - + /** sets the high stop angle in degrees, this stop must be less than +180 to be effective */ virtual void SetHighStopDeg(int idx, float deg, long jointID) = 0; - + /** returns the high stop angle in degrees */ virtual float GetHighStopDeg(int idx, long jointID) const = 0; - + /** sets the low stop position */ virtual void SetLowStopPos(int idx, float deg, long jointID) = 0; - + /** returns the low stop position */ virtual float GetLowStopPos(int idx, long jointID) const = 0; - + /** sets the high stop position */ virtual void SetHighStopPos(int idx, float deg, long jointID) = 0; - + /** returns the high stop position */ virtual float GetHighStopPos(int idx, long jointID) const = 0; - + /** the constraint force mixing (CFM) value used when not at a - stop + stop */ virtual void SetCFM(int idx, float cfm, long jointID) = 0; - + /** returns the constraint force mixing value used when not a a - stop + stop */ virtual float GetCFM(int idx, long jointID) const = 0; - + /** sets the constraint force mixing (CFM) value used by the stops. Together with the ERP value this can be used to get spongy or soft stops. This is intended for unpowered joints, @@ -170,73 +170,73 @@ reaches its limit. */ virtual void SetStopCFM(int idx, float cfm, long jointID) = 0; - + /** returns the constraint force mixing value used by the stops */ virtual float GetStopCFM(int idx, long jointID) const = 0; - + /** sets the error reduction parameter (ERP) used by the stops. */ virtual void SetStopERP(int idx, float erp, long jointID) = 0; - + /** returns the error reduction parameter used by the stops */ virtual float GetStopERP(int idx, long jointID) const = 0; - + /** sets the suspension error reduction parameter (ERP). As of ode 0.039 this is only implemented on the hinge-2 joint. */ virtual void SetSuspensionERP(int idx, float erp, long jointID) = 0; - + /** returns the suspension error reduction parameter (ERP). As of ode 0.039 this is only implemented on the hinge-2 joint. */ virtual float GetSuspensionERP(int idx, long jointID) const = 0; - + /** sets the suspension constraint force mixing value. As of ode 0.039 this is only implemented on the hinge-2 joint. */ virtual void SetSuspensionCFM(int idx, float cfm, long jointID) = 0; - + /** returns the suspension constraint force mixing value. As of ode 0.039 this is only implemented on the hinge-2 joint. */ virtual float GetSuspensionCFM(int idx, long jointID) const = 0; - + /** sets the linear motor velocity */ virtual void SetLinearMotorVelocity(int idx, float vel, long jointID) = 0; - + /** returns the linear motor velocity */ virtual float GetLinearMotorVelocity(int idx, long jointID) const = 0; - + /** sets the angular motor velocity in degrees */ virtual void SetAngularMotorVelocity(int idx, float deg, long jointID) = 0; - + /** returns the angular motor velocity in degrees */ virtual float GetAngularMotorVelocity(int idx, long jointID) const = 0; - + /** sets the maximum force or torque that the motor will use to achieve the desired velocity. This must always be greater than or equal to zero. Setting this to zero (the default value) turns off the motor. */ virtual void SetMaxMotorForce(int idx, float f, long jointID) = 0; - + /** returns the maximum force or torque that the motor will use to achieve the desired velocity. */ virtual float GetMaxMotorForce(int idx, long jointID) const = 0; - + /** Sets the joint parameter indexed by \param parameter of the joint specified by \param jointID to \param value - */ + */ virtual void SetParameter(int parameter, float value, long jointID) = 0; - + /** Returns the joint parameter indexed by \param parameter of the joint specified by \param jointID - */ + */ virtual float GetParameter(int parameter, long jointID) const = 0; - + /** Links the ID of the joint specified by \param jointID to the Joint - object specified by \param joint. Doing this allows us to later - find the Joint object that manages the joint specified + object specified by \param joint. Doing this allows us to later + find the Joint object that manages the joint specified by \param jointID. */ virtual void OnLink(long jointID, Joint* joint) = 0; Modified: trunk/spark/lib/oxygen/physicsserver/int/physicsobjectint.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/int/physicsobjectint.h 2010-03-10 06:24:22 UTC (rev 188) +++ trunk/spark/lib/oxygen/physicsserver/int/physicsobjectint.h 2010-03-28 08:27:22 UTC (rev 189) @@ -23,7 +23,7 @@ #ifndef OXYGEN_PHYSICSOBJECTINT_H #define OXYGEN_PHYSICSOBJECTINT_H -#include <boost/smart_ptr/shared_ptr.hpp> +#include <boost/shared_ptr.hpp> #include <salt/matrix.h> #include <oxygen/oxygen_defines.h> #include <oxygen/physicsserver/genericphysicsobjects.h> @@ -34,12 +34,12 @@ class OXYGEN_API PhysicsObjectInt { -public: +public: /** converts the rotation part of a salt::Matrix to an engine-specific matrix that arranges the values in a different way */ virtual void ConvertRotationMatrix(const salt::Matrix& rot, GenericPhysicsMatrix& matrix) = 0; - + /** coverts an engine-specific matrix to the rotation part of a salt::Matrix */ virtual void ConvertRotationMatrix(const GenericPhysicsMatrix* matrix, salt::Matrix& rot) const = 0; }; Modified: trunk/spark/lib/oxygen/physicsserver/int/sliderjointint.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/int/sliderjointint.h 2010-03-10 06:24:22 UTC (rev 188) +++ trunk/spark/lib/oxygen/physicsserver/int/sliderjointint.h 2010-03-28 08:27:22 UTC (rev 189) @@ -23,7 +23,7 @@ #ifndef OXYGEN_SLIDERJOINTINT_H #define OXYGEN_SLIDERJOINTINT_H -#include <boost/smart_ptr/shared_ptr.hpp> +#include <boost/shared_ptr.hpp> #include <oxygen/oxygen_defines.h> namespace oxygen @@ -35,17 +35,17 @@ public: /** Creates a Slider Joint within the given world */ virtual long CreateSliderJoint(long world) = 0; - + /** returns the slider linear position, i.e. the slider's `extension'. When the axis is set, the current position of the attached bodies is examined and that position will be the zero position. */ virtual float GetPosition(long jointID) = 0; - + /** returns the time derivative of the sliders linear position */ virtual float GetPositionRate(long jointID) = 0; - + /** Sets the direction of the slider joint's axis */ virtual void SetSliderAxis(salt::Vector3f& up, long jointID) = 0; }; Modified: trunk/spark/plugin/odeimps/odejoint.cpp =================================================================== --- trunk/spark/plugin/odeimps/odejoint.cpp 2010-03-10 06:24:22 UTC (rev 188) +++ trunk/spark/plugin/odeimps/odejoint.cpp 2010-03-28 08:27:22 UTC (rev 189) @@ -25,7 +25,7 @@ using namespace std; using namespace salt; -JointImp::JointImp() : PhysicsObjectImp() +JointImp::JointImp() : PhysicsObjectImp() { } @@ -73,11 +73,11 @@ return (long) ODEBodyID; } -void JointImp::EnableFeedback(bool enable, long jointID, +void JointImp::EnableFeedback(bool enable, long jointID, boost::shared_ptr<GenericJointFeedback> feedback) { dJointID JointImp = (dJointID) jointID; - + if (enable) { if (feedback.get() == 0) @@ -94,8 +94,6 @@ } } - cout << "bla"; - std::cin; dJointFeedback* ODEFeedback = (dJointFeedback*) feedback.get(); dJointSetFeedback(JointImp,ODEFeedback); @@ -107,7 +105,7 @@ return (dJointGetFeedback(JointImp) != 0); } -Vector3f JointImp::GetFeedbackForce(int idx, +Vector3f JointImp::GetFeedbackForce(int idx, boost::shared_ptr<GenericJointFeedback> feedback) const { dJointFeedback* fb = (dJointFeedback*) feedback.get(); @@ -166,7 +164,7 @@ return Vector3f(0,0,0); } } - + void JointImp::SetFudgeFactor(int idx, float fudge_factor, long jointID) { SetParameter(dParamFudgeFactor + (idx * dParamGroup), fudge_factor, jointID); @@ -307,7 +305,7 @@ return GetParameter(dParamFMax + (idx * dParamGroup), jointID); } -void JointImp::DestroyJoint(long jointID, +void JointImp::DestroyJoint(long jointID, boost::shared_ptr<GenericJointFeedback> feedback) { dJointID JointImp = (dJointID) jointID; @@ -328,7 +326,7 @@ case dJointTypeUniversal: dJointSetUniversalParam(JointImp, parameter, value); break; case dJointTypeAMotor: dJointSetAMotorParam(JointImp, parameter, value); - break; + break; default: return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |