00001 //part of the source code of master thesis, source code produced by Jiri Divis 00008 #ifndef VO_G2O_TYPE_VERTEX_POINT_H_ 00009 #define VO_G2O_TYPE_VERTEX_POINT_H_ 00010 00011 #include <g2o/core/base_vertex.h> 00012 #include <iostream> 00013 00014 00015 namespace vslam{ 00016 namespace g2o_types{ 00017 using Eigen::Vector3d; 00018 00027 template<class PoseGraphT> class VertexPointXYZ : public g2o::BaseVertex<3, Vector3d> 00028 { 00029 protected: 00030 int pointds_idx; 00031 Points<PoseGraphT>* points; 00032 bool initialized; 00033 00034 public: 00035 EIGEN_MAKE_ALIGNED_OPERATOR_NEW; 00036 00037 bool save_state; 00038 00039 VertexPointXYZ(int _points_idx, Points<PoseGraphT> & _points) : 00040 pointds_idx(_points_idx), initialized(true) { 00041 points=&_points; 00042 } 00043 00045 VertexPointXYZ() : points(NULL), initialized(false) {} 00046 00047 virtual void setToOriginImpl() { 00048 _estimate = Vector3d::Zero(); 00049 } 00050 00055 00056 virtual bool read(std::istream& is) { assert(false); return true; } 00057 virtual bool write(std::ostream& os) const { 00058 os << _estimate.transpose(); 00059 return os.good(); 00060 } 00062 00063 virtual void oplusImpl(const double* update) { 00064 Eigen::Map<const Vector3d> increment(update); 00065 _estimate += increment; 00066 } 00067 00068 00073 virtual ~VertexPointXYZ(){ 00074 //if((points->getPoint(pointds_idx).global-_estimate).norm() > 1.0){ 00075 if(save_state){ 00076 assert(initialized); 00077 points->lmEstimateUpd(pointds_idx, _estimate); 00078 } 00079 //} 00080 } 00081 }; 00082 } 00083 }//namespace vslam 00084 #endif