g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
data
vertex_tag.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 "
vertex_tag.h
"
28
29
#include "
g2o/stuff/macros.h
"
30
31
#ifdef G2O_HAVE_OPENGL
32
#include "
g2o/EXTERNAL/freeglut/freeglut_minimal.h
"
33
#include "
g2o/stuff/opengl_primitives.h
"
34
#include "
g2o/stuff/opengl_wrapper.h
"
35
#endif
36
37
#include <iomanip>
38
using namespace
std
;
39
40
namespace
g2o
{
41
42
VertexTag::VertexTag
() :
RobotData
() {}
43
44
VertexTag::~VertexTag
() {}
45
46
bool
VertexTag::read
(std::istream& is) {
47
is >>
_name
;
48
is >>
_position
.x() >>
_position
.y() >>
_position
.z();
49
is >>
_odom2d
.x() >>
_odom2d
.y() >>
_odom2d
.z();
50
is >>
_timestamp
;
51
is >>
_hostname
;
52
is >>
_loggerTimestamp
;
53
return
true
;
54
}
55
56
bool
VertexTag::write
(std::ostream& os)
const
{
57
os <<
_name
<<
" "
;
58
os << FIXED(
_position
.x()
59
<<
" "
<<
_position
.y() <<
" "
<<
_position
.z() <<
" "
);
60
os << FIXED(
_odom2d
.x() <<
" "
<<
_odom2d
.y() <<
" "
<<
_odom2d
.z() <<
" "
);
61
os << FIXED(
" "
<<
timestamp
() <<
" "
<<
hostname
() <<
" "
62
<<
loggerTimestamp
());
63
return
os.good();
64
}
65
66
#ifdef G2O_HAVE_OPENGL
67
VertexTagDrawAction::VertexTagDrawAction()
68
:
DrawAction
(typeid(
VertexTag
).name()), _textSize(nullptr) {}
69
70
bool
VertexTagDrawAction::refreshPropertyPtrs(
71
HyperGraphElementAction::Parameters* params_) {
72
if
(!
DrawAction::refreshPropertyPtrs
(params_))
return
false
;
73
if
(_previousParams) {
74
_textSize = _previousParams->makeProperty<
DoubleProperty
>(
75
_typeName +
"::TEXT_SIZE"
, 1);
76
}
else
{
77
_textSize = 0;
78
}
79
return
true
;
80
}
81
82
HyperGraphElementAction
* VertexTagDrawAction::operator()(
83
HyperGraph::HyperGraphElement
* element,
84
HyperGraphElementAction::Parameters
* params_) {
85
if
(
typeid
(*element).name() != _typeName)
return
nullptr
;
86
87
refreshPropertyPtrs(params_);
88
if
(!_previousParams) {
89
return
this
;
90
}
91
VertexTag
* that =
static_cast<
VertexTag
*
>
(element);
92
93
glPushMatrix();
94
glColor3f(1.f, 0.2f, 1.f);
95
glTranslatef(that->position().x(), that->position().y(),
96
that->position().z());
97
float
textSize = 1;
98
if
(_textSize) textSize = (float)_textSize->value();
99
opengl::drawBox
(0.1f * textSize, 0.1f * textSize, 0.1f * textSize);
100
glTranslatef(0.2f * textSize, 0.f, 0.f);
101
glScalef(0.003f * textSize, 0.003f * textSize, 1.f);
102
freeglut_minimal::glutStrokeString
(
freeglut_minimal::GLUT_STROKE_ROMAN
,
103
that->name().c_str());
104
glPopMatrix();
105
return
this
;
106
}
107
#endif
108
109
}
// namespace g2o
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::RobotData::timestamp
double timestamp() const
Definition
robot_data.h:46
g2o::RobotData::_loggerTimestamp
double _loggerTimestamp
timestamp when the measurement was recorded
Definition
robot_data.h:60
g2o::RobotData::loggerTimestamp
double loggerTimestamp() const
Definition
robot_data.h:49
g2o::RobotData::hostname
const std::string & hostname() const
Definition
robot_data.h:55
g2o::RobotData::_hostname
std::string _hostname
name of the computer/robot generating the data
Definition
robot_data.h:63
g2o::RobotData::_timestamp
double _timestamp
timestamp when the measurement was generated
Definition
robot_data.h:59
g2o::RobotData::RobotData
RobotData()
Definition
robot_data.cpp:31
g2o::VertexTag
string tag to be attached to a vertex
Definition
vertex_tag.h:43
g2o::VertexTag::_odom2d
Vector3F _odom2d
Definition
vertex_tag.h:60
g2o::VertexTag::~VertexTag
~VertexTag()
Definition
vertex_tag.cpp:44
g2o::VertexTag::_name
std::string _name
Definition
vertex_tag.h:58
g2o::VertexTag::read
virtual bool read(std::istream &is)
read the data from a stream
Definition
vertex_tag.cpp:46
g2o::VertexTag::_position
Vector3F _position
Definition
vertex_tag.h:59
g2o::VertexTag::VertexTag
VertexTag()
Definition
vertex_tag.cpp:42
g2o::VertexTag::write
virtual bool write(std::ostream &os) const
write the data to a stream
Definition
vertex_tag.cpp:56
freeglut_minimal.h
macros.h
freeglut_minimal::GLUT_STROKE_ROMAN
@ GLUT_STROKE_ROMAN
Definition
freeglut_minimal.h:61
freeglut_minimal::glutStrokeString
void glutStrokeString(FontID fontID, const char *string_)
Definition
freeglut_font.cpp:52
g2o::opengl::drawBox
void drawBox(GLfloat l, GLfloat w, GLfloat h)
Definition
opengl_primitives.cpp:100
g2o
Definition
dl_wrapper.cpp:55
g2o::DoubleProperty
Property< double > DoubleProperty
Definition
property.h:151
std
Definition
jet.h:876
opengl_primitives.h
opengl_wrapper.h
g2o::HyperGraphElementAction::Parameters
Definition
hyper_graph_action.h:76
g2o::HyperGraph::HyperGraphElement
Definition
hyper_graph.h:80
vertex_tag.h
Generated on
for g2o by
1.17.0