snark
Main Page
Classes
Files
File List
snark
sensors
velodyne
thin
region.h
1
// This file is part of snark, a generic and flexible library
2
// for robotics research.
3
//
4
// Copyright (C) 2011 The University of Sydney
5
//
6
// snark is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU Lesser General Public
8
// License as published by the Free Software Foundation; either
9
// version 3 of the License, or (at your option) any later version.
10
//
11
// snark is distributed in the hope that it will be useful, but WITHOUT ANY
12
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
// for more details.
15
//
16
// You should have received a copy of the GNU Lesser General Public
17
// License along with snark. If not, see <http://www.gnu.org/licenses/>.
18
19
#ifndef SNARK_SENSORS_VELODYNE_THIN_REGION
20
#define SNARK_SENSORS_VELODYNE_THIN_REGION
21
22
#include <comma/math/cyclic.h>
23
#include <comma/visiting/traits.h>
24
25
namespace
snark {
namespace
velodyne {
namespace
thin {
26
28
struct
region
29
{
30
virtual
~
region
() {}
31
virtual
bool
has(
double
range,
double
bearing,
double
elevation )
const
= 0;
32
virtual
double
coverage()
const
= 0;
33
};
34
36
struct
sector
:
public
region
37
{
38
sector
();
39
sector
(
double
bearing,
double
ken,
double
range = 0 );
40
bool
has(
double
range,
double
bearing,
double
)
const
;
41
double
coverage()
const
;
42
comma::math::cyclic< double > bearing;
43
double
ken;
44
double
range;
45
};
46
47
} } }
// namespace snark { namespace velodyne { namespace thin {
48
49
namespace
comma {
namespace
visiting {
// quick and dirty
50
51
template
<>
struct
traits< snark::velodyne::thin::sector >
52
{
53
template
<
typename
Key,
class
Visitor >
54
static
void
visit(
const
Key&,
const
snark::velodyne::thin::sector
& p, Visitor& v )
55
{
56
v.apply(
"bearing"
, p.bearing() );
57
v.apply(
"ken"
, p.ken );
58
v.apply(
"range"
, p.range );
59
}
60
61
template
<
typename
Key,
class
Visitor >
62
static
void
visit(
const
Key&,
snark::velodyne::thin::sector
& p, Visitor& v )
63
{
64
double
bearing = p.bearing();
65
v.apply(
"bearing"
, bearing );
66
p.bearing = bearing;
67
//p.bearing = comma::math::cyclic< double >( snark::math::Interval< double >( -180.0, 180.0 ), bearing );
68
v.apply(
"ken"
, p.ken );
69
v.apply(
"range"
, p.range );
70
}
71
};
72
73
} }
// namespace comma { namespace visiting {
74
75
#endif // #ifndev SNARK_SENSORS_VELODYNE_THIN_REGION
76
Generated on Fri Nov 16 2012 12:42:42 for snark by
1.8.1.2