g2o
types_sba.cpp
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 Kurt Konolige
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 #include "types_sba.h"
28 #include <iostream>
29 
30 #include "g2o/core/factory.h"
31 #include "g2o/stuff/macros.h"
32 
33 namespace g2o {
34 
35  using namespace std;
36  using namespace Eigen;
37 
39 
40  G2O_REGISTER_TYPE(VERTEX_CAM, VertexCam);
41  G2O_REGISTER_TYPE(VERTEX_XYZ, VertexSBAPointXYZ);
42  G2O_REGISTER_TYPE(VERTEX_INTRINSICS, VertexIntrinsics);
43 
44  G2O_REGISTER_TYPE(EDGE_PROJECT_P2MC, EdgeProjectP2MC);
45  G2O_REGISTER_TYPE(EDGE_PROJECT_P2MC_INTRINSICS, EdgeProjectP2MC_Intrinsics);
46  G2O_REGISTER_TYPE(EDGE_PROJECT_P2SC, EdgeProjectP2SC);
47  G2O_REGISTER_TYPE(EDGE_CAM, EdgeSBACam);
48  G2O_REGISTER_TYPE(EDGE_SCALE, EdgeSBAScale);
49 
50  // constructor
52  {
53  _estimate << 1. , 1. , .5 , .5 , .1;
54  }
55 
56  bool VertexIntrinsics::read(std::istream& is)
57  {
58  for (int i=0; i<5; i++)
59  is >> _estimate[i];
60  return true;
61  }
62 
63  bool VertexIntrinsics::write(std::ostream& os) const
64  {
65  for (int i=0; i<5; i++)
66  os << _estimate[i] << " ";
67  return os.good();
68  }
69 
70  // constructor
72  {
73  }
74 
75  bool VertexCam::read(std::istream& is)
76  {
77  // first the position and orientation (vector3 and quaternion)
78  Vector3D t;
79  for (int i=0; i<3; i++){
80  is >> t[i];
81  }
82  Vector4D rc;
83  for (int i=0; i<4; i++) {
84  is >> rc[i];
85  }
86  Quaterniond r;
87  r.coeffs() = rc;
88  r.normalize();
89 
90 
91  // form the camera object
92  SBACam cam(r,t);
93 
94  // now fx, fy, cx, cy, baseline
95  double fx, fy, cx, cy, tx;
96 
97  // try to read one value
98  is >> fx;
99  if (is.good()) {
100  is >> fy >> cx >> cy >> tx;
101  cam.setKcam(fx,fy,cx,cy,tx);
102  } else{
103  is.clear();
104  std::cerr << "cam not defined, using defaults" << std::endl;
105  cam.setKcam(300,300,320,320,0.1);
106  }
107 
108  // set the object
109  setEstimate(cam);
110  // std::cout << cam << std::endl;
111 
112  return true;
113  }
114 
115  bool VertexCam::write(std::ostream& os) const
116  {
117  const SBACam &cam = estimate();
118 
119  // first the position and orientation (vector3 and quaternion)
120  for (int i=0; i<3; i++)
121  os << cam.translation()[i] << " ";
122  for (int i=0; i<4; i++)
123  os << cam.rotation().coeffs()[i] << " ";
124 
125  // now fx, fy, cx, cy, baseline
126  os << cam.Kcam(0,0) << " ";
127  os << cam.Kcam(1,1) << " ";
128  os << cam.Kcam(0,2) << " ";
129  os << cam.Kcam(1,2) << " ";
130  os << cam.baseline << " ";
131  return os.good();
132  }
133 
136  {
137  }
138 
139  bool EdgeSBACam::read(std::istream& is)
140  {
141  Vector7d meas;
142  for (int i=0; i<7; i++)
143  is >> meas[i];
144  setMeasurement(SE3Quat(meas));
145 
146  for (int i=0; i<6; i++)
147  for (int j=i; j<6; j++) {
148  is >> information()(i,j);
149  if (i!=j)
150  information()(j,i)=information()(i,j);
151  }
152  return true;
153  }
154 
155  bool EdgeSBACam::write(std::ostream& os) const
156  {
157  for (int i=0; i<7; i++)
158  os << measurement()[i] << " ";
159  for (int i=0; i<6; i++)
160  for (int j=i; j<6; j++){
161  os << " " << information()(i,j);
162  }
163  return os.good();
164  }
165 
167  {
168  VertexCam* from = static_cast<VertexCam*>(_vertices[0]);
169  VertexCam* to = static_cast<VertexCam*>(_vertices[1]);
170  if (from_.count(from) > 0)
171  to->setEstimate((SE3Quat) from->estimate() * _measurement);
172  else
174  }
175 
176 
178  {
179  }
180 
181  bool VertexSBAPointXYZ::read(std::istream& is)
182  {
183  Vector3D lv;
184  for (int i=0; i<3; i++)
185  is >> _estimate[i];
186  return true;
187  }
188 
189  bool VertexSBAPointXYZ::write(std::ostream& os) const
190  {
191  Vector3D lv=estimate();
192  for (int i=0; i<3; i++){
193  os << lv[i] << " ";
194  }
195  return os.good();
196  }
197 
198  // point to camera projection, monocular
201  {
202  information().setIdentity();
203  }
204 
205  bool EdgeProjectP2MC::read(std::istream& is)
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  }
215 
216  bool EdgeProjectP2MC::write(std::ostream& os) const
217  {
218  for (int i=0; i<2; i++)
219  os << measurement()[i] << " ";
220  return os.good();
221  }
222 
223  // point to camera projection, stereo
226  {
227  }
228 
229  bool EdgeProjectP2SC::read(std::istream& is)
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  }
239 
240  bool EdgeProjectP2SC::write(std::ostream& os) const
241  {
242  for (int i=0; i<3; i++)
243  os << measurement()[i] << " ";
244  return os.good();
245  }
246 
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  }
330 
331 
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  }
405 
406 
407 
408  // point to camera projection, monocular
410  BaseMultiEdge<2, Vector2D>()
411  {
412  information().setIdentity();
413  resize(3);
414  }
415 
420  {
421  _jacobianOplus[0].resize(2,3);
422  _jacobianOplus[1].resize(2,6);
423  _jacobianOplus[2].resize(2,4);
424  VertexCam *vc = static_cast<VertexCam *>(_vertices[1]);
425  const SBACam &cam = vc->estimate();
426 
427  VertexSBAPointXYZ *vp = static_cast<VertexSBAPointXYZ *>(_vertices[0]);
428 
429  //VertexIntrinsics *intr = static_cast<VertexIntrinsics *>(_vertices[2]);
430 
431  Vector4D pt, trans;
432  pt.head<3>() = vp->estimate();
433  pt(3) = 1.0;
434  trans.head<3>() = cam.translation();
435  trans(3) = 1.0;
436 
437  // first get the world point in camera coords
438  Eigen::Matrix<double,3,1,Eigen::ColMajor> pc = cam.w2n * pt;
439 
440  // Jacobians wrt camera parameters
441  // set d(quat-x) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
442  double px = pc(0);
443  double py = pc(1);
444  double pz = pc(2);
445  double ipz2 = 1.0/(pz*pz);
446  if (g2o_isnan(ipz2) ) {
447  std::cout << "[SetJac] infinite jac" << std::endl;
448  abort();
449  }
450 
451  double ipz2fx = ipz2*cam.Kcam(0,0); // Fx
452  double ipz2fy = ipz2*cam.Kcam(1,1); // Fy
453 
454  Eigen::Matrix<double,3,1,Eigen::ColMajor> pwt;
455 
456  // check for local vars
457  pwt = (pt-trans).head<3>(); // transform translations, use differential rotation
458 
459  // dx
460  Eigen::Matrix<double,3,1,Eigen::ColMajor> dp = cam.dRdx * pwt; // dR'/dq * [pw - t]
461  _jacobianOplus[1](0,3) = (pz*dp(0) - px*dp(2))*ipz2fx;
462  _jacobianOplus[1](1,3) = (pz*dp(1) - py*dp(2))*ipz2fy;
463  // dy
464  dp = cam.dRdy * pwt; // dR'/dq * [pw - t]
465  _jacobianOplus[1](0,4) = (pz*dp(0) - px*dp(2))*ipz2fx;
466  _jacobianOplus[1](1,4) = (pz*dp(1) - py*dp(2))*ipz2fy;
467  // dz
468  dp = cam.dRdz * pwt; // dR'/dq * [pw - t]
469  _jacobianOplus[1](0,5) = (pz*dp(0) - px*dp(2))*ipz2fx;
470  _jacobianOplus[1](1,5) = (pz*dp(1) - py*dp(2))*ipz2fy;
471 
472  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
473  dp = -cam.w2n.col(0); // dpc / dx
474  _jacobianOplus[1](0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
475  _jacobianOplus[1](1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
476  dp = -cam.w2n.col(1); // dpc / dy
477  _jacobianOplus[1](0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
478  _jacobianOplus[1](1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
479  dp = -cam.w2n.col(2); // dpc / dz
480  _jacobianOplus[1](0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
481  _jacobianOplus[1](1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
482 
483  // Jacobians wrt point parameters
484  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
485  dp = cam.w2n.col(0); // dpc / dx
486  _jacobianOplus[0](0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
487  _jacobianOplus[0](1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
488  dp = cam.w2n.col(1); // dpc / dy
489  _jacobianOplus[0](0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
490  _jacobianOplus[0](1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
491  dp = cam.w2n.col(2); // dpc / dz
492  _jacobianOplus[0](0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
493  _jacobianOplus[0](1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
494 
495  // Jacobians w.r.t the intrinsics
496  _jacobianOplus[2].setZero();
497  _jacobianOplus[2](0,0) = px/pz; // dx/dfx
498  _jacobianOplus[2](1,1) = py/pz; // dy/dfy
499  _jacobianOplus[2](0,2) = 1.; // dx/dcx
500  _jacobianOplus[2](1,3) = 1.; // dy/dcy
501  }
502 
503  bool EdgeProjectP2MC_Intrinsics::read(std::istream& is)
504  {
505  // measured keypoint
506  Vector2D meas;
507  for (int i=0; i<2; i++)
508  is >> meas[i];
509  setMeasurement(meas);
510  // information matrix is the identity for features, could be changed to allow arbitrary covariances
511  information().setIdentity();
512  return true;
513  }
514 
515  bool EdgeProjectP2MC_Intrinsics::write(std::ostream& os) const
516  {
517  for (int i=0; i<2; i++)
518  os << measurement()[i] << " ";
519  return os.good();
520  }
521 
522 
523  // point to camera projection, stereo
525  BaseBinaryEdge<1, double, VertexCam, VertexCam>()
526  {
527  }
528 
529  bool EdgeSBAScale::read(std::istream& is)
530  {
531  double meas;
532  is >> meas;
533  setMeasurement(meas);
534  information().setIdentity();
535  is >> information()(0,0);
536  return true;
537  }
538 
539  bool EdgeSBAScale::write(std::ostream& os) const
540  {
541  os << measurement() << " " << information()(0,0);
542  return os.good();
543  }
544 
546  {
547  VertexCam* v1 = dynamic_cast<VertexCam*>(_vertices[0]);
548  VertexCam* v2 = dynamic_cast<VertexCam*>(_vertices[1]);
549  //compute the translation vector of v1 w.r.t v2
550  if (from_.count(v1) == 1){
551  SE3Quat delta = (v1->estimate().inverse()*v2->estimate());
552  double norm = delta.translation().norm();
553  double alpha = _measurement/norm;
554  delta.setTranslation(delta.translation()*alpha);
555  v2->setEstimate(v1->estimate()*delta);
556  } else {
557  SE3Quat delta = (v2->estimate().inverse()*v1->estimate());
558  double norm = delta.translation().norm();
559  double alpha = _measurement/norm;
560  delta.setTranslation(delta.translation()*alpha);
561  v1->setEstimate(v2->estimate()*delta);
562  }
563  }
564 
566  {
567  const VertexCam* v1 = dynamic_cast<const VertexCam*>(_vertices[0]);
568  const VertexCam* v2 = dynamic_cast<const VertexCam*>(_vertices[1]);
569  _measurement = (v1->estimate().inverse()*v2->estimate());
570  _inverseMeasurement = _measurement.inverse();
571  return true;
572  }
573 
574 } // end namespace
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeSBAScale()
Definition: types_sba.cpp:524
Eigen::Matrix< double, 2, 1, Eigen::ColMajor > Vector2D
Definition: eigen_types.h:45
virtual void linearizeOplus()
Jacobian for monocular projection with intrinsics calibration.
Definition: types_sba.cpp:419
virtual bool setMeasurementFromState()
Definition: types_sba.cpp:565
G2O_REGISTER_TYPE(VERTEX_TAG, VertexTag)
double baseline
Definition: sbacam.h:64
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:205
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:189
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:181
Eigen::Matrix< double, 4, 1, Eigen::ColMajor > Vector4D
Definition: eigen_types.h:47
std::set< Vertex * > VertexSet
Definition: hyper_graph.h:136
virtual void linearizeOplus()
Jacobian for stereo projection.
Definition: types_sba.cpp:250
Eigen::Matrix3d dRdx
Definition: sbacam.h:72
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeProjectP2SC()
Definition: types_sba.cpp:224
Eigen::Matrix3d dRdz
Definition: sbacam.h:72
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:229
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:503
Templatized BaseVertex.
Definition: base_vertex.h:50
virtual void setMeasurement(const Measurement &m)
Definition: base_edge.h:76
Eigen::Matrix< double, 7, 1 > Vector7d
Definition: sim3.h:35
Eigen::Matrix3d Kcam
Definition: sbacam.h:63
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:155
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:115
SE3Quat inverse() const
Definition: se3quat.h:120
virtual void setEstimate(const SBACam &cam)
Definition: types_sba.h:84
Point vertex, XYZ.
Definition: types_sba.h:137
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeProjectP2MC_Intrinsics()
Definition: types_sba.cpp:409
SBACam Vertex, (x,y,z,qw,qx,qy,qz) the parameterization for the increments constructed is a 6d vector...
Definition: types_sba.h:71
Eigen::Matrix3d dRdy
Definition: sbacam.h:72
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:539
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:75
SE3Quat _inverseMeasurement
Definition: types_sba.h:331
virtual void initialEstimate(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
Definition: types_sba.cpp:166
base class to represent an edge connecting an arbitrary number of nodes
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeProjectP2MC()
Definition: types_sba.cpp:199
const Eigen::Quaterniond & rotation() const
Definition: se3quat.h:97
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:515
A general case Vertex for optimization.
void setTranslation(const Vector3D &t_)
Definition: se3quat.h:95
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:240
EIGEN_MAKE_ALIGNED_OPERATOR_NEW VertexSBAPointXYZ()
Definition: types_sba.cpp:177
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:56
EIGEN_MAKE_ALIGNED_OPERATOR_NEW VertexIntrinsics()
Definition: types_sba.cpp:51
#define g2o_isnan(x)
Definition: macros.h:99
virtual void resize(size_t size)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67
G2O_REGISTER_TYPE_GROUP(data)
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:63
const EstimateType & estimate() const
return the current estimate of the vertex
Definition: base_vertex.h:99
virtual void setMeasurement(const double &m)
Definition: types_sba.h:352
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:529
void setKcam(double fx, double fy, double cx, double cy, double tx)
Definition: sbacam.h:138
Eigen::Matrix< double, 3, 4 > w2n
Definition: sbacam.h:67
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition: types_sba.cpp:139
virtual void linearizeOplus()
Jacobian for monocular projection.
Definition: types_sba.cpp:335
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition: types_sba.cpp:216
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition: base_edge.h:75
virtual void initialEstimate(const OptimizableGraph::VertexSet &from_, OptimizableGraph::Vertex *to_)
Definition: types_sba.cpp:545
std::vector< JacobianType, Eigen::aligned_allocator< JacobianType > > _jacobianOplus
jacobians of the edge (w.r.t. oplus)
virtual void setMeasurement(const SE3Quat &meas)
Definition: types_sba.h:305
const Vector3D & translation() const
Definition: se3quat.h:93
VertexContainer _vertices
Definition: hyper_graph.h:202