[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21635] branches/itasc: iTaSC: add param structure for IK algorithm + DNA + RNA + UI panel.

Benoit Bolsee benoit.bolsee at online.be
Thu Jul 16 23:16:32 CEST 2009


Revision: 21635
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21635
Author:   ben2610
Date:     2009-07-16 23:16:31 +0200 (Thu, 16 Jul 2009)

Log Message:
-----------
iTaSC: add param structure for IK algorithm + DNA + RNA + UI panel. My  first real plyaing with RNA! It gives user control over fixed or automatic substepping and precision of reiteration. Add the necessary support in plugin and iTaSC library.

Modified Paths:
--------------
    branches/itasc/intern/itasc/Armature.cpp
    branches/itasc/intern/itasc/Armature.hpp
    branches/itasc/intern/itasc/ConstraintSet.hpp
    branches/itasc/intern/itasc/CopyPose.cpp
    branches/itasc/intern/itasc/CopyPose.hpp
    branches/itasc/intern/itasc/Distance.cpp
    branches/itasc/intern/itasc/Distance.hpp
    branches/itasc/intern/itasc/FixedObject.hpp
    branches/itasc/intern/itasc/MovingFrame.cpp
    branches/itasc/intern/itasc/MovingFrame.hpp
    branches/itasc/intern/itasc/Object.hpp
    branches/itasc/intern/itasc/Scene.cpp
    branches/itasc/intern/itasc/Scene.hpp
    branches/itasc/intern/itasc/WorldObject.hpp
    branches/itasc/release/ui/buttons_data_bone.py
    branches/itasc/source/blender/blenkernel/BKE_action.h
    branches/itasc/source/blender/blenkernel/intern/action.c
    branches/itasc/source/blender/blenloader/intern/readfile.c
    branches/itasc/source/blender/blenloader/intern/writefile.c
    branches/itasc/source/blender/ikplugin/BIK_api.h
    branches/itasc/source/blender/ikplugin/intern/ikplugin_api.c
    branches/itasc/source/blender/ikplugin/intern/ikplugin_api.h
    branches/itasc/source/blender/ikplugin/intern/itasc_plugin.cpp
    branches/itasc/source/blender/ikplugin/intern/itasc_plugin.h
    branches/itasc/source/blender/makesdna/DNA_action_types.h
    branches/itasc/source/blender/makesrna/intern/rna_pose.c

Modified: branches/itasc/intern/itasc/Armature.cpp
===================================================================
--- branches/itasc/intern/itasc/Armature.cpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/Armature.cpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -350,6 +350,14 @@
 	m_finalized = true;
 }
 
+void Armature::pushCache(const Timestamp& timestamp)
+{
+	if (!timestamp.substep && timestamp.cache) {
+		pushQ(timestamp.cacheTimestamp);
+		pushConstraints(timestamp.cacheTimestamp);
+	}
+}
+
 void Armature::updateKinematics(const Timestamp& timestamp){
 
     //TODO: what about the timestep?
@@ -385,12 +393,7 @@
 		}
 		q_nr += joint.ndof;
 	}
-
-	if (!timestamp.substep && timestamp.cache) {
-		pushQ(timestamp.cacheTimestamp);
-		pushConstraints(timestamp.cacheTimestamp);
-	}
-
+	pushCache(timestamp);
 	updateJacobian();
 	// here update the desired output.
 	// We assume constant desired output for the joint limit constraint, no need to update it.

Modified: branches/itasc/intern/itasc/Armature.hpp
===================================================================
--- branches/itasc/intern/itasc/Armature.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/Armature.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -36,6 +36,7 @@
 	virtual int addEndEffector(const std::string& name);
 	virtual const Frame& getPose(const unsigned int end_effector);
     virtual void updateKinematics(const Timestamp& timestamp);
+    virtual void pushCache(const Timestamp& timestamp);
     virtual void updateControlOutput(const Timestamp& timestamp);
 	virtual bool setControlParameter(unsigned int constraintId, unsigned int valueId, ConstraintAction action, double value, double timestep);
 	virtual void initCache(Cache *_cache);

Modified: branches/itasc/intern/itasc/ConstraintSet.hpp
===================================================================
--- branches/itasc/intern/itasc/ConstraintSet.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/ConstraintSet.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -69,6 +69,7 @@
 	friend class Scene;
 	virtual void modelUpdate(KDL::Frame& _external_pose,const Timestamp& timestamp);
     virtual void updateKinematics(const Timestamp& timestamp)=0;
+    virtual void pushCache(const Timestamp& timestamp)=0;
     virtual void updateJacobian()=0;
     virtual void updateControlOutput(const Timestamp& timestamp)=0;
 	virtual void initCache(Cache *_cache) = 0;

Modified: branches/itasc/intern/itasc/CopyPose.cpp
===================================================================
--- branches/itasc/intern/itasc/CopyPose.cpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/CopyPose.cpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -261,6 +261,12 @@
 	}
 }
 
+void CopyPose::pushCache(const Timestamp& timestamp)
+{
+	if (!timestamp.substep && timestamp.cache) {
+        pushPose(timestamp.cacheTimestamp);
+	}
+}
 
 void CopyPose::updateKinematics(const Timestamp& timestamp)
 {
@@ -268,9 +274,7 @@
 		interpolateOutput(&m_pos, CTL_POSITIONX, timestamp);
 	if (m_outputDynamic & CTL_ROTATION)
 		interpolateOutput(&m_rot, CTL_ROTATIONX, timestamp);
-	if (!timestamp.substep && timestamp.cache) {
-        pushPose(timestamp.cacheTimestamp);
-	}
+	pushCache(timestamp);
 }
 
 void CopyPose::updateJacobian()

Modified: branches/itasc/intern/itasc/CopyPose.hpp
===================================================================
--- branches/itasc/intern/itasc/CopyPose.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/CopyPose.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -17,6 +17,7 @@
 {
 protected:
     virtual void updateKinematics(const Timestamp& timestamp);
+    virtual void pushCache(const Timestamp& timestamp);
     virtual void updateJacobian();
     virtual bool initialise(Frame& init_pose);
     virtual void initCache(Cache *_cache);

Modified: branches/itasc/intern/itasc/Distance.cpp
===================================================================
--- branches/itasc/intern/itasc/Distance.cpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/Distance.cpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -160,6 +160,12 @@
 	return true;
 }
 
+void Distance::pushCache(const Timestamp& timestamp)
+{
+	if (!timestamp.substep && timestamp.cache)
+		pushDist(timestamp.cacheTimestamp);
+}
+
 void Distance::updateKinematics(const Timestamp& timestamp)
 {
 	//the internal pose and Jf is already up to date (see model_update)
@@ -171,9 +177,8 @@
 	} else {
 		m_yd = m_nextyd;
 		m_yddot = m_nextyddot;
-		if (timestamp.cache)
-			pushDist(timestamp.cacheTimestamp);
 	}
+	pushCache(timestamp);
 }
 
 void Distance::updateJacobian()

Modified: branches/itasc/intern/itasc/Distance.hpp
===================================================================
--- branches/itasc/intern/itasc/Distance.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/Distance.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -20,6 +20,7 @@
 {
 protected:
     virtual void updateKinematics(const Timestamp& timestamp);
+    virtual void pushCache(const Timestamp& timestamp);
     virtual void updateJacobian();
     virtual bool initialise(Frame& init_pose);
 	virtual void initCache(Cache *_cache);

Modified: branches/itasc/intern/itasc/FixedObject.hpp
===================================================================
--- branches/itasc/intern/itasc/FixedObject.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/FixedObject.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -26,6 +26,7 @@
 	virtual void finalize();
 	virtual const Frame& getPose(const unsigned int frameIndex);
 	virtual void updateKinematics(const Timestamp& timestamp) {};
+	virtual void pushCache(const Timestamp& timestamp) {};
 	virtual void initCache(Cache *_cache) {};
 
 protected:

Modified: branches/itasc/intern/itasc/MovingFrame.cpp
===================================================================
--- branches/itasc/intern/itasc/MovingFrame.cpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/MovingFrame.cpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -114,6 +114,12 @@
 	}
 }
 
+void MovingFrame::pushCache(const Timestamp& timestamp)
+{
+	if (!timestamp.substep && timestamp.cache)
+		pushInternalFrame(timestamp.cacheTimestamp);
+}
+
 void MovingFrame::updateKinematics(const Timestamp& timestamp)
 {
 	if (timestamp.substep) {
@@ -122,9 +128,8 @@
 		m_internalPose.Integrate(localvel, 1.0/timestamp.realTimestep);
 	} else {
 		m_internalPose = m_nextPose;
-		if (timestamp.cache)
-			pushInternalFrame(timestamp.cacheTimestamp);
 	}
+	pushCache(timestamp);
 	// m_internalPose is updated, recompute the jacobian
 	updateJacobian();
 }

Modified: branches/itasc/intern/itasc/MovingFrame.hpp
===================================================================
--- branches/itasc/intern/itasc/MovingFrame.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/MovingFrame.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -26,6 +26,7 @@
 
 	virtual void updateCoordinates(const Timestamp& timestamp);
 	virtual void updateKinematics(const Timestamp& timestamp);
+    virtual void pushCache(const Timestamp& timestamp);
 	virtual void initCache(Cache *_cache);
 	virtual void finalize();
 protected:

Modified: branches/itasc/intern/itasc/Object.hpp
===================================================================
--- branches/itasc/intern/itasc/Object.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/Object.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -37,6 +37,7 @@
     virtual const ObjectType getType(){return m_type;};
     virtual const unsigned int getNrOfCoordinates(){return 0;};
     virtual void updateKinematics(const Timestamp& timestamp)=0;
+    virtual void pushCache(const Timestamp& timestamp)=0;
 	virtual void initCache(Cache *_cache) = 0;
 
 };

Modified: branches/itasc/intern/itasc/Scene.cpp
===================================================================
--- branches/itasc/intern/itasc/Scene.cpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/Scene.cpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -30,6 +30,7 @@
 	m_solver(NULL),m_cache(NULL) 
 {
 	m_minstep = 0.01;
+	m_maxstep = 0.06;
 }
 
 Scene::~Scene() 
@@ -47,6 +48,20 @@
 	}
 }
 
+bool Scene::setParam(SceneParam paramId, double value)
+{
+	switch (paramId) {
+	case MIN_TIMESTEP:
+		m_minstep = value;
+		break;
+	case MAX_TIMESTEP:		
+		m_maxstep = value;
+		break;
+	default:
+		return false;
+	}
+	return true;
+}
 
 bool Scene::addObject(const std::string& name, Object* object, UncontrolledObject* base, const std::string& baseFrame)
 {
@@ -213,7 +228,7 @@
 bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache)
 {
 	// we must have valid timestep and timestamp
-	if (timestamp < KDL::epsilon || timestep < KDL::epsilon)
+	if (timestamp < KDL::epsilon || timestep < 0.0)
 		return false;
 	Timestamp ts;
 	ts.realTimestamp = timestamp;
@@ -230,6 +245,19 @@
 		numsubstep = 1;
 	double timesubstep = timestep/numsubstep;
 	double timeleft = timestep;
+
+	if (timeleft == 0.0) {
+		// this special case correspond to a request to cache data
+		for(ObjectMap::iterator it=objects.begin();it!=objects.end();++it){
+			it->second->object->pushCache(ts);
+		}
+		//Update the Constraints
+		for(ConstraintMap::iterator it=constraints.begin();it!=constraints.end();++it){
+			it->second->task->pushCache(ts);
+		}
+		return true;
+	}
+
 	double maxqdot;
 	e_scalar nlcoef;
 	// initially we keep timestep unchanged so that update function compute the velocity over
@@ -386,7 +414,7 @@
 			timesubstep = timeleft;
 			// get armature max joint velocity to estimate the maximum duration of integration
 			maxqdot = m_qdot.cwise().abs().maxCoeff();
-			double maxsubstep = nlcoef*0.1;
+			double maxsubstep = nlcoef*m_maxstep;
 			if (maxsubstep < m_minstep)
 				maxsubstep = m_minstep;
 			if (timesubstep > maxsubstep)

Modified: branches/itasc/intern/itasc/Scene.hpp
===================================================================
--- branches/itasc/intern/itasc/Scene.hpp	2009-07-16 20:10:33 UTC (rev 21634)
+++ branches/itasc/intern/itasc/Scene.hpp	2009-07-16 21:16:31 UTC (rev 21635)
@@ -20,9 +20,16 @@
 
 class Scene {
 
+public:
+	enum SceneParam {
+		MIN_TIMESTEP	= 0,
+		MAX_TIMESTEP,
 
-public:
-    Scene();
+		COUNT
+	};
+
+
+	Scene();
     virtual ~Scene();
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list