g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam3d
parameter_se3_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_se3_offset.h
"
28
29
#include "
isometry3d_gradients.h
"
30
#include "
vertex_se3.h
"
31
32
#ifdef G2O_HAVE_OPENGL
33
#include "
g2o/stuff/opengl_primitives.h
"
34
#include "
g2o/stuff/opengl_wrapper.h
"
35
#endif
36
37
namespace
g2o
{
38
39
ParameterSE3Offset::ParameterSE3Offset
() {
setOffset
(); }
40
41
void
ParameterSE3Offset::setOffset
(
const
Isometry3
& offset_) {
42
_offset
= offset_;
43
_inverseOffset
=
_offset
.inverse();
44
}
45
46
bool
ParameterSE3Offset::read
(std::istream& is) {
47
Vector7
off;
48
bool
state =
internal::readVector
(is, off);
49
// normalize the quaternion to recover numerical precision lost by storing as
50
// human readable text
51
Vector4::MapType(off.data() + 3).normalize();
52
setOffset
(
internal::fromVectorQT
(off));
53
return
state;
54
}
55
56
bool
ParameterSE3Offset::write
(std::ostream& os)
const
{
57
return
internal::writeVector
(os,
internal::toVectorQT
(
_offset
));
58
}
59
60
CacheSE3Offset::CacheSE3Offset
() :
Cache
(),
_offsetParam
(0) {}
61
62
bool
CacheSE3Offset::resolveDependencies
() {
63
_offsetParam
=
dynamic_cast<
ParameterSE3Offset
*
>
(
_parameters
[0]);
64
return
_offsetParam
!= 0;
65
}
66
67
void
CacheSE3Offset::updateImpl
() {
68
const
VertexSE3
* v =
static_cast<
const
VertexSE3
*
>
(
vertex
());
69
_n2w
= v->
estimate
() *
_offsetParam
->offset();
70
_w2n
=
_n2w
.inverse();
71
_w2l
= v->
estimate
().inverse();
72
}
73
74
void
CacheSE3Offset::setOffsetParam
(
ParameterSE3Offset
*
offsetParam
) {
75
_offsetParam
=
offsetParam
;
76
}
77
78
#ifdef G2O_HAVE_OPENGL
79
CacheSE3OffsetDrawAction::CacheSE3OffsetDrawAction()
80
:
DrawAction
(typeid(
CacheSE3Offset
).name()) {
81
_previousParams = (
DrawAction::Parameters
*)0x42;
82
refreshPropertyPtrs(0);
83
}
84
85
bool
CacheSE3OffsetDrawAction::refreshPropertyPtrs(
86
HyperGraphElementAction::Parameters* params_) {
87
if
(!
DrawAction::refreshPropertyPtrs
(params_))
return
false
;
88
if
(_previousParams) {
89
_cubeSide = _previousParams->makeProperty<
FloatProperty
>(
90
_typeName +
"::CUBE_SIDE"
, .05f);
91
}
else
{
92
_cubeSide = 0;
93
}
94
return
true
;
95
}
96
97
HyperGraphElementAction
* CacheSE3OffsetDrawAction::operator()(
98
HyperGraph::HyperGraphElement
* element,
99
HyperGraphElementAction::Parameters
* params_) {
100
if
(
typeid
(*element).name() != _typeName)
return
nullptr
;
101
CacheSE3Offset
* that =
static_cast<
CacheSE3Offset
*
>
(element);
102
refreshPropertyPtrs(params_);
103
if
(!_previousParams)
return
this
;
104
105
if
(_show && !_show->value())
return
this
;
106
float
cs = _cubeSide ? _cubeSide->value() : 1.0f;
107
glPushAttrib(GL_COLOR);
108
glColor3f(
POSE_PARAMETER_COLOR
);
109
glPushMatrix();
110
glMultMatrixd(that->offsetParam()->offset().cast<
double
>().data());
111
opengl::drawBox
(cs, cs, cs);
112
glPopMatrix();
113
glPopAttrib();
114
return
this
;
115
}
116
#endif
117
118
}
// namespace g2o
g2o::BaseVertex::estimate
const EstimateType & estimate() const
return the current estimate of the vertex
Definition
base_vertex.h:127
g2o::CacheSE3Offset
caching the offset related to a vertex
Definition
parameter_se3_offset.h:67
g2o::CacheSE3Offset::CacheSE3Offset
CacheSE3Offset()
Definition
parameter_se3_offset.cpp:60
g2o::CacheSE3Offset::_n2w
Isometry3 _n2w
Definition
parameter_se3_offset.h:83
g2o::CacheSE3Offset::_w2n
Isometry3 _w2n
Definition
parameter_se3_offset.h:82
g2o::CacheSE3Offset::_w2l
Isometry3 _w2l
Definition
parameter_se3_offset.h:84
g2o::CacheSE3Offset::_offsetParam
ParameterSE3Offset * _offsetParam
the parameter connected to the cache
Definition
parameter_se3_offset.h:81
g2o::CacheSE3Offset::updateImpl
virtual void updateImpl()
redefine this to do the update
Definition
parameter_se3_offset.cpp:67
g2o::CacheSE3Offset::setOffsetParam
void setOffsetParam(ParameterSE3Offset *offsetParam)
Definition
parameter_se3_offset.cpp:74
g2o::CacheSE3Offset::offsetParam
const ParameterSE3Offset * offsetParam() const
Definition
parameter_se3_offset.h:73
g2o::CacheSE3Offset::resolveDependencies
virtual bool resolveDependencies()
Definition
parameter_se3_offset.cpp:62
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::DrawAction::Parameters
Definition
hyper_graph_action.h:204
g2o::DrawAction
draw actions
Definition
hyper_graph_action.h:201
g2o::DrawAction::refreshPropertyPtrs
virtual bool refreshPropertyPtrs(HyperGraphElementAction::Parameters *params_)
Definition
hyper_graph_action.cpp:221
g2o::HyperGraphElementAction
Abstract action that operates on a graph entity.
Definition
hyper_graph_action.h:74
g2o::ParameterSE3Offset
offset for an SE3
Definition
parameter_se3_offset.h:39
g2o::ParameterSE3Offset::_offset
Isometry3 _offset
Definition
parameter_se3_offset.h:60
g2o::ParameterSE3Offset::write
virtual bool write(std::ostream &os) const
write the data to a stream
Definition
parameter_se3_offset.cpp:56
g2o::ParameterSE3Offset::setOffset
void setOffset(const Isometry3 &offset_=Isometry3::Identity())
Definition
parameter_se3_offset.cpp:41
g2o::ParameterSE3Offset::_inverseOffset
Isometry3 _inverseOffset
Definition
parameter_se3_offset.h:61
g2o::ParameterSE3Offset::ParameterSE3Offset
ParameterSE3Offset()
Definition
parameter_se3_offset.cpp:39
g2o::ParameterSE3Offset::read
virtual bool read(std::istream &is)
read the data from a stream
Definition
parameter_se3_offset.cpp:46
g2o::VertexSE3
3D pose Vertex, represented as an Isometry3
Definition
vertex_se3.h:50
isometry3d_gradients.h
g2o::internal::toVectorQT
Vector7 toVectorQT(const Isometry3 &t)
Definition
isometry3d_mappings.cpp:111
g2o::internal::fromVectorQT
Isometry3 fromVectorQT(const Vector7 &v)
Definition
isometry3d_mappings.cpp:137
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::opengl::drawBox
void drawBox(GLfloat l, GLfloat w, GLfloat h)
Definition
opengl_primitives.cpp:100
g2o
Definition
dl_wrapper.cpp:55
g2o::Vector7
VectorN< 7 > Vector7
Definition
eigen_types.h:54
g2o::Isometry3
Eigen::Transform< double, 3, Eigen::Isometry, Eigen::ColMajor > Isometry3
Definition
eigen_types.h:77
g2o::FloatProperty
Property< float > FloatProperty
Definition
property.h:150
opengl_primitives.h
POSE_PARAMETER_COLOR
#define POSE_PARAMETER_COLOR
Definition
opengl_primitives.h:145
opengl_wrapper.h
parameter_se3_offset.h
g2o::HyperGraphElementAction::Parameters
Definition
hyper_graph_action.h:76
g2o::HyperGraph::HyperGraphElement
Definition
hyper_graph.h:80
vertex_se3.h
Generated on
for g2o by
1.17.0