g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
data
raw_laser.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 "
raw_laser.h
"
28
29
#include <iostream>
30
31
#include "
g2o/stuff/logger.h
"
32
33
using namespace
std
;
34
35
namespace
g2o
{
36
37
RawLaser::RawLaser
()
38
:
RobotData
(),
39
_laserParams
(0, 180, -
const_pi
() / 2,
const_pi
() / 180, 50,
cst
(0.1), 0) {
40
}
41
42
RawLaser::~RawLaser
() {}
43
44
bool
RawLaser::write
(std::ostream&
/*os*/
)
const
{
45
// TODO(Rainer): implement writing of raw laser
46
G2O_ERROR
(
"RawLaser::write() not implemented yet."
);
47
return
false
;
48
}
49
50
bool
RawLaser::read
(std::istream& is) {
51
int
type;
52
double
angle, fov, res, maxrange, acc;
53
int
remission_mode;
54
is >> type >> angle >> fov >> res >> maxrange >> acc >> remission_mode;
55
56
int
beams;
57
is >> beams;
58
_laserParams
=
59
LaserParameters
(type, beams, angle, res, maxrange, acc, remission_mode);
60
_ranges
.resize(beams);
61
for
(
int
i = 0; i < beams; i++) is >>
_ranges
[i];
62
63
is >> beams;
64
_remissions
.resize(beams);
65
for
(
int
i = 0; i < beams; i++) is >>
_remissions
[i];
66
67
// timestamp + host
68
is >>
_timestamp
;
69
is >>
_hostname
;
70
is >>
_loggerTimestamp
;
71
return
true
;
72
}
73
74
void
RawLaser::setRanges
(
const
vector<double>&
ranges
) {
_ranges
=
ranges
; }
75
76
void
RawLaser::setRemissions
(
const
std::vector<double>&
remissions
) {
77
_remissions
=
remissions
;
78
}
79
80
void
RawLaser::setLaserParams
(
const
LaserParameters
&
laserParams
) {
81
_laserParams
=
laserParams
;
82
}
83
84
RawLaser::Point2DVector
RawLaser::cartesian
()
const
{
85
Point2DVector
points;
86
for
(
size_t
i = 0; i <
_ranges
.size(); ++i) {
87
const
double
& r =
_ranges
[i];
88
if
(r < _laserParams.maxRange && r >
_laserParams
.minRange) {
89
double
alpha =
_laserParams
.firstBeamAngle + i *
_laserParams
.angularStep;
90
points.push_back(
Vector2
(std::cos(alpha) * r, std::sin(alpha) * r));
91
}
92
}
93
return
points;
94
}
95
96
}
// namespace g2o
g2o::RawLaser::ranges
const std::vector< double > & ranges() const
the range measurements by the laser
Definition
raw_laser.h:63
g2o::RawLaser::_remissions
std::vector< double > _remissions
Definition
raw_laser.h:76
g2o::RawLaser::_ranges
std::vector< double > _ranges
Definition
raw_laser.h:75
g2o::RawLaser::~RawLaser
~RawLaser()
Definition
raw_laser.cpp:42
g2o::RawLaser::setLaserParams
void setLaserParams(const LaserParameters &laserParams)
Definition
raw_laser.cpp:80
g2o::RawLaser::laserParams
const LaserParameters & laserParams() const
the parameters of the laser
Definition
raw_laser.h:71
g2o::RawLaser::RawLaser
RawLaser()
Definition
raw_laser.cpp:37
g2o::RawLaser::cartesian
Point2DVector cartesian() const
Definition
raw_laser.cpp:84
g2o::RawLaser::setRanges
void setRanges(const std::vector< double > &ranges)
Definition
raw_laser.cpp:74
g2o::RawLaser::setRemissions
void setRemissions(const std::vector< double > &remissions)
Definition
raw_laser.cpp:76
g2o::RawLaser::read
virtual bool read(std::istream &is)
read the data from a stream
Definition
raw_laser.cpp:50
g2o::RawLaser::_laserParams
LaserParameters _laserParams
Definition
raw_laser.h:77
g2o::RawLaser::Point2DVector
std::vector< Vector2 > Point2DVector
Definition
raw_laser.h:47
g2o::RawLaser::write
virtual bool write(std::ostream &os) const
write the data to a stream
Definition
raw_laser.cpp:44
g2o::RawLaser::remissions
const std::vector< double > & remissions() const
the remission measurements by the laser
Definition
raw_laser.h:67
g2o::RobotData::_loggerTimestamp
double _loggerTimestamp
timestamp when the measurement was recorded
Definition
robot_data.h:60
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_ERROR
#define G2O_ERROR(...)
logger.h
g2o
Definition
dl_wrapper.cpp:55
g2o::cst
constexpr double cst(long double v)
Definition
misc.h:60
g2o::Vector2
VectorN< 2 > Vector2
Definition
eigen_types.h:50
g2o::const_pi
constexpr double const_pi()
Definition
misc.h:62
std
Definition
jet.h:876
raw_laser.h
g2o::LaserParameters
parameters for a 2D range finder
Definition
laser_parameters.h:38
Generated on
for g2o by
1.17.0