g2o
Loading...
Searching...
No Matches
edge_se2_segment2d.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
27#ifndef G2O_EDGE_SE2_SEGMENT2D_H
28#define G2O_EDGE_SE2_SEGMENT2D_H
29
30#include "g2o/config.h"
34#include "vertex_segment2d.h"
35
36namespace g2o {
37
39 : public BaseBinaryEdge<4, Vector4, VertexSE2,
40 VertexSegment2D> // Avoid redefinition of BaseEdge
41 // in MSVC
42{
43 public:
44 G2O_TYPES_SLAM2D_ADDONS_API EIGEN_MAKE_ALIGNED_OPERATOR_NEW
47
49 return Eigen::Map<const Vector2>(&(_measurement[0]));
50 }
52 return Eigen::Map<const Vector2>(&(_measurement[2]));
53 }
55 Eigen::Map<Vector2> v(&_measurement[0]);
56 v = p1;
57 }
59 Eigen::Map<Vector2> v(&_measurement[2]);
60 v = p2;
61 }
62
64 const VertexSE2* v1 = static_cast<const VertexSE2*>(_vertices[0]);
65 const VertexSegment2D* l2 =
66 static_cast<const VertexSegment2D*>(_vertices[1]);
67 Eigen::Map<Vector2> error1(&_error(0));
68 Eigen::Map<Vector2> error2(&_error(2));
69 SE2 iEst = v1->estimate().inverse();
70 error1 = (iEst * l2->estimateP1());
71 error2 = (iEst * l2->estimateP2());
73 }
74
75 G2O_TYPES_SLAM2D_ADDONS_API virtual bool setMeasurementData(const double* d) {
76 Eigen::Map<const Vector4> data(d);
77 _measurement = data;
78 return true;
79 }
80
81 G2O_TYPES_SLAM2D_ADDONS_API virtual bool getMeasurementData(double* d) const {
82 Eigen::Map<Vector4> data(d);
83 data = _measurement;
84 return true;
85 }
86
88 return 4;
89 }
90
92 const VertexSE2* v1 = static_cast<const VertexSE2*>(_vertices[0]);
93 const VertexSegment2D* l2 =
94 static_cast<const VertexSegment2D*>(_vertices[1]);
95 SE2 iEst = v1->estimate().inverse();
96 setMeasurementP1(iEst * l2->estimateP1());
97 setMeasurementP2(iEst * l2->estimateP2());
98 return true;
99 }
100
101 G2O_TYPES_SLAM2D_ADDONS_API virtual bool read(std::istream& is);
102 G2O_TYPES_SLAM2D_ADDONS_API virtual bool write(std::ostream& os) const;
103
108 (void)to;
109 return (from.count(_vertices[0]) == 1 ? 1.0 : -1.0);
110 }
111};
112
113} // namespace g2o
114
115#endif
Measurement _measurement
the measurement of the edge
Definition base_edge.h:146
ErrorVector _error
Definition base_edge.h:149
const EstimateType & estimate() const
return the current estimate of the vertex
G2O_TYPES_SLAM2D_ADDONS_API Vector2 measurementP2()
G2O_TYPES_SLAM2D_ADDONS_API void setMeasurementP2(const Vector2 &p2)
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
G2O_TYPES_SLAM2D_ADDONS_API EIGEN_MAKE_ALIGNED_OPERATOR_NEW G2O_TYPES_SLAM2D_ADDONS_API EdgeSE2Segment2D()
virtual G2O_TYPES_SLAM2D_ADDONS_API double initialEstimatePossible(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
G2O_TYPES_SLAM2D_ADDONS_API Vector2 measurementP1()
virtual G2O_TYPES_SLAM2D_ADDONS_API int measurementDimension() const
virtual G2O_TYPES_SLAM2D_ADDONS_API void initialEstimate(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
virtual G2O_TYPES_SLAM2D_ADDONS_API bool getMeasurementData(double *d) const
virtual G2O_TYPES_SLAM2D_ADDONS_API bool setMeasurementData(const double *d)
virtual G2O_TYPES_SLAM2D_ADDONS_API bool setMeasurementFromState()
G2O_TYPES_SLAM2D_ADDONS_API void setMeasurementP1(const Vector2 &p1)
G2O_TYPES_SLAM2D_ADDONS_API void computeError()
VertexContainer _vertices
std::set< Vertex * > VertexSet
A general case Vertex for optimization.
represent SE2
Definition se2.h:43
SE2 inverse() const
invert :-)
Definition se2.h:83
2D pose Vertex, (x,y,theta)
Definition vertex_se2.h:41
Vector2 estimateP1() const
Vector2 estimateP2() const
#define G2O_TYPES_SLAM2D_ADDONS_API
VectorN< 2 > Vector2
Definition eigen_types.h:50