hregions.hh
1/*
2 * Player - One Hell of a Robot Server
3 * Copyright (C) 2010
4 * Mayte Lázaro, Alejandro R. Mosteo
5 *
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef HREGIONS_H_
23#define HREGIONS_H_
24
25#include <vector>
26#include "scan.hh"
27#include "types.hh"
28
30#define DF (20)
31#define NALPHAS (6)
32
33const double
34CHISQUARE[DF][NALPHAS] =
35{ { 7.88, 6.63, 5.02, 3.84, 2.71, 1.32 },
36 { 10.6, 9.21, 7.38, 5.99, 4.61, 2.77 },
37 { 12.8, 11.3, 9.35, 7.81, 6.25, 4.11 },
38 { 14.9, 13.3, 11.1, 9.49, 7.78, 5.39 },
39 { 16.7, 15.1, 12.8, 11.1, 9.24, 6.63 },
40 { 18.5, 16.8, 14.4, 12.6, 10.6, 7.84 },
41 { 20.3, 18.5, 16.0, 14.1, 12.0, 9.04 },
42 { 22.0, 20.1, 17.5, 15.5, 13.4, 10.2 },
43 { 23.6, 21.7, 19.0, 16.9, 14.7, 11.4 },
44 { 25.2, 23.2, 20.5, 18.3, 16.0, 12.5 },
45 { 26.8, 24.7, 21.9, 19.7, 17.3, 13.7 },
46 { 28.3, 26.2, 23.3, 21.0, 18.5, 14.8 },
47 { 29.8, 27.7, 24.7, 22.4, 19.8, 16.0 },
48 { 31.3, 29.1, 26.1, 23.7, 21.1, 17.1 },
49 { 32.8, 30.6, 27.5, 25.0, 22.3, 18.2 },
50 { 34.3, 32.0, 28.8, 26.3, 23.5, 19.4 },
51 { 35.7, 33.4, 30.2, 27.6, 24.8, 20.5 },
52 { 37.2, 34.8, 31.5, 28.9, 26.0, 21.6 },
53 { 38.6, 36.2, 32.9, 30.1, 27.2, 22.7 },
54 { 40.0, 37.6, 34.2, 31.4, 28.4, 23.8 }
55};
56
57#define COLUMN(a) ((a) <= 5 ? 0 : ((a) <= 10 ? 1 : ((a) <= 20 ? 2 : ((a) <= 50 ? 3 : ((a) <= 100 ? 4 : 5)))))
58#define RADIANS(d) ((d)*M_PI/180.0)
59
60// see params.hh
61// const int D_MAX_LOST_PNT = 4;
62// const double D_LASER_ANG_RES = 0.5;
63
65{
66public:
67 Endpoint(const Scan &s, int idx) : idx_(idx) {}
68
69 const int idx(void) const { return idx_; }
70
71 bool operator < (const Endpoint &rhs) const { return idx_ < rhs.idx_; }
72
73private:
74 int idx_;
75};
76
77typedef std::vector<Endpoint> EndpointsVector;
78
80{
81public:
82 HRegion(const Scan &s, int idxFrom, int idxTo);
83 virtual ~HRegion() {}
84
85 const int NumEps(void) const { return endpoints_.size(); }
86 const Endpoint &Ep(int i) const { return endpoints_.at(i); }
87
88 void IterativeLineSplit(int fromIdx, int toIdx);
89 void IterativeLineSplit(void); // Initiator of recursion
90
91 void PushGuiData(GuiData *gui_data) const;
92private:
93 GuiRegion GetGuiRegion(void) const;
94 GuiSplit GetGuiSplit(int i) const;
95
96 const Scan *scan_;
97 EndpointsVector endpoints_;
98};
99
100typedef std::vector<HRegion> RegionsVector;
101
102/*
103#define RG_LEN(r) ((r).len)
104#define RG_EP2(r, i) ((r).ep[i])
105#define RG_NUM_EP(r, i) ((r).ep[i].len)
106#define RG_EP(r, i, j) ((r).ep[i].idx[j])
107#define RG_FROM(r, i) ((r).ep[i].idx[0])
108#define RG_TO(r, i) ((r).ep[i].idx[(r).ep[i].len-1])
109*/
110
111/*
112#define HRP(p) ((p).par)
113#define HRP_MAX_EMPTY_ANGLE(p) ((p).maxEmptyAng)
114#define HRP_ALPHA_HREG(p) ((p).alphaReg)
115#define HRP_MIN_PNT_REG(p) ((p).minPntReg)
116#define HRP_MIN_LEN_REG(p) ((p).minLenReg)
117
118#define HRP_ALPHA_ILF(p) ((p).alphaILF)
119#define HRP_CHECK_RESIDUAL(p) ((p).checkResidual)
120#define HRP_MIN_DIST_EP(p) ((p).minDistEP)
121#define HRP_MAX_EBE_ANG(p) ((p).maxAngEBE)
122*/
123
124void FindHomogeneousRegions(const Scan &s, RegionsVector *r);
125void IterativeLineFitting(const Scan &s, RegionsVector *r);
126
127#endif /* HREGIONS_H_ */
Definition hregions.hh:65
Definition types.hh:81
Definition types.hh:67
Definition types.hh:74
Definition hregions.hh:80
Definition scan.hh:31