| 
									
										
										
										
											2010-01-12 10:10:42 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  *  @file  BearingFactor.H | 
					
						
							|  |  |  |  *  @authors Frank Dellaert | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Rot2.h"
 | 
					
						
							|  |  |  | #include "Pose2.h"
 | 
					
						
							|  |  |  | #include "Point2.h"
 | 
					
						
							| 
									
										
										
										
											2010-01-14 12:35:18 +08:00
										 |  |  | #include "NonlinearFactor.h"
 | 
					
						
							| 
									
										
										
										
											2010-01-12 10:10:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/**
 | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 	 * Binary factor for a bearing measurement | 
					
						
							| 
									
										
										
										
											2010-01-14 12:35:18 +08:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	template<class Config, class PoseKey, class PointKey> | 
					
						
							|  |  |  | 	class BearingFactor: public NonlinearFactor2<Config, PoseKey, Pose2, | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 	PointKey, Point2> { | 
					
						
							| 
									
										
										
										
											2010-01-14 12:35:18 +08:00
										 |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2010-01-12 10:10:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-14 12:35:18 +08:00
										 |  |  | 		Rot2 z_; /** measurement */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		typedef NonlinearFactor2<Config, PoseKey, Pose2, PointKey, Point2> Base; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BearingFactor(); /* Default constructor */ | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 		BearingFactor(const PoseKey& i, const PointKey& j, const Rot2& z, | 
					
						
							|  |  |  | 				const SharedGaussian& model) : | 
					
						
							|  |  |  | 					Base(model, i, j), z_(z) { | 
					
						
							| 
									
										
										
										
											2010-01-14 12:35:18 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** h(x)-z -> between(z,h(x)) for Rot2 manifold */ | 
					
						
							|  |  |  | 		Vector evaluateError(const Pose2& pose, const Point2& point, | 
					
						
							|  |  |  | 				boost::optional<Matrix&> H1, boost::optional<Matrix&> H2) const { | 
					
						
							|  |  |  | 			Rot2 hx = bearing(pose, point, H1, H2); | 
					
						
							|  |  |  | 			return logmap(between(z_, hx)); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-04-01 07:32:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/** return the measured */ | 
					
						
							|  |  |  | 		inline const Rot2 measured() const { | 
					
						
							|  |  |  | 			return z_; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-01-14 12:35:18 +08:00
										 |  |  | 	}; // BearingFactor
 | 
					
						
							| 
									
										
										
										
											2010-01-12 10:10:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace gtsam
 |