00001 // g2o - General Graph Optimization 00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard 00003 // 00004 // g2o is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU Lesser General Public License as published 00006 // by the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // g2o is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 #ifndef _VERTEX_SE3_QUAT_ 00018 #define _VERTEX_SE3_QUAT_ 00019 00020 #include "g2o/config.h" 00021 #include "g2o/core/base_vertex.h" 00022 #include "g2o/core/base_binary_edge.h" 00023 #include "g2o/core/hyper_graph_action.h" 00024 #include "g2o/math_groups/se3quat.h" 00025 00026 namespace g2o { 00027 00033 class VertexSE3 : public BaseVertex<6, SE3Quat> 00034 { 00035 public: 00036 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00037 VertexSE3(); 00038 00039 virtual void setToOrigin() { 00040 _estimate = SE3Quat() ; 00041 } 00042 00043 virtual bool read(std::istream& is); 00044 virtual bool write(std::ostream& os) const; 00045 00046 00047 virtual bool setEstimateData(const double* est){ 00048 Vector7d v; 00049 for (int i=0; i<7; i++) 00050 v[i]=est[i]; 00051 _estimate.fromVector(v); 00052 return true; 00053 } 00054 00055 virtual bool getEstimateData(double* est) const{ 00056 Vector7d v=_estimate.toVector(); 00057 for (int i=0; i<7; i++) 00058 est[i] = v[i]; 00059 return true; 00060 } 00061 00062 virtual int estimateDimension() const { 00063 return 7; 00064 } 00065 00066 virtual bool setMinimalEstimateData(const double* est){ 00067 Map<const Vector6d> v(est); 00068 _estimate.fromMinimalVector(v); 00069 return true; 00070 } 00071 00072 virtual bool getMinimalEstimateData(double* est) const{ 00073 Map<Vector6d> v(est); 00074 v = _estimate.toMinimalVector(); 00075 return true; 00076 } 00077 00078 virtual int minimalEstimateDimension() const { 00079 return 6; 00080 } 00081 00082 virtual void oplus(double* update) 00083 { 00084 Map<Vector6d> v(update); 00085 SE3Quat increment(v); 00086 _estimate *= increment; 00087 } 00088 }; 00089 00090 class VertexSE3WriteGnuplotAction: public WriteGnuplotAction { 00091 public: 00092 VertexSE3WriteGnuplotAction(); 00093 virtual HyperGraphElementAction* operator()(HyperGraph::HyperGraphElement* element, 00094 HyperGraphElementAction::Parameters* params_ ); 00095 }; 00096 00097 #ifdef G2O_HAVE_OPENGL 00098 class VertexSE3DrawAction: public DrawAction{ 00099 public: 00100 VertexSE3DrawAction(); 00101 virtual HyperGraphElementAction* operator()(HyperGraph::HyperGraphElement* element, 00102 HyperGraphElementAction::Parameters* params_ ); 00103 }; 00104 #endif 00105 00106 } // end namespace 00107 00108 #endif