g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam2d
parameter_se2_offset.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 "
parameter_se2_offset.h
"
28
29
#include "
g2o/core/io_helper.h
"
30
#include "
vertex_se2.h
"
31
32
#ifdef G2O_HAVE_OPENGL
33
#include "
g2o/stuff/opengl_wrapper.h
"
34
#endif
35
36
namespace
g2o
{
37
38
ParameterSE2Offset::ParameterSE2Offset
() {
setOffset
(); }
39
40
void
ParameterSE2Offset::setOffset
(
const
SE2
& offset_) {
41
_offset
= offset_;
42
_offsetMatrix
=
_offset
.rotation().toRotationMatrix();
43
_offsetMatrix
.translation() =
_offset
.translation();
44
_inverseOffsetMatrix
=
_offsetMatrix
.inverse();
45
}
46
47
bool
ParameterSE2Offset::read
(std::istream& is) {
48
Vector3
off;
49
bool
state =
g2o::internal::readVector
(is, off);
50
setOffset
(
SE2
(off));
51
return
state;
52
}
53
54
bool
ParameterSE2Offset::write
(std::ostream& os)
const
{
55
return
internal::writeVector
(os,
offset
().toVector());
56
}
57
58
CacheSE2Offset::CacheSE2Offset
() :
Cache
(),
_offsetParam
(0) {}
59
60
bool
CacheSE2Offset::resolveDependencies
() {
61
_offsetParam
=
dynamic_cast<
ParameterSE2Offset
*
>
(
_parameters
[0]);
62
return
_offsetParam
!= 0;
63
}
64
65
void
CacheSE2Offset::updateImpl
() {
66
const
VertexSE2
* v =
static_cast<
const
VertexSE2
*
>
(
vertex
());
67
_se2_n2w
= v->
estimate
() *
_offsetParam
->offset();
68
69
_n2w
=
_se2_n2w
.rotation().toRotationMatrix();
70
_n2w
.translation() =
_se2_n2w
.translation();
71
72
_se2_w2n
=
_se2_n2w
.inverse();
73
_w2n
=
_se2_w2n
.rotation().toRotationMatrix();
74
_w2n
.translation() =
_se2_w2n
.translation();
75
76
SE2
w2l = v->
estimate
().
inverse
();
77
_w2l
= w2l.
rotation
().toRotationMatrix();
78
_w2l
.translation() = w2l.
translation
();
79
80
double
alpha = v->
estimate
().
rotation
().angle();
81
double
c = std::cos(alpha), s = std::sin(alpha);
82
Matrix2
RInversePrime;
83
RInversePrime << -s, c, -c, -s;
84
_RpInverse_RInversePrime
=
85
_offsetParam
->offset().rotation().toRotationMatrix().transpose() *
86
RInversePrime;
87
_RpInverse_RInverse
= w2l.
rotation
();
88
}
89
90
void
CacheSE2Offset::setOffsetParam
(
ParameterSE2Offset
*
offsetParam
) {
91
_offsetParam
=
offsetParam
;
92
}
93
94
}
// namespace g2o
g2o::BaseVertex::estimate
const EstimateType & estimate() const
return the current estimate of the vertex
Definition
base_vertex.h:127
g2o::CacheSE2Offset::_RpInverse_RInverse
Matrix2 _RpInverse_RInverse
Definition
parameter_se2_offset.h:101
g2o::CacheSE2Offset::_w2n
Isometry2 _w2n
world to sensor transform
Definition
parameter_se2_offset.h:98
g2o::CacheSE2Offset::_n2w
Isometry2 _n2w
sensor to world
Definition
parameter_se2_offset.h:100
g2o::CacheSE2Offset::_se2_w2n
SE2 _se2_w2n
Definition
parameter_se2_offset.h:95
g2o::CacheSE2Offset::CacheSE2Offset
CacheSE2Offset()
Definition
parameter_se2_offset.cpp:58
g2o::CacheSE2Offset::updateImpl
virtual void updateImpl()
redefine this to do the update
Definition
parameter_se2_offset.cpp:65
g2o::CacheSE2Offset::_RpInverse_RInversePrime
Matrix2 _RpInverse_RInversePrime
Definition
parameter_se2_offset.h:102
g2o::CacheSE2Offset::offsetParam
const ParameterSE2Offset * offsetParam() const
Definition
parameter_se2_offset.h:78
g2o::CacheSE2Offset::_se2_n2w
SE2 _se2_n2w
Definition
parameter_se2_offset.h:96
g2o::CacheSE2Offset::_offsetParam
ParameterSE2Offset * _offsetParam
the parameter connected to the cache
Definition
parameter_se2_offset.h:94
g2o::CacheSE2Offset::_w2l
Isometry2 _w2l
world to local
Definition
parameter_se2_offset.h:99
g2o::CacheSE2Offset::resolveDependencies
virtual bool resolveDependencies()
Definition
parameter_se2_offset.cpp:60
g2o::CacheSE2Offset::setOffsetParam
void setOffsetParam(ParameterSE2Offset *offsetParam)
Definition
parameter_se2_offset.cpp:90
g2o::Cache::vertex
OptimizableGraph::Vertex * vertex()
Definition
cache.cpp:57
g2o::Cache::_parameters
ParameterVector _parameters
Definition
cache.h:103
g2o::Cache::Cache
Cache(CacheContainer *container_=0, const ParameterVector ¶meters_=ParameterVector())
Definition
cache.cpp:44
g2o::ParameterSE2Offset
offset for an SE2
Definition
parameter_se2_offset.h:41
g2o::ParameterSE2Offset::offset
const SE2 & offset() const
Definition
parameter_se2_offset.h:55
g2o::ParameterSE2Offset::_offset
SE2 _offset
Definition
parameter_se2_offset.h:64
g2o::ParameterSE2Offset::setOffset
void setOffset(const SE2 &offset_=SE2())
Definition
parameter_se2_offset.cpp:40
g2o::ParameterSE2Offset::_offsetMatrix
Isometry2 _offsetMatrix
Definition
parameter_se2_offset.h:65
g2o::ParameterSE2Offset::write
virtual bool write(std::ostream &os) const
write the data to a stream
Definition
parameter_se2_offset.cpp:54
g2o::ParameterSE2Offset::_inverseOffsetMatrix
Isometry2 _inverseOffsetMatrix
Definition
parameter_se2_offset.h:66
g2o::ParameterSE2Offset::read
virtual bool read(std::istream &is)
read the data from a stream
Definition
parameter_se2_offset.cpp:47
g2o::ParameterSE2Offset::ParameterSE2Offset
ParameterSE2Offset()
Definition
parameter_se2_offset.cpp:38
g2o::SE2
represent SE2
Definition
se2.h:43
g2o::SE2::translation
const Vector2 & translation() const
translational component
Definition
se2.h:57
g2o::SE2::inverse
SE2 inverse() const
invert :-)
Definition
se2.h:83
g2o::SE2::rotation
const Rotation2D & rotation() const
rotational component
Definition
se2.h:61
g2o::VertexSE2
2D pose Vertex, (x,y,theta)
Definition
vertex_se2.h:41
io_helper.h
g2o::internal::writeVector
bool writeVector(std::ostream &os, const Eigen::DenseBase< Derived > &b)
Definition
io_helper.h:36
g2o::internal::readVector
bool readVector(std::istream &is, Eigen::DenseBase< Derived > &b)
Definition
io_helper.h:42
g2o
Definition
dl_wrapper.cpp:55
g2o::Vector3
VectorN< 3 > Vector3
Definition
eigen_types.h:51
g2o::Matrix2
MatrixN< 2 > Matrix2
Definition
eigen_types.h:71
opengl_wrapper.h
parameter_se2_offset.h
vertex_se2.h
Generated on
for g2o by
1.17.0