| 
									
										
										
										
											2010-01-17 02:01:16 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  *  @file  pose2SLAM.cpp | 
					
						
							|  |  |  |  *  @brief: bearing/range measurements in 2D plane | 
					
						
							|  |  |  |  *  @authors Frank Dellaert | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "pose2SLAM.h"
 | 
					
						
							|  |  |  | #include "LieConfig-inl.h"
 | 
					
						
							|  |  |  | #include "NonlinearFactorGraph-inl.h"
 | 
					
						
							|  |  |  | #include "NonlinearOptimizer-inl.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Use pose2SLAM namespace for specific SLAM instance
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	using namespace pose2SLAM; | 
					
						
							|  |  |  | 	INSTANTIATE_LIE_CONFIG(Key, Pose2) | 
					
						
							|  |  |  | 	INSTANTIATE_NONLINEAR_FACTOR_GRAPH(Config) | 
					
						
							|  |  |  | 	INSTANTIATE_NONLINEAR_OPTIMIZER(Graph, Config) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	namespace pose2SLAM { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* ************************************************************************* */ | 
					
						
							|  |  |  | 		Config circle(size_t n, double R) { | 
					
						
							|  |  |  | 			Config x; | 
					
						
							|  |  |  | 			double theta = 0, dtheta = 2 * M_PI / n; | 
					
						
							|  |  |  | 			for (size_t i = 0; i < n; i++, theta += dtheta) | 
					
						
							|  |  |  | 				x.insert(i, Pose2(cos(theta), sin(theta), M_PI_2 + theta)); | 
					
						
							|  |  |  | 			return x; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-01-18 13:38:53 +08:00
										 |  |  | 		void Graph::addPrior(const Key& i, const Pose2& p, | 
					
						
							| 
									
										
										
										
											2010-01-23 01:36:57 +08:00
										 |  |  | 				const SharedGaussian& model) { | 
					
						
							| 
									
										
										
										
											2010-01-18 13:38:53 +08:00
										 |  |  | 			sharedFactor factor(new Prior(i, p, model)); | 
					
						
							| 
									
										
										
										
											2010-01-17 02:01:16 +08:00
										 |  |  | 			push_back(factor); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-18 13:38:53 +08:00
										 |  |  | 		void Graph::addConstraint(const Key& i, const Key& j, const Pose2& z, | 
					
						
							| 
									
										
										
										
											2010-01-23 01:36:57 +08:00
										 |  |  | 				const SharedGaussian& model) { | 
					
						
							| 
									
										
										
										
											2010-01-18 13:38:53 +08:00
										 |  |  | 			sharedFactor factor(new Constraint(i, j, z, model)); | 
					
						
							| 
									
										
										
										
											2010-01-17 02:01:16 +08:00
										 |  |  | 			push_back(factor); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-17 03:37:17 +08:00
										 |  |  | 		void Graph::addHardConstraint(const Key& i, const Pose2& p) { | 
					
						
							|  |  |  | 			sharedFactor factor(new HardConstraint(i, p)); | 
					
						
							| 
									
										
										
										
											2010-01-17 02:01:16 +08:00
										 |  |  | 			push_back(factor); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-01-17 03:37:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-17 02:01:16 +08:00
										 |  |  | 	/* ************************************************************************* */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	} // pose2SLAM
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // gtsam
 |