Revision: 8805
http://playerstage.svn.sourceforge.net/playerstage/?rev=8805&view=rev
Author: natepak
Date: 2010-06-28 16:20:53 +0000 (Mon, 28 Jun 2010)
Log Message:
-----------
Added ability to make bodies kinematic only
Modified Paths:
--------------
code/gazebo/trunk/server/Param.hh
code/gazebo/trunk/server/physics/Body.cc
code/gazebo/trunk/server/physics/Body.hh
code/gazebo/trunk/server/physics/bullet/BulletBody.hh
code/gazebo/trunk/server/physics/ode/ODEBody.cc
code/gazebo/trunk/server/physics/ode/ODEBody.hh
Modified: code/gazebo/trunk/server/Param.hh
===================================================================
--- code/gazebo/trunk/server/Param.hh 2010-06-28 16:19:58 UTC (rev 8804)
+++ code/gazebo/trunk/server/Param.hh 2010-06-28 16:20:53 UTC (rev 8805)
@@ -66,11 +66,18 @@
/// \brief Set the parameter value from a string
public: virtual void SetFromString(const std::string &, bool
callback=false) {}
+ /// \brief Set the help string
+ public: void SetHelp(const std::string &h) {this->help = h;}
+
+ /// \brief Get the help string
+ public: std::string GetHelp() const {return this->help;}
+
/// List of created parameters
private: static std::vector<Param*> *params;
protected: std::string key;
protected: std::string typeName;
+ protected: std::string help;
};
Modified: code/gazebo/trunk/server/physics/Body.cc
===================================================================
--- code/gazebo/trunk/server/physics/Body.cc 2010-06-28 16:19:58 UTC (rev
8804)
+++ code/gazebo/trunk/server/physics/Body.cc 2010-06-28 16:20:53 UTC (rev
8805)
@@ -90,6 +90,10 @@
this->ixzP = new ParamT<double>("ixz",0.0,0);
this->iyzP = new ParamT<double>("iyz",0.0,0);
+ this->kinematicP = new ParamT<bool>("kinematic",true,0);
+ this->kinematicP->SetHelp("true = kinematic state only, false = dynamic
body");
+ this->kinematicP->Callback( &Body::SetKinematic, this );
+
Param::End();
}
@@ -139,6 +143,7 @@
delete this->ixyP;
delete this->ixzP;
delete this->iyzP;
+ delete this->kinematicP;
}
////////////////////////////////////////////////////////////////////////////////
@@ -162,6 +167,7 @@
this->ixyP->Load(node);
this->ixzP->Load(node);
this->iyzP->Load(node);
+ this->kinematicP->Load(node);
this->customMass.SetCoG(**this->cxP, **this->cyP,** this->czP);
this->customMass.SetInertiaMatrix( **this->ixxP, **this->iyyP, **this->izzP,
@@ -210,6 +216,8 @@
childNode = childNode->GetNextByNSPrefix("sensor");
}
+ this->SetKinematic(**this->kinematicP);
+
//this->GetModel()->ConnectUpdateSignal( boost::bind(&Body::Update, this) );
}
@@ -722,3 +730,4 @@
this->customMass = mass;
}
+
Modified: code/gazebo/trunk/server/physics/Body.hh
===================================================================
--- code/gazebo/trunk/server/physics/Body.hh 2010-06-28 16:19:58 UTC (rev
8804)
+++ code/gazebo/trunk/server/physics/Body.hh 2010-06-28 16:20:53 UTC (rev
8805)
@@ -222,6 +222,12 @@
public: Entity *GetCoMEntity() { return this->comEntity; }
+ /// \brief Set whether this body is in the kinematic state
+ public: virtual void SetKinematic(const bool &) {}
+
+ /// \brief Get whether this body is in the kinematic state
+ public: virtual bool GetKinematic() const {return false;}
+
/// \brief Connect a boost::slot the the add entity signal
public: template<typename T>
boost::signals::connection ConnectEnabledSignal( T subscriber )
@@ -280,6 +286,7 @@
protected: ParamT<double> *ixyP;
protected: ParamT<double> *ixzP;
protected: ParamT<double> *iyzP;
+ protected: ParamT<bool> *kinematicP;
protected: Mass customMass;
private: boost::signal<void (bool)> enabledSignal;
Modified: code/gazebo/trunk/server/physics/bullet/BulletBody.hh
===================================================================
--- code/gazebo/trunk/server/physics/bullet/BulletBody.hh 2010-06-28
16:19:58 UTC (rev 8804)
+++ code/gazebo/trunk/server/physics/bullet/BulletBody.hh 2010-06-28
16:20:53 UTC (rev 8805)
@@ -109,7 +109,6 @@
/// \brief Get the gravity mode
public: virtual bool GetGravityMode();
-
/// \brief Set whether this body will collide with others in the model
public: void SetSelfCollide(bool collide);
Modified: code/gazebo/trunk/server/physics/ode/ODEBody.cc
===================================================================
--- code/gazebo/trunk/server/physics/ode/ODEBody.cc 2010-06-28 16:19:58 UTC
(rev 8804)
+++ code/gazebo/trunk/server/physics/ode/ODEBody.cc 2010-06-28 16:20:53 UTC
(rev 8805)
@@ -486,3 +486,27 @@
dBodySetAngularDamping(this->GetODEId(), damping);
}
+////////////////////////////////////////////////////////////////////////////////
+// Set whether this body is in the kinematic state
+void ODEBody::SetKinematic(const bool &state)
+{
+ if (this->bodyId)
+ {
+ if (state)
+ dBodySetKinematic(this->bodyId);
+ else
+ dBodySetDynamic(this->bodyId);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Get whether this body is in the kinematic state
+bool ODEBody::GetKinematic() const
+{
+ bool result = false;
+
+ if (this->bodyId)
+ result = dBodyIsKinematic(this->bodyId);
+
+ return result;
+}
Modified: code/gazebo/trunk/server/physics/ode/ODEBody.hh
===================================================================
--- code/gazebo/trunk/server/physics/ode/ODEBody.hh 2010-06-28 16:19:58 UTC
(rev 8804)
+++ code/gazebo/trunk/server/physics/ode/ODEBody.hh 2010-06-28 16:20:53 UTC
(rev 8805)
@@ -128,6 +128,12 @@
public: static void MoveCallback(dBodyID id);
+ /// \brief Set whether this body is in the kinematic state
+ public: virtual void SetKinematic(const bool &state);
+
+ /// \brief Get whether this body is in the kinematic state
+ public: virtual bool GetKinematic() const;
+
protected: Pose3d pose;
/// ODE body handle
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 Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit