g2o
Loading...
Searching...
No Matches
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
28
29#include "g2o/core/io_helper.h"
30#include "vertex_se2.h"
31
32#ifdef G2O_HAVE_OPENGL
34#endif
35
36namespace g2o {
37
39
40void ParameterSE2Offset::setOffset(const SE2& offset_) {
41 _offset = offset_;
42 _offsetMatrix = _offset.rotation().toRotationMatrix();
43 _offsetMatrix.translation() = _offset.translation();
45}
46
47bool 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
54bool ParameterSE2Offset::write(std::ostream& os) const {
55 return internal::writeVector(os, offset().toVector());
56}
57
58CacheSE2Offset::CacheSE2Offset() : Cache(), _offsetParam(0) {}
59
64
66 const VertexSE2* v = static_cast<const VertexSE2*>(vertex());
68
69 _n2w = _se2_n2w.rotation().toRotationMatrix();
70 _n2w.translation() = _se2_n2w.translation();
71
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;
85 _offsetParam->offset().rotation().toRotationMatrix().transpose() *
86 RInversePrime;
88}
89
93
94} // namespace g2o
const EstimateType & estimate() const
return the current estimate of the vertex
Isometry2 _w2n
world to sensor transform
Isometry2 _n2w
sensor to world
virtual void updateImpl()
redefine this to do the update
const ParameterSE2Offset * offsetParam() const
ParameterSE2Offset * _offsetParam
the parameter connected to the cache
Isometry2 _w2l
world to local
virtual bool resolveDependencies()
void setOffsetParam(ParameterSE2Offset *offsetParam)
OptimizableGraph::Vertex * vertex()
Definition cache.cpp:57
ParameterVector _parameters
Definition cache.h:103
void setOffset(const SE2 &offset_=SE2())
virtual bool write(std::ostream &os) const
write the data to a stream
virtual bool read(std::istream &is)
read the data from a stream
represent SE2
Definition se2.h:43
const Vector2 & translation() const
translational component
Definition se2.h:57
SE2 inverse() const
invert :-)
Definition se2.h:83
const Rotation2D & rotation() const
rotational component
Definition se2.h:61
2D pose Vertex, (x,y,theta)
Definition vertex_se2.h:41
bool writeVector(std::ostream &os, const Eigen::DenseBase< Derived > &b)
Definition io_helper.h:36
bool readVector(std::istream &is, Eigen::DenseBase< Derived > &b)
Definition io_helper.h:42
VectorN< 3 > Vector3
Definition eigen_types.h:51
MatrixN< 2 > Matrix2
Definition eigen_types.h:71