g2o
Loading...
Searching...
No Matches
g2o::BaseEdge< D, E > Class Template Reference

#include <base_edge.h>

Inheritance diagram for g2o::BaseEdge< D, E >:
Collaboration diagram for g2o::BaseEdge< D, E >:

Public Types

typedef E Measurement
typedef internal::BaseEdgeTraits< D >::ErrorVector ErrorVector
typedef internal::BaseEdgeTraits< D >::InformationType InformationType

Public Member Functions

 BaseEdge ()
BaseEdge & operator= (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 ErrorVector & error () const
ErrorVector & error ()
EIGEN_STRONG_INLINE const InformationType & information () const
 information matrix of the constraint
EIGEN_STRONG_INLINE InformationType & information ()
void setInformation (const InformationType &information)
virtual const double * informationData () const
virtual double * informationData ()
EIGEN_STRONG_INLINE const Measurement & measurement () 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 bool allVerticesFixed () const =0
virtual void computeError ()=0
virtual bool setMeasurementData (const double *m)
virtual bool getMeasurementData (double *m) const
virtual int measurementDimension () const
virtual bool setMeasurementFromState ()
RobustKernel * robustKernel () const
 if NOT NULL, error of this edge will be robustifed with the kernel
void setRobustKernel (RobustKernel *ptr)
virtual void constructQuadraticForm ()=0
virtual void mapHessianMemory (double *d, int i, int j, bool rowMajor)=0
virtual void linearizeOplus (JacobianWorkspace &jacobianWorkspace)=0
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 Vertex * createVertex (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
OptimizableGraph * graph ()
const OptimizableGraph * graph () const
bool setParameterId (int argNum, int paramId)
const Parameter * parameter (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
virtual void resize (size_t size)
const VertexContainer & vertices () const
VertexContainer & vertices ()
const Vertex * vertex (size_t i) const
Vertex * vertex (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 Data * userData () const
 the user data associated with this vertex
Data * userData ()
void setUserData (Data *obs)
void addUserData (Data *obs)

Static Public Attributes

static constexpr int Dimension = internal::BaseEdgeTraits<D>::Dimension

Protected Member Functions

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 ()

Protected Attributes

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

Detailed Description

template<int D, typename E>
class g2o::BaseEdge< D, E >

Definition at line 86 of file base_edge.h.

Member Typedef Documentation

◆ ErrorVector

template<int D, typename E>
typedef internal::BaseEdgeTraits<D>::ErrorVector g2o::BaseEdge< D, E >::ErrorVector

Definition at line 90 of file base_edge.h.

◆ InformationType

template<int D, typename E>
typedef internal::BaseEdgeTraits<D>::InformationType g2o::BaseEdge< D, E >::InformationType

Definition at line 91 of file base_edge.h.

◆ Measurement

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

Definition at line 89 of file base_edge.h.

Constructor & Destructor Documentation

◆ BaseEdge() [1/2]

◆ BaseEdge() [2/2]

template<int D, typename E>
g2o::BaseEdge< D, E >::BaseEdge ( const BaseEdge< D, E > & )
delete

◆ ~BaseEdge()

template<int D, typename E>
virtual g2o::BaseEdge< D, E >::~BaseEdge ( )
inlinevirtual

Definition at line 97 of file base_edge.h.

97{}

Member Function Documentation

◆ chi2()

template<int D, typename E>
virtual double g2o::BaseEdge< D, E >::chi2 ( ) const
inlinevirtual

computes the chi2 based on the cached error value, only valid after computeError has been called.

Implements g2o::OptimizableGraph::Edge.

Reimplemented in g2o::OnlineEdgeSE2, and g2o::OnlineEdgeSE3.

Definition at line 99 of file base_edge.h.

99{ return _error.dot(information() * _error); }
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition base_edge.h:107
ErrorVector _error
Definition base_edge.h:149

◆ error() [1/2]

template<int D, typename E>
ErrorVector & g2o::BaseEdge< D, E >::error ( )
inline

Definition at line 104 of file base_edge.h.

104{ return _error; }

◆ error() [2/2]

template<int D, typename E>
const ErrorVector & g2o::BaseEdge< D, E >::error ( ) const
inline

Definition at line 103 of file base_edge.h.

103{ return _error; }

◆ errorData() [1/2]

template<int D, typename E>
virtual double * g2o::BaseEdge< D, E >::errorData ( )
inlinevirtual

Implements g2o::OptimizableGraph::Edge.

Definition at line 102 of file base_edge.h.

102{ return _error.data(); }

◆ errorData() [2/2]

template<int D, typename E>
virtual const double * g2o::BaseEdge< D, E >::errorData ( ) const
inlinevirtual

returns the error vector cached after calling the computeError;

Implements g2o::OptimizableGraph::Edge.

Definition at line 101 of file base_edge.h.

101{ return _error.data(); }

◆ information() [1/2]

template<int D, typename E>
EIGEN_STRONG_INLINE InformationType & g2o::BaseEdge< D, E >::information ( )
inline

Definition at line 110 of file base_edge.h.

110{ return _information; }
InformationType _information
Definition base_edge.h:147

◆ information() [2/2]

template<int D, typename E>
EIGEN_STRONG_INLINE const InformationType & g2o::BaseEdge< D, E >::information ( ) const
inline

◆ informationData() [1/2]

template<int D, typename E>
virtual double * g2o::BaseEdge< D, E >::informationData ( )
inlinevirtual

Implements g2o::OptimizableGraph::Edge.

Definition at line 116 of file base_edge.h.

116{ return _information.data(); }

◆ informationData() [2/2]

template<int D, typename E>
virtual const double * g2o::BaseEdge< D, E >::informationData ( ) const
inlinevirtual

returns the memory of the information matrix, usable for example with a Eigen::Map<MatrixX>

Implements g2o::OptimizableGraph::Edge.

Definition at line 115 of file base_edge.h.

115{ return _information.data(); }

◆ initialEstimate()

template<int D, typename E>
virtual void g2o::BaseEdge< D, E >::initialEstimate ( const OptimizableGraph::VertexSet & from,
OptimizableGraph::Vertex * to )
inlinevirtual

◆ measurement()

template<int D, typename E>
EIGEN_STRONG_INLINE const Measurement & g2o::BaseEdge< D, E >::measurement ( ) const
inline

accessor functions for the measurement represented by the edge

Definition at line 119 of file base_edge.h.

119 {
120 return _measurement;
121 }
Measurement _measurement
the measurement of the edge
Definition base_edge.h:146

Referenced by g2o::Edge_V_V_GICP::Edge_V_V_GICP(), main(), main(), Robot::move(), g2o::ThetaTreeAction::perform(), g2o::SolverSLAM2DLinear::solveOrientation(), ToEdgeSim3(), and g2o::Gm2dlIO::writeGm2dl().

◆ operator=()

template<int D, typename E>
BaseEdge & g2o::BaseEdge< D, E >::operator= ( const BaseEdge< D, E > & )
delete

◆ rank()

template<int D, typename E>
virtual int g2o::BaseEdge< D, E >::rank ( ) const
inlinevirtual

Definition at line 124 of file base_edge.h.

124{ return _dimension; }

◆ readInformationMatrix()

template<int D, typename E>
bool g2o::BaseEdge< D, E >::readInformationMatrix ( std::istream & is)
inlineprotected

reads the upper triangular part of the matrix and recovers the missing symmetrical elements

Definition at line 173 of file base_edge.h.

173 {
174 for (int i = 0; i < information().rows() && is.good(); ++i)
175 for (int j = i; j < information().cols() && is.good(); ++j) {
176 is >> information()(i, j);
177 if (i != j) information()(j, i) = information()(i, j);
178 }
179 return is.good() || is.eof();
180 }

◆ readParamIds()

template<int D, typename E>
bool g2o::BaseEdge< D, E >::readParamIds ( std::istream & is)
inlineprotected

reads the param IDs from the stream

Definition at line 187 of file base_edge.h.

187 {
188 for (size_t i = 0; i < numParameters(); ++i) {
189 int paramId;
190 is >> paramId;
192 }
193 return is.good() || is.eof();
194 }
bool setParameterId(int argNum, int paramId)

◆ robustInformation()

template<int D, typename E>
InformationType g2o::BaseEdge< D, E >::robustInformation ( const Vector3 & rho) const
inlineprotected

calculate the robust information matrix by updating the information matrix of the error

Definition at line 156 of file base_edge.h.

156 {
158 // ErrorVector weightedError = _information * _error;
159 // result.noalias() += 2 * rho[2] * (weightedError *
160 // weightedError.transpose());
161 return result;
162 }
internal::BaseEdgeTraits< D >::InformationType InformationType
Definition base_edge.h:91

◆ setDimension()

template<int D, typename E>
template<int Dim = D>
std::enable_if< Dim==-1, void >::type g2o::BaseEdge< D, E >::setDimension ( int dim)
inline

set the dimension for a dynamically sizeable error function. The member will not be declared for edges having a fixed size at compile time.

Definition at line 139 of file base_edge.h.

139 {
140 _dimension = dim;
141 _information.resize(dim, dim);
142 _error.resize(dim, 1);
143 }

◆ setInformation()

template<int D, typename E>
void g2o::BaseEdge< D, E >::setInformation ( const InformationType & information)
inline

◆ setMeasurement()

◆ writeInformationMatrix()

template<int D, typename E>
bool g2o::BaseEdge< D, E >::writeInformationMatrix ( std::ostream & os) const
inlineprotected

write the upper trinagular part of the information matrix into the stream

Definition at line 165 of file base_edge.h.

165 {
166 for (int i = 0; i < information().rows(); ++i)
167 for (int j = i; j < information().cols(); ++j)
168 os << information()(i, j) << " ";
169 return os.good();
170 }

◆ writeParamIds()

template<int D, typename E>
bool g2o::BaseEdge< D, E >::writeParamIds ( std::ostream & os) const
inlineprotected

write the param IDs that are potentially used by the edge

Definition at line 182 of file base_edge.h.

182 {
183 for (auto id : _parameterIds) os << id << " ";
184 return os.good();
185 }

Member Data Documentation

◆ _error

template<int D, typename E>
ErrorVector g2o::BaseEdge< D, E >::_error
protected

error vector, stores the result after computeError() is called

Definition at line 149 of file base_edge.h.

◆ _information

template<int D, typename E>
InformationType g2o::BaseEdge< D, E >::_information
protected

information matrix of the edge. Information = inv(covariance)

Definition at line 147 of file base_edge.h.

◆ _measurement

template<int D, typename E>
Measurement g2o::BaseEdge< D, E >::_measurement
protected

the measurement of the edge

Definition at line 146 of file base_edge.h.

◆ Dimension

template<int D, typename E>
int g2o::BaseEdge< D, E >::Dimension = internal::BaseEdgeTraits<D>::Dimension
staticconstexpr

Definition at line 88 of file base_edge.h.


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