g2o
Public Member Functions | Private Member Functions | Private Attributes | List of all members
g2o::EdgeSE3PointXYZ Class Reference

g2o edge from a track to a point node More...

#include <edge_se3_pointxyz.h>

Inheritance diagram for g2o::EdgeSE3PointXYZ:
Inheritance graph
[legend]
Collaboration diagram for g2o::EdgeSE3PointXYZ:
Collaboration graph
[legend]

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeSE3PointXYZ ()
 
virtual bool read (std::istream &is)
 read the vertex from a stream, i.e., the internal state of the vertex More...
 
virtual bool write (std::ostream &os) const
 write the vertex to a stream More...
 
void computeError ()
 
virtual void linearizeOplus ()
 
virtual void setMeasurement (const Vector3D &m)
 
virtual bool setMeasurementData (const double *d)
 
virtual bool getMeasurementData (double *d) const
 
virtual int measurementDimension () const
 
virtual bool setMeasurementFromState ()
 
virtual double initialEstimatePossible (const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
 
virtual void initialEstimate (const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
 
const ParameterSE3OffsetoffsetParameter ()
 
- Public Member Functions inherited from g2o::BaseBinaryEdge< 3, Vector3D, VertexSE3, VertexPointXYZ >
 BaseBinaryEdge ()
 
virtual OptimizableGraph::VertexcreateFrom ()
 
virtual OptimizableGraph::VertexcreateTo ()
 
virtual OptimizableGraph::VertexcreateVertex (int i)
 
virtual void resize (size_t size)
 
virtual bool allVerticesFixed () const
 
virtual void linearizeOplus (JacobianWorkspace &jacobianWorkspace)
 
const JacobianXiOplusTypejacobianOplusXi () const
 returns the result of the linearization in the manifold space for the node xi More...
 
const JacobianXjOplusTypejacobianOplusXj () const
 returns the result of the linearization in the manifold space for the node xj More...
 
virtual void constructQuadraticForm ()
 
virtual void mapHessianMemory (double *d, int i, int j, bool rowMajor)
 
- Public Member Functions inherited from g2o::BaseEdge< D, Vector3D >
 BaseEdge ()
 
virtual ~BaseEdge ()
 
virtual double chi2 () const
 computes the chi2 based on the cached error value, only valid after computeError has been called. More...
 
virtual const double * errorData () const
 returns the error vector cached after calling the computeError; More...
 
virtual double * errorData ()
 
const ErrorVectorerror () const
 
ErrorVectorerror ()
 
EIGEN_STRONG_INLINE const InformationTypeinformation () const
 information matrix of the constraint More...
 
EIGEN_STRONG_INLINE InformationTypeinformation ()
 
EIGEN_STRONG_INLINE void setInformation (const InformationType &information)
 
virtual const double * informationData () const
 returns the memory of the information matrix, usable for example with a Eigen::Map<MatrixXD> More...
 
virtual double * informationData ()
 
EIGEN_STRONG_INLINE const Measurementmeasurement () const
 accessor functions for the measurement represented by the edge More...
 
virtual int rank () const
 
- Public Member Functions inherited from g2o::OptimizableGraph::Edge
 Edge ()
 
virtual ~Edge ()
 
virtual Edgeclone () const
 
RobustKernelrobustKernel () const
 if NOT NULL, error of this edge will be robustifed with the kernel More...
 
void setRobustKernel (RobustKernel *ptr)
 
int level () const
 returns the level of the edge More...
 
void setLevel (int l)
 sets the level of the edge More...
 
int dimension () const
 returns the dimensions of the error function More...
 
 G2O_ATTRIBUTE_DEPRECATED (virtual Vertex *createFrom())
 
 G2O_ATTRIBUTE_DEPRECATED (virtual Vertex *createTo())
 
long long internalId () const
 the internal ID of the edge More...
 
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 More...
 
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 ()
 
HyperGraphElementclone () const
 
- Public Member Functions inherited from g2o::HyperGraph::DataContainer
 DataContainer ()
 
virtual ~DataContainer ()
 
const DatauserData () const
 the user data associated with this vertex More...
 
DatauserData ()
 
void setUserData (Data *obs)
 
void addUserData (Data *obs)
 

Private Member Functions

virtual bool resolveCaches ()
 

Private Attributes

Eigen::Matrix< double, 3, 9, Eigen::ColMajor > J
 
ParameterSE3OffsetoffsetParam
 
CacheSE3Offsetcache
 

Additional Inherited Members

- Public Types inherited from g2o::BaseBinaryEdge< 3, Vector3D, VertexSE3, VertexPointXYZ >
typedef VertexSE3 VertexXiType
 
typedef VertexPointXYZ VertexXjType
 
typedef BaseEdge< D, Vector3D >::Measurement Measurement
 
typedef Eigen::Matrix< double, D, Di, D==1?Eigen::RowMajor:Eigen::ColMajor >::AlignedMapType JacobianXiOplusType
 
typedef Eigen::Matrix< double, D, Dj, D==1?Eigen::RowMajor:Eigen::ColMajor >::AlignedMapType JacobianXjOplusType
 
typedef BaseEdge< D, Vector3D >::ErrorVector ErrorVector
 
typedef BaseEdge< D, Vector3D >::InformationType InformationType
 
typedef 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
 
typedef 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
 
- Public Types inherited from g2o::BaseEdge< D, Vector3D >
typedef Vector3D Measurement
 
typedef Eigen::Matrix< double, D, 1, Eigen::ColMajor > ErrorVector
 
typedef Eigen::Matrix< double, D, D, Eigen::ColMajor > InformationType
 
- Static Public Attributes inherited from g2o::BaseBinaryEdge< 3, Vector3D, VertexSE3, VertexPointXYZ >
static const int Di
 
static const int Dj
 
static const int Dimension
 
- Static Public Attributes inherited from g2o::BaseEdge< D, Vector3D >
static const int Dimension
 
- Protected Member Functions inherited from g2o::BaseEdge< D, Vector3D >
InformationType robustInformation (const Vector3D &rho)
 
- 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 ()
 
- Protected Attributes inherited from g2o::BaseBinaryEdge< 3, Vector3D, VertexSE3, VertexPointXYZ >
bool _hessianRowMajor
 
HessianBlockType _hessian
 
HessianBlockTransposedType _hessianTransposed
 
JacobianXiOplusType _jacobianOplusXi
 
JacobianXjOplusType _jacobianOplusXj
 
- Protected Attributes inherited from g2o::BaseEdge< D, Vector3D >
Measurement _measurement
 
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 More...
 
- Protected Attributes inherited from g2o::HyperGraph::DataContainer
Data_userData
 

Detailed Description

g2o edge from a track to a point node

Definition at line 43 of file edge_se3_pointxyz.h.

Constructor & Destructor Documentation

g2o::EdgeSE3PointXYZ::EdgeSE3PointXYZ ( )

Definition at line 45 of file edge_se3_pointxyz.cpp.

References cache, g2o::BaseEdge< D, Vector3D >::information(), g2o::OptimizableGraph::Edge::installParameter(), J, offsetParam, and g2o::OptimizableGraph::Edge::resizeParameters().

45  : BaseBinaryEdge<3, Vector3D, VertexSE3, VertexPointXYZ>() {
46  information().setIdentity();
47  J.fill(0);
48  J.block<3,3>(0,0) = -Matrix3D::Identity();
49  cache = 0;
50  offsetParam = 0;
53  }
Eigen::Matrix< double, 3, 9, Eigen::ColMajor > J
bool installParameter(ParameterType *&p, size_t argNo, int paramId=-1)
CacheSE3Offset * cache
ParameterSE3Offset * offsetParam
void resizeParameters(size_t newSize)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67

Member Function Documentation

void g2o::EdgeSE3PointXYZ::computeError ( )
virtual

Implements g2o::OptimizableGraph::Edge.

Definition at line 99 of file edge_se3_pointxyz.cpp.

References g2o::BaseEdge< D, Vector3D >::_error, g2o::BaseEdge< D, Vector3D >::_measurement, g2o::HyperGraph::Edge::_vertices, cache, g2o::BaseVertex< D, T >::estimate(), and g2o::CacheSE3Offset::w2n().

99  {
100  // from cam to point (track)
101  //VertexSE3 *cam = static_cast<VertexSE3*>(_vertices[0]);
102  VertexPointXYZ *point = static_cast<VertexPointXYZ*>(_vertices[1]);
103 
104  Vector3D perr = cache->w2n() * point->estimate();
105 
106  // error, which is backwards from the normal observed - calculated
107  // _measurement is the measured projection
108  _error = perr - _measurement;
109  // std::cout << _error << std::endl << std::endl;
110  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
const Isometry3D & w2n() const
CacheSE3Offset * cache
VertexContainer _vertices
Definition: hyper_graph.h:202
virtual bool g2o::EdgeSE3PointXYZ::getMeasurementData ( double *  m) const
inlinevirtual

writes the measurement to an array of double

Returns
true on success

Reimplemented from g2o::OptimizableGraph::Edge.

Definition at line 66 of file edge_se3_pointxyz.h.

66  {
67  Eigen::Map<Vector3D> v(d);
68  v=_measurement;
69  return true;
70  }
void g2o::EdgeSE3PointXYZ::initialEstimate ( const OptimizableGraph::VertexSet ,
OptimizableGraph::Vertex  
)
virtual

set the estimate of the to vertex, based on the estimate of the from vertices in the edge.

Reimplemented from g2o::BaseEdge< D, Vector3D >.

Definition at line 160 of file edge_se3_pointxyz.cpp.

References g2o::BaseEdge< D, Vector3D >::_measurement, g2o::HyperGraph::Edge::_vertices, g2o::BaseVertex< D, T >::estimate(), LANDMARK_EDGE_COLOR, g2o::ParameterSE3Offset::offset(), offsetParam, offsetParameter(), g2o::BaseVertex< D, T >::setEstimate(), and g2o::HyperGraph::Edge::vertex().

161  {
162  (void) from;
163  assert(from.size() == 1 && from.count(_vertices[0]) == 1 && "Can not initialize VertexDepthCam position by VertexTrackXYZ");
164 
165  VertexSE3 *cam = dynamic_cast<VertexSE3*>(_vertices[0]);
166  VertexPointXYZ *point = dynamic_cast<VertexPointXYZ*>(_vertices[1]);
167  // SE3OffsetCache* vcache = (SE3OffsetCache* ) cam->getCache(_cacheIds[0]);
168  // if (! vcache){
169  // cerr << "fatal error in retrieving cache" << endl;
170  // }
171  // SE3OffsetParameters* params=vcache->params;
173  point->setEstimate(cam->estimate() * (offsetParam->offset() * p));
174  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
const Isometry3D & offset() const
rotation of the offset as 3x3 rotation matrix
ParameterSE3Offset * offsetParam
VertexContainer _vertices
Definition: hyper_graph.h:202
virtual double g2o::EdgeSE3PointXYZ::initialEstimatePossible ( const OptimizableGraph::VertexSet from,
OptimizableGraph::Vertex to 
)
inlinevirtual

override in your class if it's possible to initialize the vertices in certain combinations. The return value may correspond to the cost for initiliaizng the vertex but should be positive if the initialization is possible and negative if not possible.

Reimplemented from g2o::OptimizableGraph::Edge.

Definition at line 76 of file edge_se3_pointxyz.h.

77  {
78  (void) to;
79  return (from.count(_vertices[0]) == 1 ? 1.0 : -1.0);
80  }
VertexContainer _vertices
Definition: hyper_graph.h:202
void g2o::EdgeSE3PointXYZ::linearizeOplus ( )
virtual

Linearizes the oplus operator in the vertex, and stores the result in temporary variables _jacobianOplusXi and _jacobianOplusXj

Reimplemented from g2o::BaseBinaryEdge< 3, Vector3D, VertexSE3, VertexPointXYZ >.

Definition at line 112 of file edge_se3_pointxyz.cpp.

References g2o::BaseBinaryEdge< 3, Vector3D, VertexSE3, VertexPointXYZ >::_jacobianOplusXi, g2o::BaseBinaryEdge< 3, Vector3D, VertexSE3, VertexPointXYZ >::_jacobianOplusXj, g2o::HyperGraph::Edge::_vertices, cache, g2o::BaseVertex< D, T >::estimate(), g2o::ParameterSE3Offset::inverseOffset(), J, offsetParam, and g2o::CacheSE3Offset::w2l().

112  {
113  //VertexSE3 *cam = static_cast<VertexSE3 *>(_vertices[0]);
114  VertexPointXYZ *vp = static_cast<VertexPointXYZ *>(_vertices[1]);
115 
116  Vector3D Zcam = cache->w2l() * vp->estimate();
117 
118  // J(0,3) = -0.0;
119  J(0,4) = -2*Zcam(2);
120  J(0,5) = 2*Zcam(1);
121 
122  J(1,3) = 2*Zcam(2);
123  // J(1,4) = -0.0;
124  J(1,5) = -2*Zcam(0);
125 
126  J(2,3) = -2*Zcam(1);
127  J(2,4) = 2*Zcam(0);
128  // J(2,5) = -0.0;
129 
130  J.block<3,3>(0,6) = cache->w2l().rotation();
131 
132  Eigen::Matrix<double,3,9,Eigen::ColMajor> Jhom = offsetParam->inverseOffset().rotation() * J;
133 
134  _jacobianOplusXi = Jhom.block<3,6>(0,0);
135  _jacobianOplusXj = Jhom.block<3,3>(0,6);
136 
137  // std::cerr << "just linearized." << std::endl;
138  // std::cerr << "_jacobianOplusXi:" << std::endl << _jacobianOplusXi << std::endl;
139  // std::cerr << "_jacobianOplusXj:" << std::endl << _jacobianOplusXj << std::endl;
140  }
Eigen::Matrix< double, 3, 9, Eigen::ColMajor > J
const Isometry3D & w2l() const
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
const Isometry3D & inverseOffset() const
rotation of the inverse offset as 3x3 rotation matrix
CacheSE3Offset * cache
ParameterSE3Offset * offsetParam
VertexContainer _vertices
Definition: hyper_graph.h:202
virtual int g2o::EdgeSE3PointXYZ::measurementDimension ( ) const
inlinevirtual

returns the dimension of the measurement in the extended representation which is used by get/setMeasurement;

Reimplemented from g2o::OptimizableGraph::Edge.

Definition at line 72 of file edge_se3_pointxyz.h.

72 {return 3;}
const ParameterSE3Offset* g2o::EdgeSE3PointXYZ::offsetParameter ( )
inline

Definition at line 84 of file edge_se3_pointxyz.h.

Referenced by initialEstimate().

84 { return offsetParam; }
ParameterSE3Offset * offsetParam
bool g2o::EdgeSE3PointXYZ::read ( std::istream &  is)
virtual

read the vertex from a stream, i.e., the internal state of the vertex

Implements g2o::OptimizableGraph::Edge.

Definition at line 63 of file edge_se3_pointxyz.cpp.

References g2o::BaseEdge< D, Vector3D >::information(), setMeasurement(), and g2o::OptimizableGraph::Edge::setParameterId().

63  {
64  int pId;
65  is >> pId;
66  setParameterId(0, pId);
67  // measured keypoint
68  Vector3D meas;
69  for (int i=0; i<3; i++) is >> meas[i];
70  setMeasurement(meas);
71  // information matrix is the identity for features, could be changed to allow arbitrary covariances
72  if (is.bad()) {
73  return false;
74  }
75  for ( int i=0; i<information().rows() && is.good(); i++)
76  for (int j=i; j<information().cols() && is.good(); j++){
77  is >> information()(i,j);
78  if (i!=j)
79  information()(j,i)=information()(i,j);
80  }
81  if (is.bad()) {
82  // we overwrite the information matrix
83  information().setIdentity();
84  }
85  return true;
86  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
bool setParameterId(int argNum, int paramId)
virtual void setMeasurement(const Vector3D &m)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67
bool g2o::EdgeSE3PointXYZ::resolveCaches ( )
privatevirtual

Reimplemented from g2o::OptimizableGraph::Edge.

Definition at line 55 of file edge_se3_pointxyz.cpp.

References g2o::HyperGraph::Edge::_vertices, cache, offsetParam, and g2o::OptimizableGraph::Edge::resolveCache().

55  {
56  ParameterVector pv(1);
57  pv[0]=offsetParam;
58  resolveCache(cache, (OptimizableGraph::Vertex*)_vertices[0],"CACHE_SE3_OFFSET",pv);
59  return cache != 0;
60  }
CacheSE3Offset * cache
class G2O_CORE_API Vertex
void resolveCache(CacheType *&cache, OptimizableGraph::Vertex *, const std::string &_type, const ParameterVector &parameters)
Definition: cache.h:122
std::vector< Parameter * > ParameterVector
Definition: parameter.h:52
ParameterSE3Offset * offsetParam
VertexContainer _vertices
Definition: hyper_graph.h:202
virtual void g2o::EdgeSE3PointXYZ::setMeasurement ( const Vector3D m)
inlinevirtual

Reimplemented from g2o::BaseEdge< D, Vector3D >.

Definition at line 56 of file edge_se3_pointxyz.h.

Referenced by g2o::SensorPointXYZ::addNoise(), and read().

56  {
57  _measurement = m;
58  }
virtual bool g2o::EdgeSE3PointXYZ::setMeasurementData ( const double *  m)
inlinevirtual

sets the measurement from an array of double

Returns
true on success

Reimplemented from g2o::OptimizableGraph::Edge.

Definition at line 60 of file edge_se3_pointxyz.h.

60  {
61  Eigen::Map<const Vector3D> v(d);
62  _measurement = v;
63  return true;
64  }
bool g2o::EdgeSE3PointXYZ::setMeasurementFromState ( )
virtual

sets the estimate to have a zero error, based on the current value of the state variables returns false if not supported.

Reimplemented from g2o::OptimizableGraph::Edge.

Definition at line 143 of file edge_se3_pointxyz.cpp.

References g2o::BaseEdge< D, Vector3D >::_measurement, g2o::HyperGraph::Edge::_vertices, cache, g2o::BaseVertex< D, T >::estimate(), and g2o::CacheSE3Offset::w2n().

Referenced by g2o::SensorPointXYZ::sense().

143  {
144  //VertexSE3 *cam = static_cast<VertexSE3*>(_vertices[0]);
145  VertexPointXYZ *point = static_cast<VertexPointXYZ*>(_vertices[1]);
146 
147  // calculate the projection
148  const Vector3D &pt = point->estimate();
149  // SE3OffsetCache* vcache = (SE3OffsetCache*) cam->getCache(_cacheIds[0]);
150  // if (! vcache){
151  // cerr << "fatal error in retrieving cache" << endl;
152  // }
153 
154  Vector3D perr = cache->w2n() * pt;
155  _measurement = perr;
156  return true;
157  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
const Isometry3D & w2n() const
CacheSE3Offset * cache
VertexContainer _vertices
Definition: hyper_graph.h:202
bool g2o::EdgeSE3PointXYZ::write ( std::ostream &  os) const
virtual

write the vertex to a stream

Implements g2o::OptimizableGraph::Edge.

Definition at line 88 of file edge_se3_pointxyz.cpp.

References g2o::Parameter::id(), g2o::BaseEdge< D, Vector3D >::information(), g2o::BaseEdge< D, Vector3D >::measurement(), and offsetParam.

88  {
89  os << offsetParam->id() << " ";
90  for (int i=0; i<3; i++) os << measurement()[i] << " ";
91  for (int i=0; i<information().rows(); i++)
92  for (int j=i; j<information().cols(); j++) {
93  os << information()(i,j) << " ";
94  }
95  return os.good();
96  }
int id() const
Definition: parameter.h:45
ParameterSE3Offset * offsetParam
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition: base_edge.h:75

Member Data Documentation

CacheSE3Offset* g2o::EdgeSE3PointXYZ::cache
private
Eigen::Matrix<double,3,9,Eigen::ColMajor> g2o::EdgeSE3PointXYZ::J
private

Definition at line 86 of file edge_se3_pointxyz.h.

Referenced by EdgeSE3PointXYZ(), and linearizeOplus().

ParameterSE3Offset* g2o::EdgeSE3PointXYZ::offsetParam
private

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