HokuyoAIST
3.0.2
Main Page
Namespaces
Classes
Files
File List
File Members
include
hokuyoaist
utils.h
Go to the documentation of this file.
1
/* HokuyoAIST
2
*
3
* Header file for various utilities.
4
*
5
* Copyright 2008-2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp
6
* RT-Synthesis Research Group
7
* Intelligent Systems Research Institute,
8
* National Institute of Advanced Industrial Science and Technology (AIST),
9
* Japan
10
* All rights reserved.
11
*
12
* This file is part of HokuyoAIST.
13
*
14
* HokuyoAIST is free software; you can redistribute it and/or modify it
15
* under the terms of the GNU Lesser General Public License as published
16
* by the Free Software Foundation; either version 2.1 of the License,
17
* or (at your option) any later version.
18
*
19
* HokuyoAIST is distributed in the hope that it will be useful, but
20
* WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
* Lesser General Public License for more details.
23
*
24
* You should have received a copy of the GNU Lesser General Public
25
* License along with HokuyoAIST. If not, see
26
* <http://www.gnu.org/licenses/>.
27
*/
28
29
#ifndef UTILS_H__
30
#define UTILS_H__
31
32
#include <algorithm>
33
#include <cassert>
34
#include <flexiport/port.h>
35
#include <iostream>
36
#include <string>
37
#include <vector>
38
39
#if defined(WIN32)
40
typedef
unsigned
char
uint8_t;
41
typedef
unsigned
int
uint32_t;
42
#if defined(HOKUYOAIST_STATIC)
43
#define HOKUYOAIST_EXPORT
44
#elif defined(hokuyoaist_EXPORTS)
45
#define HOKUYOAIST_EXPORT __declspec(dllexport)
46
#else
47
#define HOKUYOAIST_EXPORT __declspec(dllimport)
48
#endif
49
#else
50
#include <stdint.h>
51
#define HOKUYOAIST_EXPORT
52
#endif
53
57
58
namespace
hokuyoaist
59
{
60
61
#ifndef M_PI
62
double
const
M_PI
= 3.14159265358979323846;
63
#endif
64
// Convert radians to degrees
65
#ifndef RTOD
66
inline
double
RTOD
(
double
rad)
67
{
68
return
rad * 180.0 /
M_PI
;
69
}
70
#endif
71
// Convert degrees to radians
72
#ifndef DTOR
73
inline
double
DTOR
(
double
deg)
74
{
75
return
deg *
M_PI
/ 180.0;
76
}
77
#endif
78
79
81
template
<
typename
T>
82
inline
T
median
(std::vector<T>& v)
83
{
84
typename
std::vector<T>::iterator first(v.begin());
85
typename
std::vector<T>::iterator
median
(first + (v.end() - first) / 2);
86
std::nth_element(first,
median
, v.end());
87
return
*
median
;
88
}
89
90
}
// namespace hokuyoaist
91
93
94
#endif
// UTILS_H__
95
hokuyoaist
Definition
hokuyo_errors.h:54
hokuyoaist::DTOR
double DTOR(double deg)
Definition
utils.h:73
hokuyoaist::M_PI
double const M_PI
Definition
utils.h:62
hokuyoaist::median
T median(std::vector< T > &v)
Find the median value of a std::vector.
Definition
utils.h:82
hokuyoaist::RTOD
double RTOD(double rad)
Definition
utils.h:66
Generated on Fri Jan 17 2025 00:00:00 for HokuyoAIST by
1.13.2