From 15fb7234e684d139872bd034da730dbbd89314ae Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Wed, 22 May 2013 17:27:43 +0000 Subject: [PATCH] Added check to prevent trying to add disconnected factors in iSAM1 --- gtsam/inference/ISAM-inl.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gtsam/inference/ISAM-inl.h b/gtsam/inference/ISAM-inl.h index 45031191b..4b5333f33 100644 --- a/gtsam/inference/ISAM-inl.h +++ b/gtsam/inference/ISAM-inl.h @@ -36,8 +36,14 @@ namespace gtsam { const FG& newFactors, Cliques& orphans, typename FG::Eliminate function) { // Remove the contaminated part of the Bayes tree + // Throw exception if disconnected BayesNet bn; - this->removeTop(newFactors.keys(), bn, orphans); + if (!this->empty()) { + this->removeTop(newFactors.keys(), bn, orphans); + if (bn.empty()) + throw std::runtime_error( + "ISAM::update_internal(): no variables in common between existing Bayes tree and incoming factors!"); + } FG factors(bn); // add the factors themselves