Switch to vector for noise model caching
parent
7e462b997f
commit
44aaf9ad95
|
|
@ -190,24 +190,23 @@ GaussianFactorGraph::shared_ptr LevenbergMarquardtOptimizer::buildDampedSystem(
|
||||||
} else {
|
} else {
|
||||||
// Straightforward damping:
|
// Straightforward damping:
|
||||||
|
|
||||||
NoiseMap noises;
|
// initialize noise model cache to a reasonable default size
|
||||||
|
NoiseCacheVector noises(6);
|
||||||
BOOST_FOREACH(const Values::KeyValuePair& key_value, state_.values) {
|
BOOST_FOREACH(const Values::KeyValuePair& key_value, state_.values) {
|
||||||
size_t dim = key_value.value.dim();
|
size_t dim = key_value.value.dim();
|
||||||
|
|
||||||
// Check if noise model of appropriate size already exists, else create it and cache it!
|
if (dim > noises.size())
|
||||||
NoiseMap::iterator it = noises.find(dim);
|
noises.resize(dim);
|
||||||
if(it == noises.end()) {
|
|
||||||
NoiseCacheItem item;
|
NoiseCacheItem& item = noises[dim-1];
|
||||||
|
|
||||||
|
// Initialize noise model, A and b if we haven't done so already
|
||||||
|
if(!item.model) {
|
||||||
item.A = Matrix::Identity(dim, dim);
|
item.A = Matrix::Identity(dim, dim);
|
||||||
item.b = Vector::Zero(dim);
|
item.b = Vector::Zero(dim);
|
||||||
item.model = noiseModel::Isotropic::Sigma(dim, sigma);
|
item.model = noiseModel::Isotropic::Sigma(dim, sigma);
|
||||||
noises[dim] = item;
|
|
||||||
damped += boost::make_shared<JacobianFactor>(key_value.key, item.A, item.b, item.model);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
const NoiseCacheItem& item = it->second;
|
|
||||||
damped += boost::make_shared<JacobianFactor>(key_value.key, item.A, item.b, item.model);
|
|
||||||
}
|
}
|
||||||
|
damped += boost::make_shared<JacobianFactor>(key_value.key, item.A, item.b, item.model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gttoc(damp);
|
gttoc(damp);
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Noise model Cache
|
/// Noise model Cache
|
||||||
typedef std::map<size_t, NoiseCacheItem> NoiseMap;
|
typedef std::vector<NoiseCacheItem> NoiseCacheVector;
|
||||||
|
|
||||||
void writeLogFile(double currentError);
|
void writeLogFile(double currentError);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue