| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file    GaussianISAM2 | 
					
						
							|  |  |  |  * @brief   Full non-linear ISAM | 
					
						
							|  |  |  |  * @author  Michael Kaess | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "GaussianISAM2.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace std; | 
					
						
							|  |  |  | using namespace gtsam; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Explicitly instantiate so we don't have to include everywhere
 | 
					
						
							|  |  |  | #include "ISAM2-inl.h"
 | 
					
						
							| 
									
										
										
										
											2010-01-18 16:05:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-29 22:54:45 +08:00
										 |  |  | //template class ISAM2<GaussianConditional, VectorConfig>;
 | 
					
						
							| 
									
										
										
										
											2010-01-18 16:05:33 +08:00
										 |  |  | //template class ISAM2<GaussianConditional, planarSLAM::Config>;
 | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  | void optimize2(const GaussianISAM2::sharedClique& clique, double threshold, VectorConfig& result) { | 
					
						
							|  |  |  | 	bool process_children = false; | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  | 	// parents are assumed to already be solved and available in result
 | 
					
						
							|  |  |  | 	GaussianISAM2::Clique::const_reverse_iterator it; | 
					
						
							|  |  |  | 	for (it = clique->rbegin(); it!=clique->rend(); it++) { | 
					
						
							|  |  |  | 		GaussianConditional::shared_ptr cg = *it; | 
					
						
							|  |  |  |     Vector x = cg->solve(result); // Solve for that variable
 | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  |     if (max(abs(x)) >= threshold) { | 
					
						
							|  |  |  |     	process_children = true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  |     result.insert(cg->key(), x);   // store result in partial solution
 | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  | 	if (process_children) { | 
					
						
							| 
									
										
										
										
											2010-02-17 11:29:12 +08:00
										 |  |  | 		BOOST_FOREACH(const GaussianISAM2::sharedClique& child, clique->children_) { | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  | 			optimize2(child, threshold, result); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  | VectorConfig optimize2(const GaussianISAM2& bayesTree, double threshold) { | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  | 	VectorConfig result; | 
					
						
							|  |  |  | 	// starting from the root, call optimize on each conditional
 | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  | 	optimize2(bayesTree.root(), threshold, result); | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  | 	return result; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-18 16:05:33 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  | VectorConfig optimize2(const GaussianISAM2_P& bayesTree, double threshold) { | 
					
						
							| 
									
										
										
										
											2010-01-18 16:05:33 +08:00
										 |  |  | 	VectorConfig result; | 
					
						
							|  |  |  | 	// starting from the root, call optimize on each conditional
 | 
					
						
							| 
									
										
										
										
											2010-01-21 15:38:37 +08:00
										 |  |  | 	optimize2(bayesTree.root(), threshold, result); | 
					
						
							| 
									
										
										
										
											2010-01-18 16:05:33 +08:00
										 |  |  | 	return result; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-29 13:57:05 +08:00
										 |  |  | } /// namespace gtsam
 |