edge_xy_prior.h
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
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 
31 #ifndef G2O_EDGE_XY_PRIOR_H
32 #define G2O_EDGE_XY_PRIOR_H
33 
34 #include "g2o/types/slam2d/vertex_point_xy.h"
35 #include "g2o/config.h"
36 #include "g2o/core/base_unary_edge.h"
37 
38 namespace g2o {
39 
40 using namespace Eigen;
41 
42  class EdgeXYPrior : public BaseUnaryEdge<2, Vector2d, VertexPointXY>
43  {
44  public:
46  EdgeXYPrior();
47 
48  void computeError()
49  {
50  const VertexPointXY* v = static_cast<const VertexPointXY*>(_vertices[0]);
51  _error = v->estimate()-_measurement;
52  }
53  virtual bool read(std::istream& is);
54  virtual bool write(std::ostream& os) const;
55 
56  virtual void setMeasurement(const Vector2d& m){
57  _measurement = m;
58  }
59 
60  virtual bool setMeasurementData(const double* d){
61  _measurement=Vector2d(d[0], d[1]);
62  return true;
63  }
64 
65  virtual bool getMeasurementData(double* d) const {
67  m=_measurement;
68  return true;
69  }
70 
71  virtual int measurementDimension() const {return 2;}
72 
73  virtual bool setMeasurementFromState() {
74  const VertexPointXY* v = static_cast<const VertexPointXY*>(_vertices[0]);
75  _measurement = v->estimate();
76  return true;
77  }
78 
79 
80  virtual double initialEstimatePossible(const OptimizableGraph::VertexSet& , OptimizableGraph::Vertex* ) { return 0.;}
81 #ifndef NUMERIC_JACOBIAN_TWO_D_TYPES
82  virtual void linearizeOplus();
83 #endif
84  };
85 
87  BaseUnaryEdge<2, Vector2d, VertexPointXY>()
88  {
89  _information.setIdentity();
90  _error.setZero();
91  }
92 
93  bool EdgeXYPrior::read(std::istream& is)
94  {
95  Vector2d p;
96  is >> p[0] >> p[1];
98  for (int i = 0; i < 2; ++i)
99  for (int j = i; j < 2; ++j) {
100  is >> information()(i, j);
101  if (i != j)
102  information()(j, i) = information()(i, j);
103  }
104  return true;
105  }
106 
107  bool EdgeXYPrior::write(std::ostream& os) const
108  {
109  Vector2d p = measurement();
110  os << p.x() << " " << p.y();
111  for (int i = 0; i < 2; ++i)
112  for (int j = i; j < 2; ++j)
113  os << " " << information()(i, j);
114  return os.good();
115  }
116 
117 
118  #ifndef NUMERIC_JACOBIAN_TWO_D_TYPES
120  {
121  _jacobianOplusXi=Matrix2d::Identity();
122  }
123  #endif
124 
125 } // end namespace
126 
127 #endif
g2o::EdgeXYPrior::setMeasurementData
virtual bool setMeasurementData(const double *d)
Definition: edge_xy_prior.h:60
Eigen
g2o::EdgeXYPrior::setMeasurement
virtual void setMeasurement(const Vector2d &m)
Definition: edge_xy_prior.h:56
g2o::EdgeXYPrior::EdgeXYPrior
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeXYPrior()
Definition: edge_xy_prior.h:86
g2o::EdgeXYPrior::linearizeOplus
virtual void linearizeOplus()
Definition: edge_xy_prior.h:119
g2o::EdgeXYPrior::initialEstimatePossible
virtual double initialEstimatePossible(const OptimizableGraph::VertexSet &, OptimizableGraph::Vertex *)
Definition: edge_xy_prior.h:80
os
ofstream os("timeSchurFactors.csv")
g2o::EdgeXYPrior::getMeasurementData
virtual bool getMeasurementData(double *d) const
Definition: edge_xy_prior.h:65
g2o::EdgeXYPrior::read
virtual bool read(std::istream &is)
Definition: edge_xy_prior.h:93
j
std::ptrdiff_t j
g2o
Definition: edge_se3_xyzprior.h:34
d
d
m
Matrix3f m
p
Point3_ p(2)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Eigen::Map
g2o::EdgeXYPrior::setMeasurementFromState
virtual bool setMeasurementFromState()
Definition: edge_xy_prior.h:73
g2o::EdgeXYPrior::computeError
void computeError()
Definition: edge_xy_prior.h:48
g2o::EdgeXYPrior::write
virtual bool write(std::ostream &os) const
Definition: edge_xy_prior.h:107
v
Array< int, Dynamic, 1 > v
g2o::EdgeXYPrior
Definition: edge_xy_prior.h:42
i
int i
g2o::EdgeXYPrior::measurementDimension
virtual int measurementDimension() const
Definition: edge_xy_prior.h:71


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:09