icp_chain_creation.h
Go to the documentation of this file.
00001 #ifndef __ICP_CHAIN_CREATION_H
00002 #define __ICP_CHAIN_CREATION_H
00003 
00004 #include <limits>
00005 #include <boost/format.hpp>
00006 #include "aliases.h"
00007 
00008 template<typename R>
00009 typename R::TargetType* initModuleFromRegistrar(const std::string& root, const R& registrar)
00010 {
00011         typedef typename R::ClassDescriptor ClassDescriptor;
00012         typedef PointMatcherSupport::Parametrizable::ParameterDoc ParameterDoc;
00013         typedef PointMatcherSupport::Parametrizable::Parameters Parameters;
00014         typedef PointMatcherSupport::Parametrizable::ParametersDoc::const_iterator cIter;
00015         typedef PointMatcherSupport::Parametrizable::ParametersDoc ParametersDoc;
00016         
00017         const std::string name(getParam<std::string>(root+"/name"));
00018         
00019         const ClassDescriptor* desc(registrar.getDescriptor(name));
00020         Parameters params;
00021         PointMatcherSupport::Parametrizable::ParametersDoc paramVec = desc->availableParameters();
00022 
00023         auto paramsDoc = desc->availableParameters();
00024 
00025         // NOTE: the line above is doing segFault with doc(*it)...
00026         //for (auto it = desc->availableParameters().cbegin(); it != desc->availableParameters().cend(); ++it)
00027         for (auto it = paramsDoc.cbegin(); it != paramsDoc.cend(); ++it)
00028         {
00029                 // TODO: for each parameter available in the register, try to look if this parameter is available
00030                 
00031                 const ParameterDoc doc(*it);
00032 
00033                 const std::string paramLocation(root+"/"+doc.name);
00034                 
00035                 if (hasParam(paramLocation))
00036                         params[doc.name] = getParam<std::string>(paramLocation, doc.defaultValue);
00037         }
00038         return desc->createInstance(params);
00039 }
00040 
00041 template<typename R>
00042 void initModulesFromRegistrar(const std::string& paramNamespace, const R& registrar, PointMatcherSupport::SharedPtrVector<typename R::TargetType>& modules)
00043 {
00044         const int count(getParam<int>(paramNamespace + "Count", 0));
00045         for (int i = 0; i < count; ++i)
00046         {
00047                 const std::string root((boost::format("%1%/%2%") % paramNamespace % i).str());
00048                 modules.push_back(initModuleFromRegistrar(root, registrar));
00049         }
00050 }
00051 
00052 void populateParametersBase(PM::ICPChainBase& icp)
00053 {
00054         // icp parameters
00055         PM pm;
00056         
00057         initModulesFromRegistrar("readingDataPointsFilters", pm.REG(DataPointsFilter), icp.readingDataPointsFilters);
00058         //initModulesFromRegistrar("readingStepDataPointsFilters", pm.REG(DataPointsFilter), icp.readingStepDataPointsFilters);
00059         initModulesFromRegistrar("keyframeDataPointsFilters", pm.REG(DataPointsFilter), icp.keyframeDataPointsFilters);
00060         initModulesFromRegistrar("transformations", pm.REG(Transformation), icp.transformations);
00061         icp.matcher.reset(initModuleFromRegistrar("matcher", pm.REG(Matcher)));
00062         initModulesFromRegistrar("outlierFilters", pm.REG(OutlierFilter), icp.outlierFilters);
00063         icp.errorMinimizer.reset(initModuleFromRegistrar("errorMinimizer", pm.REG(ErrorMinimizer)));
00064         initModulesFromRegistrar("transformationCheckers", pm.REG(TransformationChecker), icp.transformationCheckers);
00065         icp.inspector.reset(initModuleFromRegistrar("inspector", pm.REG(Inspector)));
00066         PointMatcherSupport::setLogger(initModuleFromRegistrar("logger", pm.REG(Logger)));
00067         // FIXME: consistency check?
00068 }
00069 
00070 void populateParameters(PM::ICPSequence& icp)
00071 {
00072         icp.ratioToSwitchKeyframe = getParam("ratioToSwitchKeyframe", 0.8);
00073         
00074         populateParametersBase(icp);
00075 }
00076 
00077 #endif // __ICP_CHAIN_CREATION_H


ethzasl_icp_mapper_experiments
Author(s): François Pomerleau and Stéphane Magnenat
autogenerated on Mon Oct 6 2014 10:28:30