INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
utils.h
1/*
2 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
3 * http://gearbox.sf.net/
4 * Copyright (c) 2008-2010 Geoffrey Biggs
5 *
6 * hokuyo_aist Hokuyo laser scanner driver.
7 *
8 * This distribution is licensed to you under the terms described in the
9 * LICENSE file included in this distribution.
10 *
11 * This work is a product of the National Institute of Advanced Industrial
12 * Science and Technology, Japan. Registration number: H22PRO-1086.
13 *
14 * This file is part of hokuyo_aist.
15 *
16 * This software is licensed under the Eclipse Public License -v 1.0 (EPL). See
17 * http://www.opensource.org/licenses/eclipse-1.0.txt
18 */
19
20#ifndef UTILS_H__
21#define UTILS_H__
22
23#include <flexiport/port.h>
24#include <string>
25#include <vector>
26#include <algorithm>
27#include <cassert>
28
29#include <iostream>
30
31#if defined(WIN32)
32 typedef unsigned char uint8_t;
33 typedef unsigned int uint32_t;
34 #if defined(HOKUYO_AIST_STATIC)
35 #define HOKUYO_AIST_EXPORT
36 #elif defined(HOKUYO_AIST_EXPORTS)
37 #define HOKUYO_AIST_EXPORT __declspec(dllexport)
38 #else
39 #define HOKUYO_AIST_EXPORT __declspec(dllimport)
40 #endif
41#else
42 #include <stdint.h>
43 #define HOKUYO_AIST_EXPORT
44#endif
45
49
50namespace hokuyo_aist
51{
52
53#ifndef M_PI
54 double const M_PI = 3.14159265358979323846;
55#endif
56// Convert radians to degrees
57#ifndef RTOD
58 inline double RTOD(double rad)
59 {
60 return rad * 180.0 / M_PI;
61 }
62#endif
63// Convert degrees to radians
64#ifndef DTOR
65 inline double DTOR(double deg)
66 {
67 return deg * M_PI / 180.0;
68 }
69#endif
70
71
73template<typename T>
74inline T median(std::vector<T>& v)
75{
76 typename std::vector<T>::iterator first(v.begin());
77 typename std::vector<T>::iterator median(first + (v.end() - first) / 2);
78 std::nth_element(first, median, v.end());
79 return *median;
80}
81
82} // namespace hokuyo_aist
83
85
86#endif // UTILS_H__
87
Hokuyo laser scanner driver name space.
T median(std::vector< T > &v)
Find the median value of a std::vector.
Definition utils.h:74
 

Generated for GearBox by  doxygen 1.4.5