g2o
Public Member Functions | List of all members
g2o::EdgeProjectP2MC Class Reference

#include <types_sba.h>

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

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeProjectP2MC ()
 
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 ()
 Jacobian for monocular projection. More...
 
- Public Member Functions inherited from g2o::BaseBinaryEdge< 2, Vector2D, VertexSBAPointXYZ, VertexCam >
 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, Vector2D >
 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 void setMeasurement (const Measurement &m)
 
virtual int rank () const
 
virtual void initialEstimate (const OptimizableGraph::VertexSet &, OptimizableGraph::Vertex *)
 
- Public Member Functions inherited from g2o::OptimizableGraph::Edge
 Edge ()
 
virtual ~Edge ()
 
virtual Edgeclone () const
 
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 More...
 
void setRobustKernel (RobustKernel *ptr)
 
virtual double initialEstimatePossible (const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
 
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)
 

Additional Inherited Members

- Public Types inherited from g2o::BaseBinaryEdge< 2, Vector2D, VertexSBAPointXYZ, VertexCam >
typedef VertexSBAPointXYZ VertexXiType
 
typedef VertexCam VertexXjType
 
typedef BaseEdge< D, Vector2D >::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, Vector2D >::ErrorVector ErrorVector
 
typedef BaseEdge< D, Vector2D >::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, Vector2D >
typedef Vector2D 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< 2, Vector2D, VertexSBAPointXYZ, VertexCam >
static const int Di
 
static const int Dj
 
static const int Dimension
 
- Static Public Attributes inherited from g2o::BaseEdge< D, Vector2D >
static const int Dimension
 
- Protected Member Functions inherited from g2o::BaseEdge< D, Vector2D >
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 ()
 
virtual bool resolveCaches ()
 
- Protected Attributes inherited from g2o::BaseBinaryEdge< 2, Vector2D, VertexSBAPointXYZ, VertexCam >
bool _hessianRowMajor
 
HessianBlockType _hessian
 
HessianBlockTransposedType _hessianTransposed
 
JacobianXiOplusType _jacobianOplusXi
 
JacobianXjOplusType _jacobianOplusXj
 
- Protected Attributes inherited from g2o::BaseEdge< D, Vector2D >
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

Definition at line 159 of file types_sba.h.

Constructor & Destructor Documentation

g2o::EdgeProjectP2MC::EdgeProjectP2MC ( )

Definition at line 199 of file types_sba.cpp.

References g2o::BaseEdge< D, Vector2D >::information().

199  :
200  BaseBinaryEdge<2, Vector2D, VertexSBAPointXYZ, VertexCam>()
201  {
202  information().setIdentity();
203  }
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67

Member Function Documentation

void g2o::EdgeProjectP2MC::computeError ( )
inlinevirtual

Implements g2o::OptimizableGraph::Edge.

Definition at line 168 of file types_sba.h.

References g2o::BaseVertex< D, T >::estimate(), and g2o::SBACam::w2i.

169  {
170  // from <Point> to <Cam>
171  const VertexSBAPointXYZ *point = static_cast<const VertexSBAPointXYZ*>(_vertices[0]);
172  const VertexCam *cam = static_cast<const VertexCam*>(_vertices[1]);
173 
174  // calculate the projection
175  const Vector3D &pt = point->estimate();
176  Vector4D ppt(pt(0),pt(1),pt(2),1.0);
177  Vector3D p = cam->estimate().w2i * ppt;
178  Vector2D perr;
179  perr = p.head<2>()/p(2);
180  // std::cout << std::endl << "CAM " << cam->estimate() << std::endl;
181  // std::cout << "POINT " << pt.transpose() << std::endl;
182  // std::cout << "PROJ " << p.transpose() << std::endl;
183  // std::cout << "CPROJ " << perr.transpose() << std::endl;
184  // std::cout << "MEAS " << _measurement.transpose() << std::endl;
185 
186  // error, which is backwards from the normal observed - calculated
187  // _measurement is the measured projection
188  _error = perr - _measurement;
189  // std::cerr << _error.x() << " " << _error.y() << " " << chi2() << std::endl;
190  }
Eigen::Matrix< double, 2, 1, Eigen::ColMajor > Vector2D
Definition: eigen_types.h:45
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
Eigen::Matrix< double, 4, 1, Eigen::ColMajor > Vector4D
Definition: eigen_types.h:47
VertexContainer _vertices
Definition: hyper_graph.h:202
void g2o::EdgeProjectP2MC::linearizeOplus ( )
virtual

Jacobian for monocular projection.

Reimplemented from g2o::BaseBinaryEdge< 2, Vector2D, VertexSBAPointXYZ, VertexCam >.

Definition at line 335 of file types_sba.cpp.

