g2o
Loading...
Searching...
No Matches
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
33namespace g2o {
34
38
39bool EdgeSE2OdomDifferentialCalib::read(std::istream& is) {
40 double vl, vr, dt;
41 is >> vl >> vr >> dt;
42 VelocityMeasurement vm(vl, vr, dt);
44 return readInformationMatrix(is);
45}
46
47bool EdgeSE2OdomDifferentialCalib::write(std::ostream& os) const {
48 os << measurement().vl() << " " << measurement().vr() << " "
49 << measurement().dt() << " ";
50 return writeInformationMatrix(os);
51}
52
53#ifdef G2O_HAVE_OPENGL
54EdgeSE2OdomDifferentialCalibDrawAction::EdgeSE2OdomDifferentialCalibDrawAction()
55 : DrawAction(typeid(EdgeSE2OdomDifferentialCalib).name()) {}
56
57HyperGraphElementAction* EdgeSE2OdomDifferentialCalibDrawAction::operator()(
58 HyperGraph::HyperGraphElement* element,
59 HyperGraphElementAction::Parameters*) {
60 if (typeid(*element).name() != _typeName) return nullptr;
61 EdgeSE2OdomDifferentialCalib* e =
62 static_cast<EdgeSE2OdomDifferentialCalib*>(element);
63 VertexSE2* fromEdge = static_cast<VertexSE2*>(e->vertex(0));
64 VertexSE2* toEdge = static_cast<VertexSE2*>(e->vertex(1));
65 glColor3f(0.5f, 0.5f, 0.5f);
66 glPushAttrib(GL_ENABLE_BIT);
67 glDisable(GL_LIGHTING);
68 glBegin(GL_LINES);
69 glVertex3f((float)fromEdge->estimate().translation().x(),
70 (float)fromEdge->estimate().translation().y(), 0.f);
71 glVertex3f((float)toEdge->estimate().translation().x(),
72 (float)toEdge->estimate().translation().y(), 0.f);
73 glEnd();
74 glPopAttrib();
75 return this;
76}
77#endif
78
79} // namespace g2o
bool writeInformationMatrix(std::ostream &os) const
write the upper trinagular part of the information matrix into the stream
Definition base_edge.h:165
bool readInformationMatrix(std::istream &is)
Definition base_edge.h:173
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition base_edge.h:119
virtual void setMeasurement(const Measurement &m)
Definition base_edge.h:122
virtual bool write(std::ostream &os) const
write the vertex to a stream
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
velocity measurement of a differential robot
2D pose Vertex, (x,y,theta)
Definition vertex_se2.h:41