g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam2d_addons
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"
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
EdgeSE2Segment2D
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
45
G2O_TYPES_SLAM2D_ADDONS_API
46
EdgeSE2Segment2D
();
47
48
G2O_TYPES_SLAM2D_ADDONS_API
Vector2
measurementP1
() {
49
return
Eigen::Map<const Vector2>(&(
_measurement
[0]));
50
}
51
G2O_TYPES_SLAM2D_ADDONS_API
Vector2
measurementP2
() {
52
return
Eigen::Map<const Vector2>(&(
_measurement
[2]));
53
}
54
G2O_TYPES_SLAM2D_ADDONS_API
void
setMeasurementP1
(
const
Vector2
& p1) {
55
Eigen::Map<Vector2> v(&
_measurement
[0]);
56
v = p1;
57
}
58
G2O_TYPES_SLAM2D_ADDONS_API
void
setMeasurementP2
(
const
Vector2
& p2) {
59
Eigen::Map<Vector2> v(&
_measurement
[2]);
60
v = p2;
61
}
62
63
G2O_TYPES_SLAM2D_ADDONS_API
void
computeError
() {
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
());
72
_error
=
_error
-
_measurement
;
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
87
G2O_TYPES_SLAM2D_ADDONS_API
virtual
int
measurementDimension
()
const
{
88
return
4;
89
}
90
91
G2O_TYPES_SLAM2D_ADDONS_API
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
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
104
G2O_TYPES_SLAM2D_ADDONS_API
virtual
void
initialEstimate
(
105
const
OptimizableGraph::VertexSet
& from,
OptimizableGraph::Vertex
* to);
106
G2O_TYPES_SLAM2D_ADDONS_API
virtual
double
initialEstimatePossible
(
107
const
OptimizableGraph::VertexSet
& from,
OptimizableGraph::Vertex
* to) {
108
(void)to;
109
return
(from.count(
_vertices
[0]) == 1 ? 1.0 : -1.0);
110
}
111
};
112
113
}
// namespace g2o
114
115
#endif
base_binary_edge.h
g2o::BaseBinaryEdge< 4, Vector4, VertexSE2, VertexSegment2D >::BaseBinaryEdge
BaseBinaryEdge()
Definition
base_binary_edge.h:41
g2o::BaseEdge< D, Vector4 >::_measurement
Measurement _measurement
Definition
base_edge.h:146
g2o::BaseEdge< D, Vector4 >::_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::EdgeSE2Segment2D::measurementP2
G2O_TYPES_SLAM2D_ADDONS_API Vector2 measurementP2()
Definition
edge_se2_segment2d.h:51
g2o::EdgeSE2Segment2D::setMeasurementP2
G2O_TYPES_SLAM2D_ADDONS_API void setMeasurementP2(const Vector2 &p2)
Definition
edge_se2_segment2d.h:58
g2o::EdgeSE2Segment2D::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.cpp:36
g2o::EdgeSE2Segment2D::write
virtual G2O_TYPES_SLAM2D_ADDONS_API bool write(std::ostream &os) const
write the vertex to a stream
Definition
edge_se2_segment2d.cpp:41
g2o::EdgeSE2Segment2D::EdgeSE2Segment2D
G2O_TYPES_SLAM2D_ADDONS_API EIGEN_MAKE_ALIGNED_OPERATOR_NEW G2O_TYPES_SLAM2D_ADDONS_API EdgeSE2Segment2D()
Definition
edge_se2_segment2d.cpp:33
g2o::EdgeSE2Segment2D::initialEstimatePossible
virtual G2O_TYPES_SLAM2D_ADDONS_API double initialEstimatePossible(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
Definition
edge_se2_segment2d.h:106
g2o::EdgeSE2Segment2D::measurementP1
G2O_TYPES_SLAM2D_ADDONS_API Vector2 measurementP1()
Definition
edge_se2_segment2d.h:48
g2o::EdgeSE2Segment2D::measurementDimension
virtual G2O_TYPES_SLAM2D_ADDONS_API int measurementDimension() const
Definition
edge_se2_segment2d.h:87
g2o::EdgeSE2Segment2D::initialEstimate
virtual G2O_TYPES_SLAM2D_ADDONS_API void initialEstimate(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
Definition
edge_se2_segment2d.cpp:46
g2o::EdgeSE2Segment2D::getMeasurementData
virtual G2O_TYPES_SLAM2D_ADDONS_API bool getMeasurementData(double *d) const
Definition
edge_se2_segment2d.h:81
g2o::EdgeSE2Segment2D::setMeasurementData
virtual G2O_TYPES_SLAM2D_ADDONS_API bool setMeasurementData(const double *d)
Definition
edge_se2_segment2d.h:75
g2o::EdgeSE2Segment2D::setMeasurementFromState
virtual G2O_TYPES_SLAM2D_ADDONS_API bool setMeasurementFromState()
Definition
edge_se2_segment2d.h:91
g2o::EdgeSE2Segment2D::setMeasurementP1
G2O_TYPES_SLAM2D_ADDONS_API void setMeasurementP1(const Vector2 &p1)
Definition
edge_se2_segment2d.h:54
g2o::EdgeSE2Segment2D::computeError
G2O_TYPES_SLAM2D_ADDONS_API void computeError()
Definition
edge_se2_segment2d.h:63
g2o::HyperGraph::Edge::_vertices
VertexContainer _vertices
Definition
hyper_graph.h:221
g2o::HyperGraph::VertexSet
std::set< Vertex * > VertexSet
Definition
hyper_graph.h:142
g2o::OptimizableGraph::Vertex
A general case Vertex for optimization.
Definition
optimizable_graph.h:108
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::Vector2
VectorN< 2 > Vector2
Definition
eigen_types.h:50
vertex_se2.h
vertex_segment2d.h
Generated on
for g2o by
1.17.0