g2o
edge_se2_odom_differential_calib.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 
28 
29 #ifdef G2O_HAVE_OPENGL
31 #endif
32 
33 namespace g2o {
34 
37  {
38  resize(3);
39  }
40 
41  bool EdgeSE2OdomDifferentialCalib::read(std::istream& is)
42  {
43  double vl, vr, dt;
44  is >> vl >> vr >> dt;
45  VelocityMeasurement vm(vl, vr, dt);
46  setMeasurement(vm);
47  for (int i = 0; i < information().rows(); ++i)
48  for (int j = i; j < information().cols(); ++j) {
49  is >> information()(i, j);
50  if (i != j)
51  information()(j, i) = information()(i, j);
52  }
53  return true;
54  }
55 
56  bool EdgeSE2OdomDifferentialCalib::write(std::ostream& os) const
57  {
58  os << measurement().vl() << " " << measurement().vr() << " " << measurement().dt();
59  for (int i = 0; i < information().rows(); ++i)
60  for (int j = i; j < information().cols(); ++j)
61  os << " " << information()(i, j);
62  return os.good();
63  }
64 
65 #ifdef G2O_HAVE_OPENGL
66  EdgeSE2OdomDifferentialCalibDrawAction::EdgeSE2OdomDifferentialCalibDrawAction() :
68  {
69  }
70 
71  HyperGraphElementAction* EdgeSE2OdomDifferentialCalibDrawAction::operator()(HyperGraph::HyperGraphElement* element, HyperGraphElementAction::Parameters* )
72  {
73  if (typeid(*element).name()!=_typeName)
74  return 0;
76  VertexSE2* fromEdge = static_cast<VertexSE2*>(e->vertex(0));
77  VertexSE2* toEdge = static_cast<VertexSE2*>(e->vertex(1));
78  glColor3f(0.5f,0.5f,0.5f);
79  glPushAttrib(GL_ENABLE_BIT);
80  glDisable(GL_LIGHTING);
81  glBegin(GL_LINES);
82  glVertex3f((float)fromEdge->estimate().translation().x(),(float)fromEdge->estimate().translation().y(),0.f);
83  glVertex3f((float)toEdge->estimate().translation().x(),(float)toEdge->estimate().translation().y(),0.f);
84  glEnd();
85  glPopAttrib();
86  return this;
87  }
88 #endif
89 
90 } // end namespace
const Vertex * vertex(size_t i) const
Definition: hyper_graph.h:186
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Abstract action that operates on a graph entity.
virtual void setMeasurement(const Measurement &m)
Definition: base_edge.h:76
2D pose Vertex, (x,y,theta)
Definition: vertex_se2.h:41
virtual bool write(std::ostream &os) const
write the vertex to a stream
velocity measurement of a differential robot
base class to represent an edge connecting an arbitrary number of nodes
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
const Vector2D & translation() const
translational component
Definition: se2.h:54
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition: base_edge.h:75