g2o
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
g2o::BaseFixedSizedEdge< D, E, VertexTypes > Class Template Reference

#include <base_fixed_sized_edge.h>

Inheritance diagram for g2o::BaseFixedSizedEdge< D, E, VertexTypes >:
Inheritance graph
[legend]
Collaboration diagram for g2o::BaseFixedSizedEdge< D, E, VertexTypes >:
Collaboration graph
[legend]

Classes

struct  HessianTupleType
 
struct  HessianTupleType< std::index_sequence< Ints... > >
 

Public Types

template<int N, typename... Types>
using NthType = typename std::tuple_element< N, std::tuple< Types... > >::type
 
template<int VertexN>
using VertexXnType = NthType< VertexN, VertexTypes... >
 The type of the N-th vertex.
 
typedef BaseEdge< D, E >::Measurement Measurement
 
typedef BaseEdge< D, E >::ErrorVector ErrorVector
 
typedef BaseEdge< D, E >::InformationType InformationType
 
template<int EdgeDimension, int VertexDimension>
using JacobianType = typename Eigen::Matrix< double, EdgeDimension, VertexDimension, EdgeDimension==1 ? Eigen::RowMajor :Eigen::ColMajor >::AlignedMapType
 
template<int DN, int DM>
using HessianBlockType = Eigen::Map< Eigen::Matrix< double, DN, DM, DN==1 ? Eigen::RowMajor :Eigen::ColMajor >, Eigen::Matrix< double, DN, DM, DN==1 ? Eigen::RowMajor :Eigen::ColMajor >::Flags &Eigen::PacketAccessBit ? Eigen::Aligned :Eigen::Unaligned >
 it requires quite some ugly code to get the type of hessians...
 
template<int K>
using HessianBlockTypeK = HessianBlockType< VertexXnType< internal::index_to_pair(K).first >::Dimension, VertexXnType< internal::index_to_pair(K).second >::Dimension >
 
template<int K>
using HessianBlockTypeKTransposed = HessianBlockType< VertexXnType< internal::index_to_pair(K).second >::Dimension, VertexXnType< internal::index_to_pair(K).first >::Dimension >
 
using HessianTuple = typename HessianTupleType< std::make_index_sequence< _nr_of_vertex_pairs > >::type
 
using HessianTupleTransposed = typename HessianTupleType< std::make_index_sequence< _nr_of_vertex_pairs > >::typeTransposed
 
using HessianRowMajorStorage = std::array< bool, _nr_of_vertex_pairs >
 
- Public Types inherited from g2o::BaseEdge< D, E >
typedef E Measurement
 
typedef internal::BaseEdgeTraits< D >::ErrorVector ErrorVector
 
typedef internal::BaseEdgeTraits< D >::InformationType InformationType
 

Public Member Functions

template<int VertexN>
constexpr std::enable_if< VertexXnType< VertexN >::Dimension!=-1, int >::type vertexDimension () const
 
template<int VertexN>
std::enable_if< VertexXnType< VertexN >::Dimension==-1, int >::type vertexDimension () const
 
template<int VertexN>
const VertexXnType< VertexN > * vertexXn () const
 
template<int VertexN>
VertexXnType< VertexN > * vertexXn ()
 
 BaseFixedSizedEdge ()
 
template<typename... CtorArgs>
OptimizableGraph::VertexcreateVertex (int i, CtorArgs... args)
 create an instance of the Nth VertexType
 
virtual void resize (size_t size)
 
template<std::size_t... Ints>
bool allVerticesFixedNs (std::index_sequence< Ints... >) const
 
virtual bool allVerticesFixed () const
 
virtual void linearizeOplus (JacobianWorkspace &jacobianWorkspace)
 
template<std::size_t... Ints>
void linearizeOplus_allocate (JacobianWorkspace &jacobianWorkspace, std::index_sequence< Ints... >)
 
virtual void linearizeOplus ()
 
template<std::size_t... Ints>
void linearizeOplusNs (std::index_sequence< Ints... >)
 
template<int N>
void linearizeOplusN ()
 
template<int N>
const std::tuple_element< N, std::tuple< JacobianType< D, VertexTypes::Dimension >... > >::type & jacobianOplusXn () const
 
template<int N>
std::tuple_element< N, std::tuple< JacobianType< D, VertexTypes::Dimension >... > >::type & jacobianOplusXn ()
 
virtual void constructQuadraticForm ()
 
template<std::size_t... Ints>
void constructQuadraticFormNs (const InformationType &omega, const ErrorVector &weightedError, std::index_sequence< Ints... >)
 
