| 
									
										
										
										
											2009-11-11 04:19:00 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file    VSLAMGraph.h | 
					
						
							|  |  |  |  * @brief   A factor graph for the VSLAM problem | 
					
						
							|  |  |  |  * @author  Alireza Fathi | 
					
						
							|  |  |  |  * @author  Carlos Nieto | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include <map>
 | 
					
						
							|  |  |  | #include <set>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-11 06:49:22 +08:00
										 |  |  | #include "NonlinearFactorGraph.h"
 | 
					
						
							|  |  |  | #include "FactorGraph-inl.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-11 04:19:00 +08:00
										 |  |  | #include "VSLAMFactor.h"
 | 
					
						
							|  |  |  | #include "VSLAMConfig.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-17 09:19:55 +08:00
										 |  |  | #include "Testable.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-11 04:19:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-11 06:49:22 +08:00
										 |  |  | namespace gtsam{ | 
					
						
							| 
									
										
										
										
											2009-11-11 04:19:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Non-linear factor graph for visual SLAM | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-11-17 09:19:55 +08:00
										 |  |  | class VSLAMGraph : public gtsam::NonlinearFactorGraph<VSLAMConfig>, Testable<VSLAMGraph>{ | 
					
						
							| 
									
										
										
										
											2009-11-11 04:19:00 +08:00
										 |  |  | private: | 
					
						
							|  |  |  | 	int nFrames; | 
					
						
							|  |  |  | 	typedef map <int, int> feat_ids_type; | 
					
						
							|  |  |  | 	feat_ids_type feat_ids; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /** default constructor is empty graph */ | 
					
						
							|  |  |  |   VSLAMGraph() {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /**
 | 
					
						
							|  |  |  |    * Constructor that loads measurements from file | 
					
						
							|  |  |  |    * @param path to the file | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   VSLAMGraph(const std::string& path); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /**
 | 
					
						
							|  |  |  |    * print out graph | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   void print(const std::string& s = "") const { | 
					
						
							|  |  |  |     gtsam::NonlinearFactorGraph<VSLAMConfig>::print(s); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-17 09:19:55 +08:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * equals | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   bool equals(const VSLAMGraph&, double tol=1e-9) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-13 14:18:27 +08:00
										 |  |  |   // Getters
 | 
					
						
							| 
									
										
										
										
											2009-11-11 04:19:00 +08:00
										 |  |  |   int Get_nFrames(){return nFrames;}; | 
					
						
							|  |  |  |   int Get_nFeat_ids(){return feat_ids.size();}; | 
					
						
							|  |  |  |   feat_ids_type* Get_feat_ids_map(){return &feat_ids;}; | 
					
						
							| 
									
										
										
										
											2009-11-13 14:18:27 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /**
 | 
					
						
							|  |  |  |    *  Add a constraint on a landmark (for now, *must* be satisfied in any Config) | 
					
						
							|  |  |  |    *  @param j index of landmark | 
					
						
							|  |  |  |    *  @param p to which point to constrain it to | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   void addLandmarkConstraint(int j, const Point3& p = Point3()); | 
					
						
							| 
									
										
										
										
											2009-11-17 09:19:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-18 01:19:54 +08:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    *  Add a constraint on a camera (for now, *must* be satisfied in any Config) | 
					
						
							|  |  |  |    *  @param j index of camera | 
					
						
							|  |  |  |    *  @param p to which pose to constrain it to | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   void addCameraConstraint(int j, const Pose3& p = Pose3()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-17 09:19:55 +08:00
										 |  |  | private: | 
					
						
							|  |  |  | 	/** Serialization function */ | 
					
						
							|  |  |  | 	friend class boost::serialization::access; | 
					
						
							|  |  |  | 	template<class Archive> | 
					
						
							|  |  |  | 	void serialize(Archive & ar, const unsigned int version) { | 
					
						
							|  |  |  | 		ar & BOOST_SERIALIZATION_NVP(nFrames); | 
					
						
							|  |  |  | 		ar & BOOST_SERIALIZATION_NVP(feat_ids); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-11-11 04:19:00 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2009-11-11 06:49:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace gtsam
 |