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

#include <types_sba.h>

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

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeProjectP2SC ()
 
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 stereo projection. More...
 
- Public Member Functions inherited from g2o::BaseBinaryEdge< 3, Vector3D, 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, 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 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< 3, Vector3D, VertexSBAPointXYZ, VertexCam >
typedef VertexSBAPointXYZ VertexXiType
 
typedef VertexCam 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, VertexSBAPointXYZ, VertexCam >
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 ()
 
virtual bool resolveCaches ()
 
- Protected Attributes inherited from g2o::BaseBinaryEdge< 3, Vector3D, VertexSBAPointXYZ, VertexCam >
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

Definition at line 198 of file types_sba.h.

Constructor & Destructor Documentation

g2o::EdgeProjectP2SC::EdgeProjectP2SC ( )

Definition at line 224 of file types_sba.cpp.

224  :
225  BaseBinaryEdge<3, Vector3D, VertexSBAPointXYZ, VertexCam>()
226  {
227  }

Member Function Documentation

void g2o::EdgeProjectP2SC::computeError ( )
inlinevirtual

Implements g2o::OptimizableGraph::Edge.

Definition at line 207 of file types_sba.h.

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

208  {
209  // from <Point> to <Cam>
210  const VertexSBAPointXYZ *point = static_cast<const VertexSBAPointXYZ*>(_vertices[0]);
211  VertexCam *cam = static_cast<VertexCam*>(_vertices[1]);
212 
213  // calculate the projection
214  Vector3D kp;
215  Vector4D pt;
216  pt.head<3>() = point->estimate();
217  pt(3) = 1.0;
218  const SBACam& nd = cam->estimate();
219  // these should be already ok
220  /* nd.setTransform(); */
221  /* nd.setProjection(); */
222  /* nd.setDr(); */
223 
224  Vector3D p1 = nd.w2i * pt;
225  Vector3D p2 = nd.w2n * pt;
226  Vector3D pb(nd.baseline,0,0);
227 
228  double invp1 = 1.0/p1(2);
229  kp.head<2>() = p1.head<2>()*invp1;
230 
231  // right camera px
232  p2 = nd.Kcam*(p2-pb);
233  kp(2) = p2(0)/p2(2);
234 
235  // std::cout << std::endl << "CAM " << cam->estimate() << std::endl;
236  // std::cout << "POINT " << pt.transpose() << std::endl;
237  // std::cout << "PROJ " << p1.transpose() << std::endl;
238  // std::cout << "PROJ " << p2.transpose() << std::endl;
239  // std::cout << "CPROJ " << kp.transpose() << std::endl;
240  // std::cout << "MEAS " << _measurement.transpose() << std::endl;
241 
242  // error, which is backwards from the normal observed - calculated
243  // _measurement is the measured projection
244  _error = kp - _measurement;
245  }
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::EdgeProjectP2SC::linearizeOplus ( )
virtual

Jacobian for stereo projection.

Reimplemented from g2o::BaseBinaryEdge< 3, Vector3D, VertexSBAPointXYZ, VertexCam >.

Definition at line 250 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::baseline, 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.

251  {
252  VertexCam *vc = static_cast<VertexCam *>(_vertices[1]);
253  const SBACam &cam = vc->estimate();
254 
255  VertexSBAPointXYZ *vp = static_cast<VertexSBAPointXYZ *>(_vertices[0]);
256  Vector4D pt, trans;
257  pt.head<3>() = vp->estimate();
258  pt(3) = 1.0;
259  trans.head<3>() = cam.translation();
260  trans(3) = 1.0;
261 
262  // first get the world point in camera coords
263  Eigen::Matrix<double,3,1,Eigen::ColMajor> pc = cam.w2n * pt;
264 
265  // Jacobians wrt camera parameters
266  // set d(quat-x) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
267  double px = pc(0);
268  double py = pc(1);
269  double pz = pc(2);
270  double ipz2 = 1.0/(pz*pz);
271  if (g2o_isnan(ipz2) ) {
272  std::cout << "[SetJac] infinite jac" << std::endl;
273  abort();
274  }
275 
276  double ipz2fx = ipz2*cam.Kcam(0,0); // Fx
277  double ipz2fy = ipz2*cam.Kcam(1,1); // Fy
278  double b = cam.baseline; // stereo baseline
279 
280  Eigen::Matrix<double,3,1,Eigen::ColMajor> pwt;
281 
282  // check for local vars
283  pwt = (pt-trans).head<3>(); // transform translations, use differential rotation
284 
285  // dx
286  Eigen::Matrix<double,3,1,Eigen::ColMajor> dp = cam.dRdx * pwt; // dR'/dq * [pw - t]
287  _jacobianOplusXj(0,3) = (pz*dp(0) - px*dp(2))*ipz2fx;
288  _jacobianOplusXj(1,3) = (pz*dp(1) - py*dp(2))*ipz2fy;
289  _jacobianOplusXj(2,3) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
290  // dy
291  dp = cam.dRdy * pwt; // dR'/dq * [pw - t]
292  _jacobianOplusXj(0,4) = (pz*dp(0) - px*dp(2))*ipz2fx;
293  _jacobianOplusXj(1,4) = (pz*dp(1) - py*dp(2))*ipz2fy;
294  _jacobianOplusXj(2,4) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
295  // dz
296  dp = cam.dRdz * pwt; // dR'/dq * [pw - t]
297  _jacobianOplusXj(0,5) = (pz*dp(0) - px*dp(2))*ipz2fx;
298  _jacobianOplusXj(1,5) = (pz*dp(1) - py*dp(2))*ipz2fy;
299  _jacobianOplusXj(2,5) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
300 
301  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
302  dp = -cam.w2n.col(0); // dpc / dx
303  _jacobianOplusXj(0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
304  _jacobianOplusXj(1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
305  _jacobianOplusXj(2,0) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
306  dp = -cam.w2n.col(1); // dpc / dy
307  _jacobianOplusXj(0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
308  _jacobianOplusXj(1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
309  _jacobianOplusXj(2,1) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
310  dp = -cam.w2n.col(2); // dpc / dz
311  _jacobianOplusXj(0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
312  _jacobianOplusXj(1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
313  _jacobianOplusXj(2,2) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
314 
315  // Jacobians wrt point parameters
316  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
317  dp = cam.w2n.col(0); // dpc / dx
318  _jacobianOplusXi(0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
319  _jacobianOplusXi(1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
320  _jacobianOplusXi(2,0) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
321  dp = cam.w2n.col(1); // dpc / dy
322  _jacobianOplusXi(0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
323  _jacobianOplusXi(1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
324  _jacobianOplusXi(2,1) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
325  dp = cam.w2n.col(2); // dpc / dz
326  _jacobianOplusXi(0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
327  _jacobianOplusXi(1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
328  _jacobianOplusXi(2,2) = (pz*dp(0) - (px-b)*dp(2))*ipz2fx; // right image px
329  }
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::EdgeProjectP2SC::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 229 of file types_sba.cpp.

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

230  {
231  Vector3D meas;
232  for (int i=0; i<3; i++)
233  is >> meas[i];
234  setMeasurement(meas);
235  // information matrix is the identity for features, could be changed to allow arbitrary covariances
236  information().setIdentity();
237  return true;
238  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
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::EdgeProjectP2SC::write ( std::ostream &  os) const
virtual

write the vertex to a stream

Implements g2o::OptimizableGraph::Edge.

Definition at line 240 of file types_sba.cpp.

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

241  {
242  for (int i=0; i<3; i++)
243  os << measurement()[i] << " ";
244  return os.good();
245  }
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: