g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam2d_addons
edge_se2_segment2d_pointLine.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_POINTLINE_H
28
#define G2O_EDGE_SE2_SEGMENT2D_POINTLINE_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
G2O_TYPES_SLAM2D_ADDONS_API
EdgeSE2Segment2DPointLine
39
:
public
BaseBinaryEdge
<3, Vector3, VertexSE2, VertexSegment2D> {
40
public
:
41
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42
EdgeSE2Segment2DPointLine
();
43
44
double
theta
()
const
{
return
_measurement
[2]; }
45
Vector2
point
()
const
{
46
Eigen::Map<const Vector2> p(&
_measurement
[0]);
47
return
p;
48
}
49
50
void
setTheta
(
double
t) {
_measurement
[2] = t; }
51
void
setPoint
(
const
Vector2
& p_) {
52
Eigen::Map<Vector2> p(&
_measurement
[0]);
53
p = p_;
54
}
55
56
int
pointNum
()
const
{
return
_pointNum
; }
57
void
setPointNum
(
int
pn) {
_pointNum
= pn; }
58
59
void
computeError
() {
60
const
VertexSE2
* v1 =
static_cast<
const
VertexSE2
*
>
(
_vertices
[0]);
61
const
VertexSegment2D
* l2 =
62
static_cast<
const
VertexSegment2D
*
>
(
_vertices
[1]);
63
SE2
iEst = v1->
estimate
().
inverse
();
64
Vector2
predP1 = iEst * l2->
estimateP1
();
65
Vector2
predP2 = iEst * l2->
estimateP2
();
66
Vector2
dP = predP2 - predP1;
67
Vector2
normal(dP.y(), -dP.x());
68
normal.normalize();
69
Vector3
prediction;
70
prediction[2] = std::atan2(normal.y(), normal.x());
71
Eigen::Map<Vector2> pt(&prediction[0]);
72
pt = (
_pointNum
== 0) ? predP1 : predP2;
73
_error
= prediction -
_measurement
;
74
_error
[2] =
normalize_theta
(
_error
[2]);
75
}
76
77
virtual
bool
setMeasurementData
(
const
double
* d) {
78
Eigen::Map<const Vector3> data(d);
79
_measurement
= data;
80
return
true
;
81
}
82
83
virtual
bool
getMeasurementData
(
double
* d)
const
{
84
Eigen::Map<Vector3> data(d);
85
data =
_measurement
;
86
return
true
;
87
}
88
89
virtual
int
measurementDimension
()
const
{
return
3; }
90
91
virtual
bool
setMeasurementFromState
() {
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
Vector2
predP1 = iEst * l2->
estimateP1
();
97
Vector2
predP2 = iEst * l2->
estimateP2
();
98
Vector2
dP = predP2 - predP1;
99
Vector2
normal(dP.y(), -dP.x());
100
normal.normalize();
101
Vector3
prediction;
102
prediction[2] = std::atan2(normal.y(), normal.x());
103
Eigen::Map<Vector2> pt(&prediction[0]);
104
pt = (
_pointNum
== 0) ? predP1 : predP2;
105
setMeasurement
(prediction);
106
return
true
;
107
}
108
109
virtual
bool
read(std::istream& is);
110
virtual
bool
write(std::ostream& os)
const
;
111
112
protected
:
113
int
_pointNum
;
114
115
/* #ifndef NUMERIC_JACOBIAN_TWO_D_TYPES */
116
/* virtual void linearizeOplus(); */
117
/* #endif */
118
};
119
120
/* class G2O_TYPES_SLAM2D_ADDONS_API
121
* EdgeSE2Segment2DPointLineWriteGnuplotAction: public WriteGnuplotAction { */
122
/* public: */
123
/* EdgeSE2Segment2DPointLineWriteGnuplotAction(); */
124
/* virtual HyperGraphElementAction*
125
* operator()(HyperGraph::HyperGraphElement* element, */
126
/* HyperGraphElementAction::Parameters* params_); */
127
/* }; */
128
129
/* #ifdef G2O_HAVE_OPENGL */
130
/* class G2O_TYPES_SLAM2D_ADDONS_API EdgeSE2Segment2DPointLineDrawAction:
131
* public DrawAction{ */
132
/* public: */
133
/* EdgeSE2Segment2DPointLineDrawAction(); */
134
/* virtual HyperGraphElementAction*
135
* operator()(HyperGraph::HyperGraphElement* element, */
136
/* HyperGraphElementAction::Parameters* params_); */
137
/* }; */
138
/* #endif */
139
140
}
// namespace g2o
141
142
#endif
base_binary_edge.h
g2o::BaseBinaryEdge< 3, Vector3, VertexSE2, VertexSegment2D >::BaseBinaryEdge
BaseBinaryEdge()
Definition
base_binary_edge.h:41
g2o::BaseEdge< D, Vector3 >::setMeasurement
virtual void setMeasurement(const Measurement &m)
Definition
base_edge.h:122
g2o::BaseEdge< D, Vector3 >::_measurement
Measurement _measurement
Definition
base_edge.h:146
g2o::BaseEdge< D, Vector3 >::_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::EdgeSE2Segment2DPointLine::setMeasurementFromState
virtual bool setMeasurementFromState()
Definition
edge_se2_segment2d_pointLine.h:91
g2o::EdgeSE2Segment2DPointLine::getMeasurementData
virtual bool getMeasurementData(double *d) const
Definition
edge_se2_segment2d_pointLine.h:83
g2o::EdgeSE2Segment2DPointLine::setPointNum
void setPointNum(int pn)
Definition
edge_se2_segment2d_pointLine.h:57
g2o::EdgeSE2Segment2DPointLine::_pointNum
int _pointNum
Definition
edge_se2_segment2d_pointLine.h:113
g2o::EdgeSE2Segment2DPointLine::setPoint
void setPoint(const Vector2 &p_)
Definition
edge_se2_segment2d_pointLine.h:51
g2o::EdgeSE2Segment2DPointLine::measurementDimension
virtual int measurementDimension() const
Definition
edge_se2_segment2d_pointLine.h:89
g2o::EdgeSE2Segment2DPointLine::EdgeSE2Segment2DPointLine
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeSE2Segment2DPointLine()
Definition
edge_se2_segment2d_pointLine.cpp:31
g2o::EdgeSE2Segment2DPointLine::setTheta
void setTheta(double t)
Definition
edge_se2_segment2d_pointLine.h:50
g2o::EdgeSE2Segment2DPointLine::point
Vector2 point() const
Definition
edge_se2_segment2d_pointLine.h:45
g2o::EdgeSE2Segment2DPointLine::pointNum
int pointNum() const
Definition
edge_se2_segment2d_pointLine.h:56
g2o::EdgeSE2Segment2DPointLine::setMeasurementData
virtual bool setMeasurementData(const double *d)
Definition
edge_se2_segment2d_pointLine.h:77
g2o::EdgeSE2Segment2DPointLine::theta
double theta() const
Definition
edge_se2_segment2d_pointLine.h:44
g2o::EdgeSE2Segment2DPointLine::computeError
void computeError()
Definition
edge_se2_segment2d_pointLine.h:59
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::Vector3
VectorN< 3 > Vector3
Definition
eigen_types.h:51
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