g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam2d_addons
edge_se2_segment2d_line.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_LINE_H
28
#define G2O_EDGE_SE2_SEGMENT2D_LINE_H
29
30
#include "g2o/config.h"
31
#include "
g2o/core/base_binary_edge.h
"
32
#include "
g2o/types/slam2d/vertex_se2.h
"
33
#include "
g2o_types_slam2d_addons_api.h
"
34
#include "
vertex_segment2d.h
"
35
36
namespace
g2o
{
37
38
class
EdgeSE2Segment2DLine
39
:
public
BaseBinaryEdge
<2, Vector2, VertexSE2,
40
VertexSegment2D>
// Avoid redefinition of BaseEdge
41
// in MSVC
42
{
43
public
:
44
G2O_TYPES_SLAM2D_ADDONS_API
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45
G2O_TYPES_SLAM2D_ADDONS_API
46
EdgeSE2Segment2DLine
();
47
48
G2O_TYPES_SLAM2D_ADDONS_API
double
theta
()
const
{
return
_measurement
[0]; }
49
G2O_TYPES_SLAM2D_ADDONS_API
double
rho
()
const
{
return
_measurement
[1]; }
50
51
G2O_TYPES_SLAM2D_ADDONS_API
void
setTheta
(
double
t) {
_measurement
[0] = t; }
52
G2O_TYPES_SLAM2D_ADDONS_API
void
setRho
(
double
r) {
_measurement
[1] = r; }
53
54
G2O_TYPES_SLAM2D_ADDONS_API
void
computeError
() {
55
const
VertexSE2
* v1 =
static_cast<
const
VertexSE2
*
>
(
_vertices
[0]);
56
const
VertexSegment2D
* l2 =
57
static_cast<
const
VertexSegment2D
*
>
(
_vertices
[1]);
58
SE2
iEst = v1->
estimate
().
inverse
();
59
Vector2
predP1 = iEst * l2->
estimateP1
();
60
Vector2
predP2 = iEst * l2->
estimateP2
();
61
Vector2
dP = predP2 - predP1;
62
Vector2
normal(dP.y(), -dP.x());
63
normal.normalize();
64
Vector2
prediction(std::atan2(normal.y(), normal.x()),
65
predP1.dot(normal) * .5 + predP2.dot(normal) * .5);
66
67
_error
= prediction -
_measurement
;
68
_error
[0] =
normalize_theta
(
_error
[0]);
69
}
70
71
G2O_TYPES_SLAM2D_ADDONS_API
virtual
bool
setMeasurementData
(
const
double
* d) {
72
Eigen::Map<const Vector2> data(d);
73
_measurement
= data;
74
return
true
;
75
}
76
77
G2O_TYPES_SLAM2D_ADDONS_API
virtual
bool
getMeasurementData
(
double
* d)
const
{
78
Eigen::Map<Vector2> data(d);
79
data =
_measurement
;
80
return
true
;
81
}
82
83
G2O_TYPES_SLAM2D_ADDONS_API
virtual
int
measurementDimension
()
const
{
84
return
2;
85
}
86
87
G2O_TYPES_SLAM2D_ADDONS_API
virtual
bool
setMeasurementFromState
() {
88
const
VertexSE2
* v1 =
static_cast<
const
VertexSE2
*
>
(
_vertices
[0]);
89
const
VertexSegment2D
* l2 =
90
static_cast<
const
VertexSegment2D
*
>
(
_vertices
[1]);
91
SE2
iEst = v1->
estimate
().
inverse
();
92
Vector2
predP1 = iEst * l2->
estimateP1
();
93
Vector2
predP2 = iEst * l2->
estimateP2
();
94
Vector2
dP = predP2 - predP1;
95
Vector2
normal(dP.y(), -dP.x());
96
normal.normalize();
97
Vector2
prediction(std::atan2(normal.y(), normal.x()),
98
predP1.dot(normal) * .5 + predP2.dot(normal) * .5);
99
_measurement
= prediction;
100
return
true
;
101
}
102
103
G2O_TYPES_SLAM2D_ADDONS_API
virtual
bool
read
(std::istream& is);
104
G2O_TYPES_SLAM2D_ADDONS_API
virtual
bool
write
(std::ostream& os)
const
;
105
106
/* #ifndef NUMERIC_JACOBIAN_TWO_D_TYPES */
107
/* virtual void linearizeOplus(); */
108
/* #endif */
109
};
110
111
/* class G2O_TYPES_SLAM2D_ADDONS_API EdgeSE2Segment2DLineWriteGnuplotAction:
112
* public WriteGnuplotAction { */
113
/* public: */
114
/* EdgeSE2Segment2DLineWriteGnuplotAction(); */
115
/* virtual HyperGraphElementAction*
116
* operator()(HyperGraph::HyperGraphElement* element, */
117
/* HyperGraphElementAction::Parameters* params_); */
118
/* }; */
119
120
/* #ifdef G2O_HAVE_OPENGL */
121
/* class G2O_TYPES_SLAM2D_ADDONS_API EdgeSE2Segment2DLineDrawAction: public
122
* DrawAction{ */
123
/* public: */
124
/* EdgeSE2Segment2DLineDrawAction(); */
125
/* virtual HyperGraphElementAction*
126
* operator()(HyperGraph::HyperGraphElement* element, */
127
/* HyperGraphElementAction::Parameters* params_); */
128
/* }; */
129
/* #endif */
130
131
}
// namespace g2o
132
133
#endif
base_binary_edge.h
g2o::BaseBinaryEdge< 2, Vector2, VertexSE2, VertexSegment2D >::BaseBinaryEdge
BaseBinaryEdge()
Definition
base_binary_edge.h:41
g2o::BaseEdge< D, Vector2 >::_measurement
Measurement _measurement
Definition
base_edge.h:146
g2o::BaseEdge< D, Vector2 >::_error
ErrorVector _error
Definition
base_edge.h:149
g2o::BaseVertex::estimate
const EstimateType & estimate() const
return the current estimate of the vertex
Definition
base_vertex.h:127
g2o::EdgeSE2Segment2DLine::EdgeSE2Segment2DLine
G2O_TYPES_SLAM2D_ADDONS_API EIGEN_MAKE_ALIGNED_OPERATOR_NEW G2O_TYPES_SLAM2D_ADDONS_API EdgeSE2Segment2DLine()
Definition
edge_se2_segment2d_line.cpp:31
g2o::EdgeSE2Segment2DLine::setTheta
G2O_TYPES_SLAM2D_ADDONS_API void setTheta(double t)
Definition
edge_se2_segment2d_line.h:51
g2o::EdgeSE2Segment2DLine::read
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
Definition
edge_se2_segment2d_line.cpp:34
g2o::EdgeSE2Segment2DLine::setMeasurementFromState
virtual G2O_TYPES_SLAM2D_ADDONS_API bool setMeasurementFromState()
Definition
edge_se2_segment2d_line.h:87
g2o::EdgeSE2Segment2DLine::write
virtual G2O_TYPES_SLAM2D_ADDONS_API bool write(std::ostream &os) const
write the vertex to a stream
Definition
edge_se2_segment2d_line.cpp:39
g2o::EdgeSE2Segment2DLine::getMeasurementData
virtual G2O_TYPES_SLAM2D_ADDONS_API bool getMeasurementData(double *d) const
Definition
edge_se2_segment2d_line.h:77
g2o::EdgeSE2Segment2DLine::theta
G2O_TYPES_SLAM2D_ADDONS_API double theta() const
Definition
edge_se2_segment2d_line.h:48
g2o::EdgeSE2Segment2DLine::setRho
G2O_TYPES_SLAM2D_ADDONS_API void setRho(double r)
Definition
edge_se2_segment2d_line.h:52
g2o::EdgeSE2Segment2DLine::setMeasurementData
virtual G2O_TYPES_SLAM2D_ADDONS_API bool setMeasurementData(const double *d)
Definition
edge_se2_segment2d_line.h:71
g2o::EdgeSE2Segment2DLine::measurementDimension
virtual G2O_TYPES_SLAM2D_ADDONS_API int measurementDimension() const
Definition
edge_se2_segment2d_line.h:83
g2o::EdgeSE2Segment2DLine::rho
G2O_TYPES_SLAM2D_ADDONS_API double rho() const
Definition
edge_se2_segment2d_line.h:49
g2o::EdgeSE2Segment2DLine::computeError
G2O_TYPES_SLAM2D_ADDONS_API void computeError()
Definition
edge_se2_segment2d_line.h:54
g2o::HyperGraph::Edge::_vertices
VertexContainer _vertices
Definition
hyper_graph.h:221
g2o::SE2
represent SE2
Definition
se2.h:43
g2o::SE2::inverse
SE2 inverse() const
invert :-)
Definition
se2.h:83
g2o::VertexSE2
2D pose Vertex, (x,y,theta)
Definition
vertex_se2.h:41
g2o::VertexSegment2D
Definition
vertex_segment2d.h:40
g2o::VertexSegment2D::estimateP1
Vector2 estimateP1() const
Definition
vertex_segment2d.h:45
g2o::VertexSegment2D::estimateP2
Vector2 estimateP2() const
Definition
vertex_segment2d.h:48
g2o_types_slam2d_addons_api.h
G2O_TYPES_SLAM2D_ADDONS_API
#define G2O_TYPES_SLAM2D_ADDONS_API
Definition
g2o_types_slam2d_addons_api.h:55
g2o
Definition
dl_wrapper.cpp:55
g2o::normalize_theta
double normalize_theta(double theta)
Definition
misc.h:103
g2o::Vector2
VectorN< 2 > Vector2
Definition
eigen_types.h:50
vertex_se2.h
vertex_segment2d.h
Generated on
for g2o by
1.17.0