g2o
edge_se3_line.cpp
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 
27 #include "edge_se3_line.h"
28 
29 namespace g2o {
30 
32  information().setIdentity();
33  cache = 0;
34  offsetParam = 0;
37  }
38 
39  bool EdgeSE3Line3D::read(std::istream& is) {
40  int pId;
41  is >> pId;
42  setParameterId(0, pId);
43 
44  for (int i=0; i<6; i++)
45  is >> _measurement(i);
46  _measurement(6) = 1.;
47  information().setZero();
48  for (int i=0; i<6; i++)
49  for (int j=i; j<6; j++){
50  is >> information()(i,j);
51  information()(i,j) = information()(j,i);
52  }
53  information()(6,6) = 1e9; // normalization constraint
54  return is.good();
55  }
56 
57  bool EdgeSE3Line3D::write(std::ostream& os) const {
58  os << offsetParam->id() << " ";
59  for (int i=0; i<6; i++)
60  os << _measurement(i) << " ";
61  for (int i=0; i<6; i++)
62  for (int j=i; j<6; j++){
63  os << information()(i,j) << " ";
64  }
65  return os.good();
66  }
67 
69  const VertexLine3D* landmark=static_cast<const VertexLine3D*>(vertices()[1]);
70  Line3D projected(cache->w2n() * landmark->estimate());
71  projected.normalize();
72  _error.head(6) = _measurement.head<6>() - projected;
73  _error(6) = 0; // this is the normalization constraint
74  }
75 
77  ParameterVector pv(1);
78  pv[0]=offsetParam;
79  resolveCache(cache, (OptimizableGraph::Vertex*)_vertices[0],"CACHE_SE3_OFFSET",pv);
80  return cache != 0;
81  }
82 
83 }
bool installParameter(ParameterType *&p, size_t argNo, int paramId=-1)
const Isometry3D & w2n() const
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
virtual bool write(std::ostream &os) const
write the vertex to a stream
bool setParameterId(int argNum, int paramId)
const VertexContainer & vertices() const
Definition: hyper_graph.h:178
G2O_TYPES_SLAM3D_ADDONS_API void normalize()
Definition: line3d.h:84
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
int id() const
Definition: parameter.h:45
A general case Vertex for optimization.
void resizeParameters(size_t newSize)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67
const EstimateType & estimate() const
return the current estimate of the vertex
Definition: base_vertex.h:99
CacheSE3Offset * cache
Definition: edge_se3_line.h:80
ParameterSE3Offset * offsetParam
Definition: edge_se3_line.h:79
virtual bool resolveCaches()
VertexContainer _vertices
Definition: hyper_graph.h:202