g2o
edge_line2d_pointxy.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_line2d_pointxy.h"
28 
29 #ifdef WINDOWS
30 #include <windows.h>
31 #endif
32 
33 #ifdef G2O_HAVE_OPENGL
34 #ifdef __APPLE__
35 #include <OpenGL/gl.h>
36 #else
37 #include <GL/gl.h>
38 #endif
39 #endif
40 
41 namespace g2o {
42 
45  {
46  }
47 
48  bool EdgeLine2DPointXY::read(std::istream& is)
49  {
50  is >> _measurement;
51  is >> information()(0,0);
52  return true;
53  }
54 
55  bool EdgeLine2DPointXY::write(std::ostream& os) const
56  {
57  os << measurement() << " ";
58  os << information()(0,0);
59  return os.good();
60  }
61 
62  // void EdgeLine2DPointXY::initialEstimate(const OptimizableGraph::VertexSet& from, OptimizableGraph::Vertex* to)
63  // {
64  // assert(from.size() == 1 && from.count(_vertices[0]) == 1 && "Can not initialize VertexLine2D position by VertexPointXY");
65 
66  // VertexLine2D* vi = static_cast<VertexLine2D*>(_vertices[0]);
67  // VertexPointXY* vj = static_cast<VertexPointXY*>(_vertices[1]);
68  // if (from.count(vi) > 0 && to == vj) {
69  // Line2D T=vi->estimate();
70  // Vector2D est=_measurement;
71  // est[0] += T.rotation().angle();
72  // est[0] = normalize_theta(est[0]);
73  // Vector2D n(cos(est[0]), sin(est[0]));
74  // est[1] += n.dot(T.translation());
75  // vj->setEstimate(est);
76  // }
77  // }
78 
79 // #ifndef NUMERIC_JACOBIAN_TWO_D_TYPES
80 // void EdgeLine2DPointXY::linearizeOplus()
81 // {
82 // const VertexLine2D* vi = static_cast<const VertexLine2D*>(_vertices[0]);
83 // const VertexPointXY* vj = static_cast<const VertexPointXY*>(_vertices[1]);
84 // const double& x1 = vi->estimate().translation()[0];
85 // const double& y1 = vi->estimate().translation()[1];
86 // const double& th1 = vi->estimate().rotation().angle();
87 // const double& x2 = vj->estimate()[0];
88 // const double& y2 = vj->estimate()[1];
89 
90 // double aux_1 = cos(th1) ;
91 // double aux_2 = -aux_1 ;
92 // double aux_3 = sin(th1) ;
93 
94 // _jacobianOplusXi( 0 , 0 ) = aux_2 ;
95 // _jacobianOplusXi( 0 , 1 ) = -aux_3 ;
96 // _jacobianOplusXi( 0 , 2 ) = aux_1*y2-aux_1*y1-aux_3*x2+aux_3*x1 ;
97 // _jacobianOplusXi( 1 , 0 ) = aux_3 ;
98 // _jacobianOplusXi( 1 , 1 ) = aux_2 ;
99 // _jacobianOplusXi( 1 , 2 ) = -aux_3*y2+aux_3*y1-aux_1*x2+aux_1*x1 ;
100 
101 // _jacobianOplusXj( 0 , 0 ) = aux_1 ;
102 // _jacobianOplusXj( 0 , 1 ) = aux_3 ;
103 // _jacobianOplusXj( 1 , 0 ) = -aux_3 ;
104 // _jacobianOplusXj( 1 , 1 ) = aux_1 ;
105 // }
106 // #endif
107 
108 // EdgeLine2DPointXYWriteGnuplotAction::EdgeLine2DPointXYWriteGnuplotAction(): WriteGnuplotAction(typeid(EdgeLine2DPointXY).name()){}
109 
110 // HyperGraphElementAction* EdgeLine2DPointXYWriteGnuplotAction::operator()(HyperGraph::HyperGraphElement* element, HyperGraphElementAction::Parameters* params_){
111 // if (typeid(*element).name()!=_typeName)
112 // return 0;
113 // WriteGnuplotAction::Parameters* params=static_cast<WriteGnuplotAction::Parameters*>(params_);
114 // if (!params->os){
115 // std::cerr << __PRETTY_FUNCTION__ << ": warning, on valid os specified" << std::endl;
116 // return 0;
117 // }
118 
119 // EdgeLine2DPointXY* e = static_cast<EdgeLine2DPointXY*>(element);
120 // VertexLine2D* fromEdge = static_cast<VertexLine2D*>(e->vertex(0));
121 // VertexPointXY* toEdge = static_cast<VertexPointXY*>(e->vertex(1));
122 // *(params->os) << fromEdge->estimate().translation().x() << " " << fromEdge->estimate().translation().y()
123 // << " " << fromEdge->estimate().rotation().angle() << std::endl;
124 // *(params->os) << toEdge->estimate().x() << " " << toEdge->estimate().y() << std::endl;
125 // *(params->os) << std::endl;
126 // return this;
127 // }
128 
129 // #ifdef G2O_HAVE_OPENGL
130 // EdgeLine2DPointXYDrawAction::EdgeLine2DPointXYDrawAction(): DrawAction(typeid(EdgeLine2DPointXY).name()){}
131 
132 // HyperGraphElementAction* EdgeLine2DPointXYDrawAction::operator()(HyperGraph::HyperGraphElement* element,
133 // HyperGraphElementAction::Parameters* params_){
134 // if (typeid(*element).name()!=_typeName)
135 // return 0;
136 
137 // refreshPropertyPtrs(params_);
138 // if (! _previousParams)
139 // return this;
140 
141 // if (_show && !_show->value())
142 // return this;
143 
144 
145 // EdgeLine2DPointXY* e = static_cast<EdgeLine2DPointXY*>(element);
146 // VertexLine2D* fromEdge = static_cast<VertexLine2D*>(e->vertex(0));
147 // VertexPointXY* toEdge = static_cast<VertexPointXY*>(e->vertex(1));
148 // glColor3f(0.4f,0.4f,0.2f);
149 // glPushAttrib(GL_ENABLE_BIT);
150 // glDisable(GL_LIGHTING);
151 // glBegin(GL_LINES);
152 // glVertex3f((float)fromEdge->estimate().translation().x(),(float)fromEdge->estimate().translation().y(),0.f);
153 // glVertex3f((float)toEdge->estimate().x(),(float)toEdge->estimate().y(),0.f);
154 // glEnd();
155 // glPopAttrib();
156 // return this;
157 // }
158 // #endif
159 
160 } // end namespace
G2O_TYPES_SLAM2D_ADDONS_API EIGEN_MAKE_ALIGNED_OPERATOR_NEW G2O_TYPES_SLAM2D_ADDONS_API EdgeLine2DPointXY()
Measurement _measurement
Definition: base_edge.h:87
virtual G2O_TYPES_SLAM2D_ADDONS_API bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
virtual G2O_TYPES_SLAM2D_ADDONS_API bool write(std::ostream &os) const
write the vertex to a stream
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition: base_edge.h:75