g2o
vertex_se3.h
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 #ifndef G2O_VERTEX_SE3_
28 #define G2O_VERTEX_SE3_
29 
30 #include "g2o/config.h"
31 #include "g2o/core/base_vertex.h"
33 #include "isometry3d_mappings.h"
34 #include "g2o_types_slam3d_api.h"
35 
36 namespace g2o {
37 
50  class G2O_TYPES_SLAM3D_API VertexSE3 : public BaseVertex<6, Isometry3D>
51  {
52  public:
54 
55  static const int orthogonalizeAfter = 1000; //< orthogonalize the rotation matrix after N updates
56 
57  VertexSE3();
58 
59  virtual void setToOriginImpl() {
60  _estimate = Isometry3D::Identity();
61  }
62 
63  virtual bool read(std::istream& is);
64  virtual bool write(std::ostream& os) const;
65 
66  virtual bool setEstimateDataImpl(const double* est){
67  Eigen::Map<const Vector7d> v(est);
68  _estimate=internal::fromVectorQT(v);
69  return true;
70  }
71 
72  virtual bool getEstimateData(double* est) const{
73  Eigen::Map<Vector7d> v(est);
74  v=internal::toVectorQT(_estimate);
75  return true;
76  }
77 
78  virtual int estimateDimension() const {
79  return 7;
80  }
81 
82  virtual bool setMinimalEstimateDataImpl(const double* est){
83  Eigen::Map<const Vector6d> v(est);
84  _estimate = internal::fromVectorMQT(v);
85  return true;
86  }
87 
88  virtual bool getMinimalEstimateData(double* est) const{
89  Eigen::Map<Vector6d> v(est);
90  v = internal::toVectorMQT(_estimate);
91  return true;
92  }
93 
94  virtual int minimalEstimateDimension() const {
95  return 6;
96  }
97 
105  virtual void oplusImpl(const double* update)
106  {
107  Eigen::Map<const Vector6d> v(update);
108  Isometry3D increment = internal::fromVectorMQT(v);
109  _estimate = _estimate * increment;
110  if (++_numOplusCalls > orthogonalizeAfter) {
111  _numOplusCalls = 0;
112  internal::approximateNearestOrthogonalMatrix(_estimate.matrix().topLeftCorner<3,3>());
113  }
114  }
115 
117  SE3Quat G2O_ATTRIBUTE_DEPRECATED(estimateAsSE3Quat() const) { return internal::toSE3Quat(estimate());}
119  void G2O_ATTRIBUTE_DEPRECATED(setEstimateFromSE3Quat(const SE3Quat& se3)) { setEstimate(internal::fromSE3Quat(se3));}
120 
121  protected:
123  };
124 
129  public:
131  virtual HyperGraphElementAction* operator()(HyperGraph::HyperGraphElement* element,
133  };
134 
135 #ifdef G2O_HAVE_OPENGL
136 
139  class G2O_TYPES_SLAM3D_API VertexSE3DrawAction: public DrawAction{
140  public:
141  VertexSE3DrawAction();
143  protected:
144  virtual bool refreshPropertyPtrs(HyperGraphElementAction::Parameters* params_);
145  FloatProperty* _triangleX, *_triangleY;
146  };
147 #endif
148 
149 } // end namespace
150 
151 #endif
Isometry3D fromVectorQT(const Vector7d &v)
Abstract action that operates on a graph entity.
virtual bool setMinimalEstimateDataImpl(const double *est)
Definition: vertex_se3.h:82
virtual bool setEstimateDataImpl(const double *est)
Definition: vertex_se3.h:66
Templatized BaseVertex.
Definition: base_vertex.h:50
SE3Quat toSE3Quat(const Isometry3D &t)
virtual void setToOriginImpl()
sets the node to the origin (used in the multilevel stuff)
Definition: vertex_se3.h:59
virtual bool getMinimalEstimateData(double *est) const
Definition: vertex_se3.h:88
#define G2O_TYPES_SLAM3D_API
Eigen::Transform< double, 3, Eigen::Isometry, Eigen::ColMajor > Isometry3D
Definition: eigen_types.h:66
Vector6d toVectorMQT(const Isometry3D &t)
write the vertex to some Gnuplot data file
Definition: vertex_se3.h:128
virtual int minimalEstimateDimension() const
Definition: vertex_se3.h:94
virtual bool getEstimateData(double *est) const
Definition: vertex_se3.h:72
void approximateNearestOrthogonalMatrix(const Eigen::MatrixBase< Derived > &R)
void G2O_ATTRIBUTE_DEPRECATED(setEstimateFromSE3Quat(const SE3Quat &se3))
wrapper function to use the old SE3 type
Definition: vertex_se3.h:119
virtual void oplusImpl(const double *update)
Definition: vertex_se3.h:105
3D pose Vertex, represented as an Isometry3D
Definition: vertex_se3.h:50
SE3Quat G2O_ATTRIBUTE_DEPRECATED(estimateAsSE3Quat() const)
wrapper function to use the old SE3 type
Definition: vertex_se3.h:117
int _numOplusCalls
store how often opluse was called to trigger orthogonaliation of the rotation matrix ...
Definition: vertex_se3.h:122
Vector7d toVectorQT(const Isometry3D &t)
Isometry3D fromVectorMQT(const Vector6d &v)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition: vertex_se3.h:53
virtual int estimateDimension() const
Definition: vertex_se3.h:78
Isometry3D fromSE3Quat(const SE3Quat &t)