g2o
base_binary_edge.h
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, H. Strasdat, 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_BASE_BINARY_EDGE_H
28 #define G2O_BASE_BINARY_EDGE_H
29 
30 #include <iostream>
31 #include <limits>
32 
33 #include "base_edge.h"
34 #include "robust_kernel.h"
35 #include "g2o/config.h"
36 
37 namespace g2o {
38 
39  template <int D, typename E, typename VertexXi, typename VertexXj>
40  class BaseBinaryEdge : public BaseEdge<D, E>
41  {
42  public:
43 
44  typedef VertexXi VertexXiType;
45  typedef VertexXj VertexXjType;
46 
47  static const int Di = VertexXiType::Dimension;
48  static const int Dj = VertexXjType::Dimension;
49 
52  typedef typename Eigen::Matrix<double, D, Di, D==1?Eigen::RowMajor:Eigen::ColMajor>::AlignedMapType JacobianXiOplusType;
53  typedef typename Eigen::Matrix<double, D, Dj, D==1?Eigen::RowMajor:Eigen::ColMajor>::AlignedMapType JacobianXjOplusType;
56 
57  typedef Eigen::Map<Eigen::Matrix<double, Di, Dj, Di==1?Eigen::RowMajor:Eigen::ColMajor>,
58  Eigen::Matrix<double, Di, Dj, Di==1?Eigen::RowMajor:Eigen::ColMajor>::Flags & Eigen::AlignedBit ? Eigen::Aligned : Eigen::Unaligned > HessianBlockType;
59  typedef Eigen::Map<Eigen::Matrix<double, Dj, Di, Dj==1?Eigen::RowMajor:Eigen::ColMajor>,
60  Eigen::Matrix<double, Dj, Di, Dj==1?Eigen::RowMajor:Eigen::ColMajor>::Flags & Eigen::AlignedBit ? Eigen::Aligned : Eigen::Unaligned > HessianBlockTransposedType;
61 
63  _hessianRowMajor(false),
64  _hessian(0, VertexXiType::Dimension, VertexXjType::Dimension), // HACK we map to the null pointer for initializing the Maps
65  _hessianTransposed(0, VertexXjType::Dimension, VertexXiType::Dimension),
66  _jacobianOplusXi(0, D, Di), _jacobianOplusXj(0, D, Dj)
67  {
68  _vertices.resize(2);
69  }
70 
73  virtual OptimizableGraph::Vertex* createVertex(int i);
74 
75  virtual void resize(size_t size);
76 
77  virtual bool allVerticesFixed() const;
78 
79  virtual void linearizeOplus(JacobianWorkspace& jacobianWorkspace);
80 
85  virtual void linearizeOplus();
86 
88  const JacobianXiOplusType& jacobianOplusXi() const { return _jacobianOplusXi;}
90  const JacobianXjOplusType& jacobianOplusXj() const { return _jacobianOplusXj;}
91 
92  virtual void constructQuadraticForm() ;
93 
94  virtual void mapHessianMemory(double* d, int i, int j, bool rowMajor);
95 
98 
99  protected:
102  using BaseEdge<D,E>::_error;
105 
107  HessianBlockType _hessian;
108  HessianBlockTransposedType _hessianTransposed;
109  JacobianXiOplusType _jacobianOplusXi;
110  JacobianXjOplusType _jacobianOplusXj;
111 
112  public:
113  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
114  };
115 
116 #include "base_binary_edge.hpp"
117 
118 } // end namespace g2o
119 
120 #endif
virtual OptimizableGraph::Vertex * createVertex(int i)
const JacobianXjOplusType & jacobianOplusXj() const
returns the result of the linearization in the manifold space for the node xj
Eigen::Matrix< double, D, Dj, D==1?Eigen::RowMajor:Eigen::ColMajor >::AlignedMapType JacobianXjOplusType
virtual void linearizeOplus()
static const int Dj
static const int Di
Eigen::Map< Eigen::Matrix< double, Di, Dj, Di==1?Eigen::RowMajor:Eigen::ColMajor >, Eigen::Matrix< double, Di, Dj, Di==1?Eigen::RowMajor:Eigen::ColMajor >::Flags &Eigen::AlignedBit?Eigen::Aligned:Eigen::Unaligned > HessianBlockType
virtual void constructQuadraticForm()
Eigen::Matrix< double, D, D, Eigen::ColMajor > InformationType
Definition: base_edge.h:47
BaseEdge< D, E >::ErrorVector ErrorVector
virtual OptimizableGraph::Vertex * createFrom()
BaseEdge< D, E >::Measurement Measurement
virtual bool allVerticesFixed() const
JacobianXiOplusType _jacobianOplusXi
Eigen::Matrix< double, D, 1, Eigen::ColMajor > ErrorVector
Definition: base_edge.h:46
Eigen::Matrix< double, D, Di, D==1?Eigen::RowMajor:Eigen::ColMajor >::AlignedMapType JacobianXiOplusType
static const int Dimension
Eigen::Map< Eigen::Matrix< double, Dj, Di, Dj==1?Eigen::RowMajor:Eigen::ColMajor >, Eigen::Matrix< double, Dj, Di, Dj==1?Eigen::RowMajor:Eigen::ColMajor >::Flags &Eigen::AlignedBit?Eigen::Aligned:Eigen::Unaligned > HessianBlockTransposedType
A general case Vertex for optimization.
virtual void resize(size_t size)
BaseEdge< D, E >::InformationType InformationType
virtual void mapHessianMemory(double *d, int i, int j, bool rowMajor)
HessianBlockTransposedType _hessianTransposed
JacobianXjOplusType _jacobianOplusXj
HessianBlockType _hessian
provide memory workspace for computing the Jacobians
const JacobianXiOplusType & jacobianOplusXi() const
returns the result of the linearization in the manifold space for the node xi
virtual OptimizableGraph::Vertex * createTo()
VertexContainer _vertices
Definition: hyper_graph.h:202