diff --git a/cpp/ISAM2-inl.h b/cpp/ISAM2-inl.h index 3f869ffc3..708424c44 100644 --- a/cpp/ISAM2-inl.h +++ b/cpp/ISAM2-inl.h @@ -119,16 +119,8 @@ namespace gtsam { void ISAM2::update_internal(const NonlinearFactorGraph& newFactors, const Config& config, Cliques& orphans) { -#if 0 // todo - temporarily disabled -------------------------------------------------------------------------------------------------- - // copy variables into config_, but don't overwrite existing entries (current linearization point!) - for (typename Config::const_iterator it = config.begin(); it!=config.end(); it++) { - if (!linPoint_.contains(it->first)) { - linPoint_.insert(it->first, it->second); - } - } -#else - linPoint_ = config; -#endif + // add new variables + linPoint_.insert(config); FactorGraph newFactorsLinearized = newFactors.linearize(linPoint_); diff --git a/cpp/ISAM2.h b/cpp/ISAM2.h index f01f55ff8..13b1aed6a 100644 --- a/cpp/ISAM2.h +++ b/cpp/ISAM2.h @@ -65,9 +65,11 @@ namespace gtsam { void update_internal(const NonlinearFactorGraph& newFactors, const Config& config, Cliques& orphans); void update(const NonlinearFactorGraph& newFactors, const Config& config); - const Config estimate() {return expmap(linPoint_, delta_);} + const Config estimate() const {return expmap(linPoint_, delta_);} + const Config linearizationPoint() const {return linPoint_;} private: + FactorGraph relinearizeAffectedFactors(const std::list& affectedKeys); FactorGraph getCachedBoundaryFactors(Cliques& orphans); diff --git a/cpp/TupleConfig-inl.h b/cpp/TupleConfig-inl.h index 8e92a4c71..7532bcf9e 100644 --- a/cpp/TupleConfig-inl.h +++ b/cpp/TupleConfig-inl.h @@ -25,4 +25,14 @@ namespace gtsam { second.print(s + "Config2: "); } + template + void PairConfig::insert(const PairConfig& config) { + for (typename Config1::const_iterator it = config.first.begin(); it!=config.first.end(); it++) { + insert(it->first, it->second); + } + for (typename Config2::const_iterator it = config.second.begin(); it!=config.second.end(); it++) { + insert(it->first, it->second); + } + } + } diff --git a/cpp/TupleConfig.h b/cpp/TupleConfig.h index d28fd4f23..5f6195813 100644 --- a/cpp/TupleConfig.h +++ b/cpp/TupleConfig.h @@ -107,6 +107,8 @@ namespace gtsam { void insert(const J1& j, const X1& value) { insert_helper(first, j, value); } void insert(const J2& j, const X2& value) { insert_helper(second, j, value); } + void insert(const PairConfig& config); + /** * Remove the variable with the given j. Throws invalid_argument if the * j is not present in the config. diff --git a/cpp/VectorConfig.cpp b/cpp/VectorConfig.cpp index e05d98d6a..1ec554a7e 100644 --- a/cpp/VectorConfig.cpp +++ b/cpp/VectorConfig.cpp @@ -41,6 +41,13 @@ VectorConfig& VectorConfig::insert(const Symbol& name, const Vector& val) { return *this; } +/* ************************************************************************* */ +void VectorConfig::insert(const VectorConfig& config) { + for (const_iterator it = config.begin(); it!=config.end(); it++) { + insert(it->first, it->second); + } +} + /* ************************************************************************* */ void VectorConfig::add(const Symbol& j, const Vector& a) { Vector& vj = values[j]; diff --git a/cpp/VectorConfig.h b/cpp/VectorConfig.h index bc70a510b..6fb3100d4 100644 --- a/cpp/VectorConfig.h +++ b/cpp/VectorConfig.h @@ -41,6 +41,9 @@ namespace gtsam { /** Insert a value into the configuration with a given index */ VectorConfig& insert(const Symbol& name, const Vector& val); + /** Insert a config into another config */ + void insert(const VectorConfig& config); + /** Add to vector at position j */ void add(const Symbol& j, const Vector& a);