template<int N>
void constructQuadraticFormN (const InformationType &omega, const ErrorVector &weightedError)
 
template<int N, typename AtOType >
void constructOffDiagonalQuadraticFormMs (const AtOType &, std::index_sequence<>)
 
template<int N, std::size_t... Ints, typename AtOType >
void constructOffDiagonalQuadraticFormMs (const AtOType &AtO, std::index_sequence< Ints... >)
 
template<int N, int M, typename AtOType >
void constructOffDiagonalQuadraticFormM (const AtOType &AtO)
 
virtual void mapHessianMemory (double *d, int i, int j, bool rowMajor)
 
template<std::size_t... Ints>
bool allVerticesFixedNs (std::index_sequence< Ints... >) const
 
template<std::size_t... Ints>
void constructQuadraticFormNs (const InformationType &omega, const ErrorVector &weightedError, std::index_sequence< Ints... >)
 
template<int N, typename AtOType >
void constructOffDiagonalQuadraticFormMs (const AtOType &, std::index_sequence<>)
 
template<int N, std::size_t... Ints, typename AtOType >
void constructOffDiagonalQuadraticFormMs (const AtOType &AtO, std::index_sequence< Ints... >)
 
template<int N, int M, typename AtOType >
void constructOffDiagonalQuadraticFormM (const AtOType &AtO)
 
template<int N>
void constructQuadraticFormN (const InformationType &omega, const ErrorVector &weightedError)
 
template<std::size_t... Ints>
void linearizeOplus_allocate (JacobianWorkspace &jacobianWorkspace, std::index_sequence< Ints... >)
 
template<int N>
void linearizeOplusN ()
 
template<std::size_t... Ints>
void linearizeOplusNs (std::index_sequence< Ints... >)
 
- Public Member Functions inherited from g2o::BaseEdge< D, E >
 BaseEdge ()
 
BaseEdgeoperator= (const BaseEdge &)=delete
 
 BaseEdge (const BaseEdge &)=delete
 
virtual ~BaseEdge ()
 
virtual double chi2 () const
 
virtual const double * errorData () const
 returns the error vector cached after calling the computeError;
 
virtual double * errorData ()
 
const ErrorVectorerror () const
 
ErrorVectorerror ()
 
EIGEN_STRONG_INLINE const InformationTypeinformation () const
 information matrix of the constraint
 
EIGEN_STRONG_INLINE InformationTypeinformation ()
 
void setInformation (const InformationType &information)
 
virtual const double * informationData () const
 
virtual double * informationData ()
 
EIGEN_STRONG_INLINE const Measurementmeasurement () const
 accessor functions for the measurement represented by the edge
 
virtual void setMeasurement (const Measurement &m)
 
virtual int rank () const
 
virtual void initialEstimate (const OptimizableGraph::VertexSet &, OptimizableGraph::Vertex *)
 
template<int Dim = D>
std::enable_if< Dim==-1, void >::type setDimension (int dim)
 
- Public Member Functions inherited from g2o::OptimizableGraph::Edge
 Edge ()
 
virtual ~Edge ()
 
virtual void computeError ()=0
 
virtual bool setMeasurementData (const double *m)
 
virtual bool getMeasurementData (double *m) const
 
virtual int measurementDimension () const
 
virtual bool setMeasurementFromState ()
 
RobustKernelrobustKernel () const
 if NOT NULL, error of this edge will be robustifed with the kernel
 
void setRobustKernel (RobustKernel *ptr)
 
