From 92f284933d573504500c791ec064a246b97d9f79 Mon Sep 17 00:00:00 2001 From: Francois Bleibel <fbleibel@gmail.com> Date: Tue, 22 Jun 2010 14:30:28 +0900 Subject: [PATCH] More refactoring. Removed undertermination between sot::Pool and dynamicgraph::Pool in pool.cpp. Added cmake configure for import-default-paths. --- include/CMakeLists.txt | 4 ++-- include/sot-core/memory-task-sot.h | 4 ++-- include/sot-core/pool.h | 3 +-- include/sot-core/sot-h.h | 6 +++--- include/sot-core/task-abstract.h | 10 +++++----- src/factory/pool.cpp | 25 ++++++++----------------- src/sot/sot-h.cpp | 20 ++++++++++---------- 7 files changed, 31 insertions(+), 41 deletions(-) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 1a149b3d..013ccbdb 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -4,8 +4,8 @@ # Generate header with default script directory. SET(SOT_IMPORT_DEFAULT_PATHS \"${CMAKE_INSTALL_PREFIX}/script\") -CONFIGURE_FILE(sot-core/import-default-paths.h.cmake - sot-core/import-default-paths.h) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sot-core/import-default-paths.h.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/sot-core/import-default-paths.h) SET(${PROJECT_NAME}_HEADERS sot-core-api.h diff --git a/include/sot-core/memory-task-sot.h b/include/sot-core/memory-task-sot.h index 4897f793..26855d0b 100644 --- a/include/sot-core/memory-task-sot.h +++ b/include/sot-core/memory-task-sot.h @@ -47,7 +47,7 @@ namespace sot { class SOTSOT_CORE_EXPORT MemoryTaskSOT -: public TaskAbstract::sotMemoryTaskAbstract, public Entity +: public TaskAbstract::MemoryTaskAbstract, public Entity { public:// protected: /* Internal memory to reduce the dynamic allocation at task resolution. */ @@ -65,7 +65,7 @@ class SOTSOT_CORE_EXPORT MemoryTaskSOT public: /* mJ is the number of actuated joints, nJ the number of feature in the task, * and ffsize the number of unactuated DOF. */ - sotMemoryTaskSOT( const std::string & name,const unsigned int nJ=0, + MemoryTaskSOT( const std::string & name,const unsigned int nJ=0, const unsigned int mJ=0,const unsigned int ffsize =0 ); virtual void initMemory( const unsigned int nJ, diff --git a/include/sot-core/pool.h b/include/sot-core/pool.h index 7e67cf20..50a48bb2 100644 --- a/include/sot-core/pool.h +++ b/include/sot-core/pool.h @@ -138,8 +138,7 @@ class SOT_CORE_EXPORT PoolStorage void writeCompletionList(std::ostream& os); }; - -SOT_CORE_EXPORT extern PoolStorage sotPool; +SOT_CORE_EXPORT extern sot::PoolStorage sotPool; } // namespace sot diff --git a/include/sot-core/sot-h.h b/include/sot-core/sot-h.h index 359e1eaa..65ea9ff4 100644 --- a/include/sot-core/sot-h.h +++ b/include/sot-core/sot-h.h @@ -62,15 +62,15 @@ class SOTSOTH_EXPORT SotH virtual const std::string& getClassName( void ) const { return CLASS_NAME; } /* --- SPECIFIC MEM -------------------------------------------------- */ - class sotMemoryTaskSOTH - : public TaskAbstract::sotMemoryTaskAbstract,public Entity + class MemoryTaskSOTH + : public TaskAbstract::MemoryTaskAbstract,public Entity { public: const SotH * referenceKey; SolverHierarchicalInequalities solver; ml::Matrix JK,Jff,Jact; public: - sotMemoryTaskSOTH( const std::string & name, + MemoryTaskSOTH( const std::string & name, const SotH * ref, unsigned int nJ, sotRotationComposedInExtenso& Qh, diff --git a/include/sot-core/task-abstract.h b/include/sot-core/task-abstract.h index 445f88b5..95b1173c 100644 --- a/include/sot-core/task-abstract.h +++ b/include/sot-core/task-abstract.h @@ -53,25 +53,25 @@ class SOT_CORE_EXPORT TaskAbstract public: /* Use a derivative of this class to store computational memory. */ - class sotMemoryTaskAbstract + class MemoryTaskAbstract { public: int timeLastChange; public: - sotMemoryTaskAbstract( void ) : timeLastChange(0) {}; - virtual ~sotMemoryTaskAbstract( void ) {}; + MemoryTaskAbstract( void ) : timeLastChange(0) {}; + virtual ~MemoryTaskAbstract( void ) {}; public: virtual void commandLine( const std::string& cmdLine ,std::istringstream& cmdArgs ,std::ostream& os ) = 0; virtual void display( std::ostream& os ) const = 0; friend std::ostream& - operator<<( std::ostream& os,const sotMemoryTaskAbstract& tcm ) + operator<<( std::ostream& os,const MemoryTaskAbstract& tcm ) {tcm.display(os); return os;} }; public: - sotMemoryTaskAbstract * memoryInternal; + MemoryTaskAbstract * memoryInternal; protected: void taskRegistration( void ); diff --git a/src/factory/pool.cpp b/src/factory/pool.cpp index 0bc25dab..5d5e375b 100644 --- a/src/factory/pool.cpp +++ b/src/factory/pool.cpp @@ -21,16 +21,20 @@ /* --------------------------------------------------------------------- */ /* --- INCLUDE --------------------------------------------------------- */ /* --------------------------------------------------------------------- */ +#include <list> +#ifdef WIN32 +#include <time.h> +#endif /*WIN32*/ /* --- SOT --- */ #include <sot-core/pool.h> #include <sot-core/debug.h> #include <dynamic-graph/entity.h> -#include <list> +#include <sot-core/task-abstract.h> +#include <sot-core/feature-abstract.h> using namespace sot; - - +namespace sot { /* --------------------------------------------------------------------- */ /* --- CLASS ----------------------------------------------------------- */ /* --------------------------------------------------------------------- */ @@ -112,19 +116,6 @@ getFeature( const std::string& name ) return *entPtr->second; } - - - -/* --------------------------------------------------------------------- */ - -#include <dynamic-graph/entity.h> -#include <sot-core/task-abstract.h> -#include <sot-core/feature-abstract.h> - -#ifdef WIN32 -#include <time.h> -#endif /*WIN32*/ - void PoolStorage:: writeGraph(const std::string &aFileName) { @@ -248,6 +239,6 @@ commandLine( const std::string& objectName,const std::string& functionName, } /// The global sotPool object -namespace sot { + PoolStorage sotPool; } diff --git a/src/sot/sot-h.cpp b/src/sot/sot-h.cpp index 98525d96..cf53f0ab 100644 --- a/src/sot/sot-h.cpp +++ b/src/sot/sot-h.cpp @@ -76,8 +76,8 @@ defineNbDof( const unsigned int& nbDof ) Sot::defineNbDof(nbDof); for(StackType::iterator iter=stack.begin();stack.end()!=iter;++iter ) { - sotMemoryTaskSOTH * mem - = dynamic_cast<sotMemoryTaskSOTH *>( (*iter)->memoryInternal ); + MemoryTaskSOTH * mem + = dynamic_cast<MemoryTaskSOTH *>( (*iter)->memoryInternal ); if(NULL!=mem) mem->solver.setNbDof(nbDof); } solverNorm.setNbDof(nbDof-(ffJointIdLast-ffJointIdFirst)); @@ -270,11 +270,11 @@ computeControlLaw( ml::Vector& control,const int& iterTime ) unsigned int ntask=err.size(); sotDEBUG(25) << "/* Init memory. */" << std::endl; - sotMemoryTaskSOTH * mem = dynamic_cast<sotMemoryTaskSOTH *>( task.memoryInternal ); + MemoryTaskSOTH * mem = dynamic_cast<MemoryTaskSOTH *>( task.memoryInternal ); if( (NULL==mem)||(mem->referenceKey!=this) ) { if( NULL!=task.memoryInternal ) delete task.memoryInternal; - mem = new sotMemoryTaskSOTH(task.getName()+"_memSOTH", + mem = new MemoryTaskSOTH(task.getName()+"_memSOTH", this,nJ,Qh,Rh,constraintH); task.memoryInternal = mem; } @@ -373,7 +373,7 @@ computeControlLaw( ml::Vector& control,const int& iterTime ) for( StackType::iterator iter = stack.begin(); iter!=stack.end();++iter,++iterTask ) { TaskAbstract & task = **iter; - sotMemoryTaskSOTH * mem = dynamic_cast<sotMemoryTaskSOTH *>( task.memoryInternal ); + MemoryTaskSOTH * mem = dynamic_cast<MemoryTaskSOTH *>( task.memoryInternal ); if( mem == NULL ) continue; sotVectorMultiBound taskVector = task.taskSOUT(iterTime); const ml::Matrix JK = mem->jacobianConstrainedSINOUT.accessCopy(); @@ -408,21 +408,21 @@ computeControlLaw( ml::Vector& control,const int& iterTime ) /* --------------------------------------------------------------------- */ -const std::string SotH::sotMemoryTaskSOTH::CLASS_NAME = "MemoryTaskSOTH"; +const std::string SotH::MemoryTaskSOTH::CLASS_NAME = "MemoryTaskSOTH"; -void SotH::sotMemoryTaskSOTH:: +void SotH::MemoryTaskSOTH:: commandLine( const std::string& cmdLine,std::istringstream& cmdArgs, std::ostream& os ) { Entity::commandLine( cmdLine,cmdArgs,os ); } -void SotH::sotMemoryTaskSOTH:: +void SotH::MemoryTaskSOTH:: display( std::ostream& os ) const {} //TODO -SotH::sotMemoryTaskSOTH:: -sotMemoryTaskSOTH( const std::string & name, +SotH::MemoryTaskSOTH:: +MemoryTaskSOTH( const std::string & name, const SotH * ref, unsigned int nJ, sotRotationComposedInExtenso& Qh, -- GitLab