References g2o::BaseBinaryEdge< 3, Vector3D, VertexSBAPointXYZ, VertexCam >::_jacobianOplusXi, g2o::BaseBinaryEdge< 3, Vector3D, VertexSBAPointXYZ, VertexCam >::_jacobianOplusXj, g2o::HyperGraph::Edge::_vertices, g2o::SBACam::dRdx, g2o::SBACam::dRdy, g2o::SBACam::dRdz, g2o::BaseVertex< D, T >::estimate(), g2o_isnan, g2o::SBACam::Kcam, g2o::SE3Quat::translation(), and g2o::SBACam::w2n.

336  {
337  VertexCam *vc = static_cast<VertexCam *>(_vertices[1]);
338  const SBACam &cam = vc->estimate();
339 
340  VertexSBAPointXYZ *vp = static_cast<VertexSBAPointXYZ *>(_vertices[0]);
341  Vector4D pt, trans;
342  pt.head<3>() = vp->estimate();
343  pt(3) = 1.0;
344  trans.head<3>() = cam.translation();
345  trans(3) = 1.0;
346 
347  // first get the world point in camera coords
348  Eigen::Matrix<double,3,1,Eigen::ColMajor> pc = cam.w2n * pt;
349 
350  // Jacobians wrt camera parameters
351  // set d(quat-x) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
352  double px = pc(0);
353  double py = pc(1);
354  double pz = pc(2);
355  double ipz2 = 1.0/(pz*pz);
356  if (g2o_isnan(ipz2) ) {
357  std::cout << "[SetJac] infinite jac" << std::endl;
358  abort();
359  }
360 
361  double ipz2fx = ipz2*cam.Kcam(0,0); // Fx
362  double ipz2fy = ipz2*cam.Kcam(1,1); // Fy
363 
364  Eigen::Matrix<double,3,1,Eigen::ColMajor> pwt;
365 
366  // check for local vars
367  pwt = (pt-trans).head<3>(); // transform translations, use differential rotation
368 
369  // dx
370  Eigen::Matrix<double,3,1,Eigen::ColMajor> dp = cam.dRdx * pwt; // dR'/dq * [pw - t]
371  _jacobianOplusXj(0,3) = (pz*dp(0) - px*dp(2))*ipz2fx;
372  _jacobianOplusXj(1,3) = (pz*dp(1) - py*dp(2))*ipz2fy;
373  // dy
374  dp = cam.dRdy * pwt; // dR'/dq * [pw - t]
375  _jacobianOplusXj(0,4) = (pz*dp(0) - px*dp(2))*ipz2fx;
376  _jacobianOplusXj(1,4) = (pz*dp(1) - py*dp(2))*ipz2fy;
377  // dz
378  dp = cam.dRdz * pwt; // dR'/dq * [pw - t]
379  _jacobianOplusXj(0,5) = (pz*dp(0) - px*dp(2))*ipz2fx;
380  _jacobianOplusXj(1,5) = (pz*dp(1) - py*dp(2))*ipz2fy;
381 
382  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
383  dp = -cam.w2n.col(0); // dpc / dx
384  _jacobianOplusXj(0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
385  _jacobianOplusXj(1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
386  dp = -cam.w2n.col(1); // dpc / dy
387  _jacobianOplusXj(0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
388  _jacobianOplusXj(1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
389  dp = -cam.w2n.col(2); // dpc / dz
390  _jacobianOplusXj(0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
391  _jacobianOplusXj(1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
392 
393  // Jacobians wrt point parameters
394  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
395  dp = cam.w2n.col(0); // dpc / dx
396  _jacobianOplusXi(0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
397  _jacobianOplusXi(1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
398  dp = cam.w2n.col(1); // dpc / dy
399  _jacobianOplusXi(0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
400  _jacobianOplusXi(1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
401  dp = cam.w2n.col(2); // dpc / dz
402  _jacobianOplusXi(0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
403  _jacobianOplusXi(1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
404  }
Eigen::Matrix< double, 4, 1, Eigen::ColMajor > Vector4D
Definition: eigen_types.h:47
#define g2o_isnan(x)
Definition: macros.h:99
VertexContainer _vertices
Definition: hyper_graph.h:202
bool g2o::EdgeProjectP2MC::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 205 of file types_sba.cpp.

References g2o::BaseEdge< D, Vector2D >::_measurement, g2o::BaseEdge< D, Vector2D >::information(), and g2o::BaseEdge< D, Vector2D >::setMeasurement().

206  {
207  // measured keypoint
208  for (int i=0; i<2; i++)
209  is >> _measurement[i];
211  // information matrix is the identity for features, could be changed to allow arbitrary covariances
212  information().setIdentity();
213  return true;
214  }
virtual void setMeasurement(const Measurement &m)
Definition: base_edge.h:76
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67
bool g2o::EdgeProjectP2MC::write ( std::ostream &  os) const
virtual

write the vertex to a stream

Implements g2o::OptimizableGraph::Edge.

Definition at line 216 of file types_sba.cpp.

References g2o::BaseEdge< D, Vector2D >::measurement().

217  {
218  for (int i=0; i<2; i++)
219  os << measurement()[i] << " ";
220  return os.good();
221  }
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition: base_edge.h:75

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