virtual double initialEstimatePossible (const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
 
int level () const
 returns the level of the edge
 
void setLevel (int l)
 sets the level of the edge
 
int dimension () const
 returns the dimensions of the error function
 
 G2O_ATTRIBUTE_DEPRECATED (virtual Vertex *createFrom())
 
 G2O_ATTRIBUTE_DEPRECATED (virtual Vertex *createTo())
 
virtual VertexcreateVertex (int)
 
virtual bool read (std::istream &is)=0
 read the vertex from a stream, i.e., the internal state of the vertex
 
virtual bool write (std::ostream &os) const =0
 write the vertex to a stream
 
long long internalId () const
 the internal ID of the edge
 
OptimizableGraphgraph ()
 
const OptimizableGraphgraph () const
 
bool setParameterId (int argNum, int paramId)
 
const Parameterparameter (int argNo) const
 
size_t numParameters () const
 
void resizeParameters (size_t newSize)
 
- Public Member Functions inherited from g2o::HyperGraph::Edge
 Edge (int id=InvalidId)
 creates and empty edge with no vertices
 
const VertexContainervertices () const
 
VertexContainervertices ()
 
const Vertexvertex (size_t i) const
 
Vertexvertex (size_t i)
 
void setVertex (size_t i, Vertex *v)
 
int id () const
 
void setId (int id)
 
virtual HyperGraphElementType elementType () const
 
int numUndefinedVertices () const
 
- Public Member Functions inherited from g2o::HyperGraph::HyperGraphElement
virtual ~HyperGraphElement ()
 
- Public Member Functions inherited from g2o::HyperGraph::DataContainer
 DataContainer ()
 
virtual ~DataContainer ()
 
const DatauserData () const
 the user data associated with this vertex
 
DatauserData ()
 
void setUserData (Data *obs)
 
void addUserData (Data *obs)
 

Static Public Member Functions

template<int VertexN>
static constexpr int VertexDimension ()
 Size of the N-th vertex at compile time.
 

Static Public Attributes

static const int Dimension = BaseEdge<D, E>::Dimension
 
static const std::size_t _nr_of_vertices = sizeof...(VertexTypes)
 
static const std::size_t _nr_of_vertex_pairs
 
- Static Public Attributes inherited from g2o::BaseEdge< D, E >
static constexpr int Dimension = internal::BaseEdgeTraits<D>::Dimension
 

Protected Attributes

HessianRowMajorStorage _hessianRowMajor
 
HessianTuple _hessianTuple
 
HessianTupleTransposed _hessianTupleTransposed
 
std::tuple< JacobianType< D, VertexTypes::Dimension >... > _jacobianOplus
 
- Protected Attributes inherited from g2o::BaseEdge< D, E >
Measurement _measurement
 the measurement of the edge
 
InformationType _information
 
ErrorVector _error
 
- Protected Attributes inherited from g2o::OptimizableGraph::Edge
int _dimension
 
int _level
 
RobustKernel_robustKernel
 
long long _internalId
 
std::vector< int > _cacheIds
 
std::vector< std::string > _parameterTypes
 
std::vector< Parameter ** > _parameters
 
std::vector< int > _parameterIds
 
- Protected Attributes inherited from g2o::HyperGraph::Edge
VertexContainer _vertices
 
int _id
 unique id
 
- Protected Attributes inherited from g2o::HyperGraph::DataContainer
Data_userData
 

Additional Inherited Members

- Protected Member Functions inherited from g2o::BaseEdge< D, E >
InformationType robustInformation (const Vector3 &rho) const
 
bool writeInformationMatrix (std::ostream &os) const
 write the upper trinagular part of the information matrix into the stream
 
bool readInformationMatrix (std::istream &is)
 
bool writeParamIds (std::ostream &os) const
 write the param IDs that are potentially used by the edge
 
bool readParamIds (std::istream &is)
 reads the param IDs from the stream
 
- Protected Member Functions inherited from g2o::OptimizableGraph::Edge
template<typename ParameterType >
bool installParameter (ParameterType *&p, size_t argNo, int paramId=-1)
 
template<typename CacheType >
void resolveCache (CacheType *&cache, OptimizableGraph::Vertex *, const std::string &_type, const ParameterVector &parameters)
 
bool resolveParameters ()
 
virtual bool resolveCaches ()
 

Detailed Description

template<int D, typename E, typename... VertexTypes>
class g2o::BaseFixedSizedEdge< D, E, VertexTypes >

Definition at line 125 of file base_fixed_sized_edge.h.

Member Typedef Documentation

◆ ErrorVector

template<int D, typename E , typename... VertexTypes>
typedef BaseEdge<D,E>::ErrorVector g2o::BaseFixedSizedEdge< D, E, VertexTypes >::ErrorVector

Definition at line 166 of file base_fixed_sized_edge.h.

◆ HessianBlockType

template<int D, typename E , typename... VertexTypes>
template<int DN, int DM>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::HessianBlockType = Eigen::Map< Eigen::Matrix<double, DN, DM, DN == 1 ? Eigen::RowMajor : Eigen::ColMajor>, Eigen::Matrix<double, DN, DM, DN == 1 ? Eigen::RowMajor : Eigen::ColMajor>::Flags & Eigen::PacketAccessBit ? Eigen::Aligned : Eigen::Unaligned>

it requires quite some ugly code to get the type of hessians...

Definition at line 176 of file base_fixed_sized_edge.h.

◆ HessianBlockTypeK

template<int D, typename E , typename... VertexTypes>
template<int K>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::HessianBlockTypeK = HessianBlockType< VertexXnType<internal::index_to_pair(K).first>::Dimension, VertexXnType<internal::index_to_pair(K).second>::Dimension>

Definition at line 185 of file base_fixed_sized_edge.h.

◆ HessianBlockTypeKTransposed

template<int D, typename E , typename... VertexTypes>
template<int K>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::HessianBlockTypeKTransposed = HessianBlockType< VertexXnType<internal::index_to_pair(K).second>::Dimension, VertexXnType<internal::index_to_pair(K).first>::Dimension>

Definition at line 189 of file base_fixed_sized_edge.h.

◆ HessianRowMajorStorage

template<int D, typename E , typename... VertexTypes>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::HessianRowMajorStorage = std::array<bool, _nr_of_vertex_pairs>

Definition at line 206 of file base_fixed_sized_edge.h.

◆ HessianTuple

template<int D, typename E , typename... VertexTypes>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::HessianTuple = typename HessianTupleType< std::make_index_sequence<_nr_of_vertex_pairs> >::type

Definition at line 202 of file base_fixed_sized_edge.h.

◆ HessianTupleTransposed

template<int D, typename E , typename... VertexTypes>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::HessianTupleTransposed = typename HessianTupleType< std::make_index_sequence<_nr_of_vertex_pairs> >::typeTransposed

Definition at line 204 of file base_fixed_sized_edge.h.

◆ InformationType

template<int D, typename E , typename... VertexTypes>
typedef BaseEdge<D,E>::InformationType g2o::BaseFixedSizedEdge< D, E, VertexTypes >::InformationType

Definition at line 167 of file base_fixed_sized_edge.h.

◆ JacobianType

template<int D, typename E , typename... VertexTypes>
template<int EdgeDimension, int VertexDimension>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::JacobianType = typename Eigen::Matrix< double, EdgeDimension, VertexDimension, EdgeDimension == 1 ? Eigen::RowMajor : Eigen::ColMajor>::AlignedMapType

Definition at line 170 of file base_fixed_sized_edge.h.

◆ Measurement

template<int D, typename E , typename... VertexTypes>
typedef BaseEdge<D,E>::Measurement g2o::BaseFixedSizedEdge< D, E, VertexTypes >::Measurement

Definition at line 165 of file base_fixed_sized_edge.h.

◆ NthType

template<int D, typename E , typename... VertexTypes>
template<int N, typename... Types>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::NthType = typename std::tuple_element<N, std::tuple<Types...> >::type

Definition at line 128 of file base_fixed_sized_edge.h.

◆ VertexXnType

template<int D, typename E , typename... VertexTypes>
template<int VertexN>
using g2o::BaseFixedSizedEdge< D, E, VertexTypes >::VertexXnType = NthType<VertexN, VertexTypes...>

The type of the N-th vertex.

Definition at line 131 of file base_fixed_sized_edge.h.

Constructor & Destructor Documentation

◆ BaseFixedSizedEdge()

template<int D, typename E , typename... VertexTypes>
g2o::BaseFixedSizedEdge< D, E, VertexTypes >::BaseFixedSizedEdge ( )
inline

Definition at line 208 of file base_fixed_sized_edge.h.

209 : BaseEdge<D, E>(),
210 _hessianRowMajor(internal::createBoolArray<_nr_of_vertex_pairs>()),
214 _jacobianOplus({nullptr, D, VertexTypes::Dimension}...) {
215 _vertices.resize(_nr_of_vertices, nullptr);
216 }
static const std::size_t _nr_of_vertices
HessianTupleTransposed _hessianTupleTransposed
HessianRowMajorStorage _hessianRowMajor
std::tuple< JacobianType< D, VertexTypes::Dimension >... > _jacobianOplus
VertexContainer _vertices
std::tuple< Args... > createHessianMaps(const std::tuple< Args... > &)
helper function for creating a tuple of Eigen::Map

Member Function Documentation

◆ allVerticesFixed()

template<int D, typename E , typename... VertexTypes>
bool BaseFixedSizedEdge::allVerticesFixed ( ) const
virtual

Implements g2o::OptimizableGraph::Edge.

Definition at line 44 of file base_fixed_sized_edge.hpp.

44 {
45 return allVerticesFixedNs(std::make_index_sequence<_nr_of_vertices>());
46}
bool allVerticesFixedNs(std::index_sequence< Ints... >) const

◆ allVerticesFixedNs() [1/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
bool g2o::BaseFixedSizedEdge< D, E, VertexTypes >::allVerticesFixedNs ( std::index_sequence< Ints... >  ) const

◆ allVerticesFixedNs() [2/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
bool g2o::BaseFixedSizedEdge< D, E, VertexTypes >::allVerticesFixedNs ( std::index_sequence< Ints... >  ) const

Definition at line 38 of file base_fixed_sized_edge.hpp.

39 {
40 return (... && vertexXn<Ints>()->fixed());
41}

◆ constructOffDiagonalQuadraticFormM() [1/2]

template<int D, typename E , typename... VertexTypes>
template<int N, int M, typename AtOType >
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructOffDiagonalQuadraticFormM ( const AtOType &  AtO)

◆ constructOffDiagonalQuadraticFormM() [2/2]

template<int D, typename E , typename... VertexTypes>
template<int N, int M, typename AtOType >
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructOffDiagonalQuadraticFormM ( const AtOType &  AtO)

Definition at line 91 of file base_fixed_sized_edge.hpp.

92 {
93 constexpr auto fromId = N;
94 constexpr auto toId = N + M + 1;
95 assert(fromId < toId && "Index mixed up");
96 auto to = vertexXn<toId>();
97 if (!to->fixed()) {
98 const auto& B = std::get<toId>(_jacobianOplus);
99 constexpr auto K = internal::pair_to_index(fromId, toId);
100 internal::QuadraticFormLock lck(*to);
101 (void)lck;
102 if (_hessianRowMajor[K]) { // we have to write to the block as transposed
103 auto& hessianTransposed = std::get<K>(_hessianTupleTransposed);
104 hessianTransposed.noalias() += B.transpose() * AtO.transpose();
105 } else {
106 auto& hessian = std::get<K>(_hessianTuple);
107 hessian.noalias() += AtO * B;
108 }
109 }
110}
constexpr int pair_to_index(const int i, const int j)

◆ constructOffDiagonalQuadraticFormMs() [1/4]

template<int D, typename E , typename... VertexTypes>
template<int N, typename AtOType >
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructOffDiagonalQuadraticFormMs ( const AtOType &  ,
std::index_sequence<>   
)

◆ constructOffDiagonalQuadraticFormMs() [2/4]

template<int D, typename E , typename... VertexTypes>
template<int N, typename AtOType >
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructOffDiagonalQuadraticFormMs ( const AtOType &  ,
std::index_sequence<>   
)

Definition at line 77 of file base_fixed_sized_edge.hpp.

78 {
79}

◆ constructOffDiagonalQuadraticFormMs() [3/4]

template<int D, typename E , typename... VertexTypes>
template<int N, std::size_t... Ints, typename AtOType >
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructOffDiagonalQuadraticFormMs ( const AtOType &  AtO,
std::index_sequence< Ints... >   
)

◆ constructOffDiagonalQuadraticFormMs() [4/4]

template<int D, typename E , typename... VertexTypes>
template<int N, std::size_t... Ints, typename AtOType >
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructOffDiagonalQuadraticFormMs ( const AtOType &  AtO,
std::index_sequence< Ints... >   
)

Definition at line 83 of file base_fixed_sized_edge.hpp.

85 {
86 (void(constructOffDiagonalQuadraticFormM<N, Ints, AtOType>(AtO)), ...);
87}

◆ constructQuadraticForm()

template<int D, typename E , typename... VertexTypes>
void BaseFixedSizedEdge::constructQuadraticForm ( )
virtual

computes the (block) elements of the Hessian matrix of the linearized least squares.

Implements g2o::OptimizableGraph::Edge.

Definition at line 49 of file base_fixed_sized_edge.hpp.

49 {
50 if (this->robustKernel()) {
51 double error = this->chi2();
52 Vector3 rho;
53 this->robustKernel()->robustify(error, rho);
54 Eigen::Matrix<double, D, 1, Eigen::ColMajor> omega_r =
56 omega_r *= rho[1];
58 std::make_index_sequence<_nr_of_vertices>());
59 } else {
61 std::make_index_sequence<_nr_of_vertices>());
62 }
63}
InformationType _information
Definition base_edge.h:147
virtual double chi2() const
Definition base_edge.h:99
const ErrorVector & error() const
Definition base_edge.h:103
InformationType robustInformation(const Vector3 &rho) const
Definition base_edge.h:156
ErrorVector _error
Definition base_edge.h:149
void constructQuadraticFormNs(const InformationType &omega, const ErrorVector &weightedError, std::index_sequence< Ints... >)
RobustKernel * robustKernel() const
if NOT NULL, error of this edge will be robustifed with the kernel
virtual void robustify(double squaredError, Vector3 &rho) const =0
VectorN< 3 > Vector3
Definition eigen_types.h:51

◆ constructQuadraticFormN() [1/2]

template<int D, typename E , typename... VertexTypes>
template<int N>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructQuadraticFormN ( const InformationType omega,
const ErrorVector weightedError 
)

◆ constructQuadraticFormN() [2/2]

template<int D, typename E , typename... VertexTypes>
template<int N>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructQuadraticFormN ( const InformationType omega,
const ErrorVector weightedError 
)

Definition at line 114 of file base_fixed_sized_edge.hpp.

115 {
116 auto from = vertexXn<N>();
117 const auto& A = std::get<N>(_jacobianOplus);
118
119 if (!(from->fixed())) {
120 const auto AtO = A.transpose() * omega;
121 {
122 internal::QuadraticFormLock lck(*from);
123 (void)lck;
124 from->b().noalias() += A.transpose() * weightedError;
125 from->A().noalias() += AtO * A;
126 }
127 constructOffDiagonalQuadraticFormMs<N>(
128 AtO, std::make_index_sequence<_nr_of_vertices - N - 1>());
129 }
130};

◆ constructQuadraticFormNs() [1/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructQuadraticFormNs ( const InformationType omega,
const ErrorVector weightedError,
std::index_sequence< Ints... >   
)

◆ constructQuadraticFormNs() [2/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::constructQuadraticFormNs ( const InformationType omega,
const ErrorVector weightedError,
std::index_sequence< Ints... >   
)

Definition at line 67 of file base_fixed_sized_edge.hpp.

69 {
70 (void(constructQuadraticFormN<Ints>(omega, weightedError)), ...);
71}

◆ createVertex()

template<int D, typename E , typename... VertexTypes>
template<typename... CtorArgs>
OptimizableGraph::Vertex * g2o::BaseFixedSizedEdge< D, E, VertexTypes >::createVertex ( int  i,
CtorArgs...  args 
)
inline

create an instance of the Nth VertexType

Definition at line 220 of file base_fixed_sized_edge.h.

220 {
221 if (i < 0) return nullptr;
223 sizeof...(VertexTypes) - 1,
224 typename std::remove_reference<decltype(*this)>::type, CtorArgs...>(
225 i, *this, args...);
226 };
std::enable_if< I==-1, OptimizableGraph::Vertex * >::type createNthVertexType(int, const EdgeType &, CtorArgs...)

References g2o::internal::createNthVertexType().

◆ jacobianOplusXn() [1/2]

template<int D, typename E , typename... VertexTypes>
template<int N>
std::tuple_element< N, std::tuple< JacobianType< D, VertexTypes::Dimension >... > >::type & g2o::BaseFixedSizedEdge< D, E, VertexTypes >::jacobianOplusXn ( )
inline

returns the result of the linearization in the manifold space for the nodes xn

Definition at line 262 of file base_fixed_sized_edge.h.

262 {
263 return std::get<N>(_jacobianOplus);
264 }

References g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_jacobianOplus.

◆ jacobianOplusXn() [2/2]

template<int D, typename E , typename... VertexTypes>
template<int N>
const std::tuple_element< N, std::tuple< JacobianType< D, VertexTypes::Dimension >... > >::type & g2o::BaseFixedSizedEdge< D, E, VertexTypes >::jacobianOplusXn ( ) const
inline

returns the result of the linearization in the manifold space for the nodes xn

Definition at line 254 of file base_fixed_sized_edge.h.

254 {
255 return std::get<N>(_jacobianOplus);
256 }

References g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_jacobianOplus.

◆ linearizeOplus() [1/2]

template<int D, typename E , typename... VertexTypes>
void BaseFixedSizedEdge::linearizeOplus ( )
virtual

◆ linearizeOplus() [2/2]

template<int D, typename E , typename... VertexTypes>
void BaseFixedSizedEdge::linearizeOplus ( JacobianWorkspace jacobianWorkspace)
virtual

Linearizes the constraint in the edge in the manifold space, and store the result in the given workspace

Implements g2o::OptimizableGraph::Edge.

Definition at line 133 of file base_fixed_sized_edge.hpp.

134 {
135 linearizeOplus_allocate(jacobianWorkspace,
136 std::make_index_sequence<_nr_of_vertices>());
138}
void linearizeOplus_allocate(JacobianWorkspace &jacobianWorkspace, std::index_sequence< Ints... >)

◆ linearizeOplus_allocate() [1/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::linearizeOplus_allocate ( JacobianWorkspace jacobianWorkspace,
std::index_sequence< Ints... >   
)

◆ linearizeOplus_allocate() [2/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::linearizeOplus_allocate ( JacobianWorkspace jacobianWorkspace,
std::index_sequence< Ints... >   
)

Definition at line 142 of file base_fixed_sized_edge.hpp.

143 {
144 (new (&std::get<Ints>(_jacobianOplus))
145 JacobianType<D, VertexDimension<Ints>()>(
146 jacobianWorkspace.workspaceForVertex(Ints), D < 0 ? _dimension : D,
147 VertexDimension<Ints>() < 0 ? vertexXn<Ints>()->dimension()
148 : VertexDimension<Ints>()),
149 ...);
150}
typename Eigen::Matrix< double, EdgeDimension, VertexDimension, EdgeDimension==1 ? Eigen::RowMajor :Eigen::ColMajor >::AlignedMapType JacobianType

References g2o::JacobianWorkspace::workspaceForVertex().

◆ linearizeOplusN() [1/2]

template<int D, typename E , typename... VertexTypes>
template<int N>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::linearizeOplusN ( )

◆ linearizeOplusN() [2/2]

template<int D, typename E , typename... VertexTypes>
template<int N>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::linearizeOplusN ( )

Definition at line 154 of file base_fixed_sized_edge.hpp.

154 {
155 auto vertex = vertexXn<N>();
156
157 if (vertex->fixed()) return;
158
159 auto& jacobianOplus = std::get<N>(_jacobianOplus);
160
161 constexpr double delta = cst(1e-9);
162 constexpr double scalar = 1 / (2 * delta);
163
164 internal::QuadraticFormLock lck(*vertex);
165 (void)lck;
166
167 typedef typename std::conditional<
168 VertexXnType<N>::Dimension == -1, ceres::internal::FixedArray<double>,
169 ceres::internal::FixedArray<
170 double, static_cast<size_t>(VertexXnType<N>::Dimension)> >::type
171 FixedArray;
172 FixedArray add_vertex(vertexDimension<N>());
173 add_vertex.fill(0.);
174
175 // estimate the jacobian numerically
176 // add small step along the unit vector in each dimension
177 for (int d = 0; d < vertexDimension<N>(); ++d) {
178 vertex->push();
179 add_vertex[d] = delta;
180 vertex->oplus(add_vertex.data());
181 computeError();
182 auto errorBak = this->error();
183 vertex->pop();
184 vertex->push();
185 add_vertex[d] = -delta;
186 vertex->oplus(add_vertex.data());
187 computeError();
188 errorBak -= this->error();
189 vertex->pop();
190 add_vertex[d] = 0.0;
191
192 jacobianOplus.col(d) = scalar * errorBak;
193 } // end dimension
194}
const Vertex * vertex(size_t i) const
virtual void computeError()=0
constexpr double cst(long double v)
Definition misc.h:60

References g2o::cst(), g2o::ceres::internal::FixedArray< T, N, A >::data(), and g2o::ceres::internal::FixedArray< T, N, A >::fill().

◆ linearizeOplusNs() [1/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::linearizeOplusNs ( std::index_sequence< Ints... >  )

◆ linearizeOplusNs() [2/2]

template<int D, typename E , typename... VertexTypes>
template<std::size_t... Ints>
void g2o::BaseFixedSizedEdge< D, E, VertexTypes >::linearizeOplusNs ( std::index_sequence< Ints... >  )

Definition at line 198 of file base_fixed_sized_edge.hpp.

199 {
200 (void(linearizeOplusN<Ints>()), ...);
201}

◆ mapHessianMemory()

template<int D, typename E , typename... VertexTypes>
void BaseFixedSizedEdge::mapHessianMemory ( double *  d,
int  i,
int  j,
bool  rowMajor 
)
virtual

maps the internal matrix to some external memory location, you need to provide the memory before calling constructQuadraticForm

Parameters
dthe memory location to which we map
iindex of the vertex i
jindex of the vertex j (j > i, upper triangular fashion)
rowMajorif true, will write in rowMajor order to the block. Since EIGEN is columnMajor by default, this results in writing the transposed

Implements g2o::OptimizableGraph::Edge.

Definition at line 227 of file base_fixed_sized_edge.hpp.

229 {
230 assert(i < j && "index assumption violated");
231 // get the size of the vertices
232 int vi_dim =
233 static_cast<OptimizableGraph::Vertex*>(HyperGraph::Edge::vertex(i))
234 ->dimension();
235 int vj_dim =
236 static_cast<OptimizableGraph::Vertex*>(HyperGraph::Edge::vertex(j))
237 ->dimension();
238 int k = internal::pair_to_index(i, j);
239 _hessianRowMajor[k] = rowMajor;
240 if (rowMajor)
242 k);
243 else
244 tuple_apply_i(MapHessianMemoryK{d, vi_dim, vj_dim}, _hessianTuple, k);
245}
int dimension() const
returns the dimensions of the error function
void tuple_apply_i(F &&f, T &t, int i)
Definition tuple_tools.h:39

◆ resize()

template<int D, typename E , typename... VertexTypes>
void BaseFixedSizedEdge::resize ( size_t  size)
virtual

resizes the number of vertices connected by this edge

Reimplemented from g2o::HyperGraph::Edge.

Definition at line 30 of file base_fixed_sized_edge.hpp.

30 {
31 assert(size == _nr_of_vertices &&
32 "attempting to resize a constant size edge");
34}
virtual void resize(size_t size)

Referenced by main().

◆ VertexDimension()

template<int D, typename E , typename... VertexTypes>
template<int VertexN>
static constexpr int g2o::BaseFixedSizedEdge< D, E, VertexTypes >::VertexDimension ( )
inlinestaticconstexpr

Size of the N-th vertex at compile time.

Definition at line 134 of file base_fixed_sized_edge.h.

134 {
135 return VertexXnType<VertexN>::Dimension;
136 };

◆ vertexDimension() [1/2]

template<int D, typename E , typename... VertexTypes>
template<int VertexN>
constexpr std::enable_if< VertexXnType< VertexN >::Dimension!=-1, int >::type g2o::BaseFixedSizedEdge< D, E, VertexTypes >::vertexDimension ( ) const
inlineconstexpr

Get the size of a given Vertex. If the vertex dimension is static and by this known at compile time, we return this. Otherwise we get the size at runtime.

Definition at line 144 of file base_fixed_sized_edge.h.

144 {
145 return VertexXnType<VertexN>::Dimension;
146 };

◆ vertexDimension() [2/2]

template<int D, typename E , typename... VertexTypes>
template<int VertexN>
std::enable_if< VertexXnType< VertexN >::Dimension==-1, int >::type g2o::BaseFixedSizedEdge< D, E, VertexTypes >::vertexDimension ( ) const
inline

Definition at line 148 of file base_fixed_sized_edge.h.

148 {
149 return vertexXn<VertexN>()->dimension();
150 };

◆ vertexXn() [1/2]

template<int D, typename E , typename... VertexTypes>
template<int VertexN>
VertexXnType< VertexN > * g2o::BaseFixedSizedEdge< D, E, VertexTypes >::vertexXn ( )
inline

Definition at line 160 of file base_fixed_sized_edge.h.

160 {
161 return static_cast<VertexXnType<VertexN>*>(_vertices[VertexN]);
162 }

References g2o::HyperGraph::Edge::_vertices.

◆ vertexXn() [2/2]

template<int D, typename E , typename... VertexTypes>
template<int VertexN>
const VertexXnType< VertexN > * g2o::BaseFixedSizedEdge< D, E, VertexTypes >::vertexXn ( ) const
inline

Return a pointer to the N-th vertex, directly casted to the correct type

Definition at line 156 of file base_fixed_sized_edge.h.

156 {
157 return static_cast<const VertexXnType<VertexN>*>(_vertices[VertexN]);
158 }

References g2o::HyperGraph::Edge::_vertices.

Member Data Documentation

◆ _hessianRowMajor

template<int D, typename E , typename... VertexTypes>
HessianRowMajorStorage g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_hessianRowMajor
protected

Definition at line 301 of file base_fixed_sized_edge.h.

◆ _hessianTuple

template<int D, typename E , typename... VertexTypes>
HessianTuple g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_hessianTuple
protected

Definition at line 302 of file base_fixed_sized_edge.h.

◆ _hessianTupleTransposed

template<int D, typename E , typename... VertexTypes>
HessianTupleTransposed g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_hessianTupleTransposed
protected

Definition at line 303 of file base_fixed_sized_edge.h.

◆ _jacobianOplus

template<int D, typename E , typename... VertexTypes>
std::tuple<JacobianType<D, VertexTypes::Dimension>...> g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_jacobianOplus
protected

◆ _nr_of_vertex_pairs

template<int D, typename E , typename... VertexTypes>
const std::size_t g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_nr_of_vertex_pairs
static
Initial value:

Definition at line 200 of file base_fixed_sized_edge.h.

◆ _nr_of_vertices

template<int D, typename E , typename... VertexTypes>
const std::size_t g2o::BaseFixedSizedEdge< D, E, VertexTypes >::_nr_of_vertices = sizeof...(VertexTypes)
static

Definition at line 199 of file base_fixed_sized_edge.h.

◆ Dimension

template<int D, typename E , typename... VertexTypes>
const int g2o::BaseFixedSizedEdge< D, E, VertexTypes >::Dimension = BaseEdge<D, E>::Dimension
static

Definition at line 164 of file base_fixed_sized_edge.h.


The documentation for this class was generated from the following files: