| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  *  @file  RangeFactor.H | 
					
						
							|  |  |  |  *  @authors Frank Dellaert | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/geometry/Pose2.h>
 | 
					
						
							|  |  |  | #include <gtsam/geometry/Point2.h>
 | 
					
						
							|  |  |  | #include <gtsam/nonlinear/NonlinearFactor.h>
 | 
					
						
							| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/**
 | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 	 * Binary factor for a range measurement | 
					
						
							| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | 	template<class Values, class PoseKey, class PointKey> | 
					
						
							|  |  |  | 	class RangeFactor: public NonlinearFactor2<Values, PoseKey, PointKey> { | 
					
						
							| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | 	private: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		double z_; /** measurement */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | 		typedef NonlinearFactor2<Values, PoseKey, PointKey> Base; | 
					
						
							| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		RangeFactor(); /* Default constructor */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 		RangeFactor(const PoseKey& i, const PointKey& j, double z, | 
					
						
							|  |  |  | 				const SharedGaussian& model) : | 
					
						
							|  |  |  | 					Base(model, i, j), z_(z) { | 
					
						
							| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** h(x)-z */ | 
					
						
							|  |  |  | 		Vector evaluateError(const Pose2& pose, const Point2& point, | 
					
						
							|  |  |  | 				boost::optional<Matrix&> H1, boost::optional<Matrix&> H2) const { | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 			double hx = pose.range(point, H1, H2); | 
					
						
							| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | 			return Vector_(1, hx - z_); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/** return the measured */ | 
					
						
							| 
									
										
										
										
											2010-05-27 01:32:19 +08:00
										 |  |  | 		inline double measured() const { | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 			return z_; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-01-14 14:00:17 +08:00
										 |  |  | 	}; // RangeFactor
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace gtsam
 |