diff --git a/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl b/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl index 1e41bd166ba7f97fe9e7f9bba3d716e2b713ac86..040ac241bd932e1f589fd855611979eff3b0290d 100755 --- a/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl +++ b/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl @@ -226,6 +226,17 @@ module hpp /// \return whether the configuration is quasi-statically balanced short isConfigBalanced(in floatSeq config, in Names_t contacts, in double robustnessTreshold) raises (Error); + /// run and store an analysis on all limb databases + /// \param analysis name of the analysis existing + /// \param isstatic 1 is becomes new static value of database, 0 otherwise + void runSampleAnalysis(in string analysis, in double isstatic) raises (Error); + + /// run and store an analysis on a limb database + /// \param limbname name of the limb to perform the analysis to + /// \param analysis name of the analysis existing + /// \param isstatic 1 is becomes new static value of database, 0 otherwise + void runLimbSampleAnalysis(in string limbname, in string analysis, in double isstatic) raises (Error); + }; // interface Robot }; // module rbprm }; // module corbaserver diff --git a/src/hpp/corbaserver/rbprm/rbprmfullbody.py b/src/hpp/corbaserver/rbprm/rbprmfullbody.py index b50ec3b2a1c730756d0e104a7d5a3252ba0a33a9..643f0471a169333453530118f8c0c65222df6323 100755 --- a/src/hpp/corbaserver/rbprm/rbprmfullbody.py +++ b/src/hpp/corbaserver/rbprm/rbprmfullbody.py @@ -213,6 +213,27 @@ class FullBody (object): else: return False + ## Updates limb databases with a user chosen computation + # + # \param analysis name of computation + # \param isstatic whether the computation should be used to sort samples by default + def runSampleAnalysis(self, analysis, isstatic): + isStatic = 0. + if(isstatic): + isStatic = 1. + self.client.rbprm.rbprm.runSampleAnalysis(analysis,isStatic) + + ## Updates a limb database with a user chosen computation + # + # \param limbname name of the limb chosen for computation + # \param analysis name of computation + # \param isstatic whether the computation should be used to sort samples by default + def runLimbSampleAnalysis(self, limbname, analysis, isstatic): + isStatic = 0. + if(isstatic): + isStatic = 1. + self.client.rbprm.rbprm.runLimbSampleAnalysis(limbname, analysis,isStatic) + ## Create octree nodes representation for a given limb # # \param gui gepetoo viewer instance discretization step diff --git a/src/rbprmbuilder.impl.cc b/src/rbprmbuilder.impl.cc index 545e8f224fbcbf578aa12e38e4aa6fc45adc6122..3ade6a7cdde7a1f9345d313e881ac69142981a5f 100755 --- a/src/rbprmbuilder.impl.cc +++ b/src/rbprmbuilder.impl.cc @@ -695,6 +695,56 @@ namespace hpp { } } + + void RbprmBuilder::runSampleAnalysis(const char* analysis, double isstatic) throw (hpp::Error) + { + try + { + std::string eval(analysis); + sampling::T_evaluate::const_iterator analysisit = analysisFactory_.evaluate_.find(std::string(eval)); + if(analysisit == analysisFactory_.evaluate_.end()) + { + std::string err("No analysis named " + eval + "was defined for analyzing database sample"); + throw Error (err.c_str()); + } + for(T_Limb::const_iterator cit = fullBody_->GetLimbs().begin(); cit !=fullBody_->GetLimbs().end();++cit) + { + sampling::SampleDB & sampleDB =const_cast<sampling::SampleDB &> (cit->second->sampleContainer_); + sampling::addValue(sampleDB, analysisit->first, analysisit->second, isstatic > 0.5, isstatic > 0.5); + } + } + catch(std::runtime_error& e) + { + throw Error(e.what()); + } + } + + void RbprmBuilder::runLimbSampleAnalysis(const char* limbname, const char* analysis, double isstatic) throw (hpp::Error) + { + try + { + std::string eval(analysis); + sampling::T_evaluate::const_iterator analysisit = analysisFactory_.evaluate_.find(std::string(eval)); + if(analysisit == analysisFactory_.evaluate_.end()) + { + std::string err("No analysis named " + eval + "was defined for analyzing database sample"); + throw Error (err.c_str()); + } + T_Limb::const_iterator lit = fullBody_->GetLimbs().find(std::string(limbname)); + if(lit == fullBody_->GetLimbs().end()) + { + std::string err("No limb " + std::string(limbname) + "was defined for robot" + fullBody_->device_->name()); + throw Error (err.c_str()); + } + sampling::SampleDB & sampleDB =const_cast<sampling::SampleDB &> (lit->second->sampleContainer_); + sampling::addValue(sampleDB, analysisit->first, analysisit->second, isstatic > 0.5, isstatic > 0.5); + } + catch(std::runtime_error& e) + { + throw Error(e.what()); + } + } + void RbprmBuilder::SetProblemSolver (hpp::core::ProblemSolverPtr_t problemSolver) { problemSolver_ = problemSolver; diff --git a/src/rbprmbuilder.impl.hh b/src/rbprmbuilder.impl.hh index 87777145170bd658b1401af82888c67086cf6344..27751b83a12024b63016eb3228a695bd46d060a6 100755 --- a/src/rbprmbuilder.impl.hh +++ b/src/rbprmbuilder.impl.hh @@ -24,6 +24,7 @@ # include <hpp/rbprm/rbprm-fullbody.hh> # include <hpp/rbprm/rbprm-shooter.hh> # include <hpp/rbprm/rbprm-validation.hh> +# include <hpp/rbprm/sampling/analysis.hh> # include <hpp/core/collision-path-validation-report.hh> # include <hpp/core/problem-solver.hh> # include <hpp/core/discretized-collision-checking.hh> @@ -123,6 +124,9 @@ namespace hpp { virtual hpp::floatSeqSeq* GetOctreeBoxes(const char* limbName, const hpp::floatSeq& configuration) throw (hpp::Error); virtual hpp::floatSeq* getOctreeTransform(const char* limbName, const hpp::floatSeq& configuration) throw (hpp::Error); virtual CORBA::Short isConfigBalanced(const hpp::floatSeq& config, const hpp::Names_t& contactLimbs, double robustnessTreshold) throw (hpp::Error); + virtual void runSampleAnalysis(const char* analysis, double isstatic) throw (hpp::Error); + virtual void runLimbSampleAnalysis(const char* limbname, const char* analysis, double isstatic) throw (hpp::Error); + public: void SetProblemSolver (hpp::core::ProblemSolverPtr_t problemSolver); @@ -139,6 +143,7 @@ namespace hpp { rbprm::State startState_; rbprm::State endState_; std::vector<rbprm::State> lastStatesComputed_; + sampling::AnalysisFactory analysisFactory_; }; // class RobotBuilder } // namespace impl } // namespace manipulation