polar_match.h
Go to the documentation of this file.
1 
6 /* **************************************************************************
7  polar_match.h - Matching laser scans in polar coord system
8  -------------------
9  begin : Tue Nov 9 2004
10  version : 0.3
11  copyright : (C) 2004-2010 by Albert Diosi and Lindsay Kleeman
12  email : albert.diosi@gmail.com
13  comments : - range units are cm; angle units are radians or degrees
14  - the laser is on the robot's Y axis
15  - in scan projections, occluded ref scanpoints are not removed!
16  - TODO: Investigate why is checking the range difference necessary for
17  the Hokuyo UTM and not for the rest.
18  ***************************************************************************/
19 /****************************************************************************
20 Copyright (c) 2004-2010, Albert Diosi and Lindsay Kleeman
21 All rights reserved.
22 
23 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
24 
25  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
27  * The name of the copyright holders may not be used to endorse or promote products derived from this software without specific prior written permission.
28 
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 ****************************************************************************/
31 
32 /*
33 First of all you need to select the laser range finder you have by
34 setting "#define PM_LASER "
35 to PM_SICK_LMS200, PM_HOKUYO_URG_04LX.
36 */
37 
38 #ifndef _POLAR_MATCH_
39 #define _POLAR_MATCH_
40 
41 #include <stdio.h>
42 
43 //TODO: get the result generation to work again:
44 //#define PM_GENERATE_RESULTS //If left uncommented scanmatching results are
45  //saved into the "results"directory if two required programs are present.
46 
47 //----------------- L A S E R S P E C I F I C P A R A M E T E R S------------
48 
49 // STEP 1) Define a name for your laser range finder here (if it hasn't been defined yet):
50 #define PM_PSD_SCANNER 0
51 #define PM_HOKUYO_URG_04LX 1
52 #define PM_SICK_LMS200 2
53 #define PM_HOKUYO_UTM_30LX 3
54 #define PM_VSCAN 4
55 
56 // STEP 2) Set the type your laser range finder here:
57 // #define PM_LASER PM_SICK_LMS200
58 // #define PM_LASER PM_HOKUYO_URG_04LX
59 // #define PM_LASER PM_PSD_SCANNER
60  #define PM_LASER PM_VSCAN
61 
62 // STEP 3) Add your laser range finder's parameters here if it is a different model (use centimeters)
63 
64  #define PM_LASER_NAME "VirtualScan"
65  #define PM_L_POINTS 720
66  #define PM_FOV 360
67  #define PM_MAX_RANGE 100000
68  #define PM_MIN_VALID_POINTS 80
69  #define PM_SEARCH_WINDOW 10
70  #define PM_CORRIDOR_THRESHOLD 25.0
71 
72 // STEP 4) Set the time registration delay (the time between your time stamps and the
73 // time the scan was taken) and the distance of your laser from the odometry center
74 // in the forward direction.
75 #define PM_TIME_DELAY 0
76 #define PM_LASER_Y 0
77 #define PM_MIN_RANGE 10.0f
83 #define PM_SEG_MAX_DIST 80.0
84 #define PM_WEIGHTING_FACTOR 30*30
85 #define PM_CHANGE_WEIGHT_ITER 10
86 
87 #define PM_TYPE double
88 
89 #define PM_MAX_ERROR 100
90 //#define PM_STOP_COND 0.001
91 #define PM_STOP_COND 0.1
92 #define PM_MAX_ITER 500
93 #define PM_MAX_ITER_ICP 500
94 #define PM_STOP_COND_ICP 0.1
95 
96 #define PM_MIN_STD_XY 5.0
97 #define PM_MIN_STD_ORIENTATION 4.0
98 #define PM_MATCH_ERROR_OFFSET 5.0
99 
100 #define PM_ODO -1
101 #define PM_PSM 1
102 #define PM_ICP 3
103 
104 #define PM_TIME_FILE "results/iterations.txt"
105 
106 // Description of range reading errors. Each range measurement may be tagged with one of these:
107 #define PM_RANGE 1
108 #define PM_MOVING 2
109 #define PM_MIXED 4
110 #define PM_OCCLUDED 8
111 #define PM_EMPTY 16
112 
113 extern PM_TYPE pm_fi[PM_L_POINTS];
114 extern PM_TYPE pm_si[PM_L_POINTS];
115 extern PM_TYPE pm_co[PM_L_POINTS];
116 extern const PM_TYPE PM_D2R;
117 extern const PM_TYPE PM_R2D;
118 
128 struct PMScan
129 {
130  double t;
138  int seg[PM_L_POINTS];
141 };
142 
143 void pm_init(const char* filename=NULL, FILE **fin=NULL);
144 int pm_readScan(FILE *fin, PMScan *ls);
145 void pm_save_scan(PMScan *act,const char *filename);
146 
147 void pm_preprocessScan(PMScan *ls);
148 
149 PM_TYPE pm_psm( const PMScan *lsr,PMScan *lsa);
150 PM_TYPE pm_icp( const PMScan *lsr,PMScan *lsa);
151 
152 void pm_plotScanAt(const PMScan *ls, PM_TYPE x,PM_TYPE y,PM_TYPE th,const char *col, double diameter = 2.0, bool connect_lines = false);
153 void pm_plotScan(PMScan *ls, const char *col,double diameter = 2.0, bool connect_lines = false);
154 void pm_show_segmentation(const PMScan *ls);
155 void pm_plotScan4Thesis(PMScan *lsr,PMScan *lsa);
156 void pm_plotTime4Thesis(PM_TYPE xt, PM_TYPE yt, PM_TYPE tht,int *iter=NULL,double *time=NULL);
157 
158 bool pm_is_corridor(PMScan *act);
160 PM_TYPE pm_error_index2 ( PMScan *ref,PMScan *cur, int* associatedPoints=NULL );
162 void pm_cov_est(PM_TYPE err, double *c11,double *c12, double *c22, double *c33,
163  bool corridor=false, PM_TYPE corr_angle=0);
164 
165 void pm_unit_test(int matching_alg = PM_PSM, bool interactive=true);
166 #endif
void pm_plotScan4Thesis(PMScan *lsr, PMScan *lsa)
void pm_show_segmentation(const PMScan *ls)
void pm_plotScanAt(const PMScan *ls, PM_TYPE x, PM_TYPE y, PM_TYPE th, const char *col, double diameter=2.0, bool connect_lines=false)
bool pm_is_corridor(PMScan *act)
Guesses if a scan was taken on a corridor.
void pm_save_scan(PMScan *act, const char *filename)
Saves scan in a text file.
PM_TYPE r[PM_L_POINTS]
[cm] Laser range readings. 0 or negative ranges denote invalid readings.
Definition: polar_match.h:134
int pm_readScan(FILE *fin, PMScan *ls)
Reads one scan from file fin and stores it in ls.
PM_TYPE ry
[cm] Robot odometry Y coordinate.
Definition: polar_match.h:132
void pm_unit_test(int matching_alg=PM_PSM, bool interactive=true)
Performs unit tests on scan matching.
PM_TYPE pm_error_index(PMScan *lsr, PMScan *lsa)
Calculates an error index expressing the quality of a match.
const PM_TYPE PM_R2D
Conversion factor for converting radians to degrees.
Definition: polar_match.cpp:69
void pm_plotTime4Thesis(PM_TYPE xt, PM_TYPE yt, PM_TYPE tht, int *iter=NULL, double *time=NULL)
double t
[s] Time when scan was taken.
Definition: polar_match.h:130
PM_TYPE x[PM_L_POINTS]
[cm] Laser reading X coordinates in Cartesian coordinates.
Definition: polar_match.h:135
#define PM_L_POINTS
Maximum number of points in a scan.
Definition: polar_match.h:65
PM_TYPE pm_error_index2(PMScan *ref, PMScan *cur, int *associatedPoints=NULL)
More quickly calculates an error index expressing the quality of a match.
PM_TYPE pm_si[PM_L_POINTS]
Contains the sinus of each bearing.
Definition: polar_match.cpp:66
PM_TYPE rx
[cm] Robot odometry X coordinate.
Definition: polar_match.h:131
int bad[PM_L_POINTS]
Tag describing the validity of a range measurement. 0 if OK; sources of invalidity - out of range rea...
Definition: polar_match.h:137
void pm_init(const char *filename=NULL, FILE **fin=NULL)
Initialises internal variables and opens a log file.
void pm_cov_est(PM_TYPE err, double *c11, double *c12, double *c22, double *c33, bool corridor=false, PM_TYPE corr_angle=0)
Estimates the covariance matrix of a match.
int seg[PM_L_POINTS]
Describes which segment the range reading belongs to.
Definition: polar_match.h:140
PM_TYPE pm_icp(const PMScan *lsr, PMScan *lsa)
Matches two laser scans using the iterative closest point method.
PM_TYPE th
[rad] Robot orientation.
Definition: polar_match.h:133
#define PM_TYPE
The variable type used in calculations. Change it to double for higher accuracy and lower speed...
Definition: polar_match.h:87
#define PM_PSM
Polar scan matching - matching bearing association rule.
Definition: polar_match.h:101
Structure describing a laser scan.
Definition: polar_match.h:128
PM_TYPE pm_co[PM_L_POINTS]
Contains the cosinus of each bearing.
Definition: polar_match.cpp:67
void pm_preprocessScan(PMScan *ls)
Shows segmentation results by plotting segments with different colours.
PM_TYPE pm_fi[PM_L_POINTS]
Contains precomputed range bearings.
Definition: polar_match.cpp:65
PM_TYPE pm_corridor_angle(PMScan *act)
Determines the orientation of a corridor.
PM_TYPE y[PM_L_POINTS]
[cm] Laser reading Y coordinates in Cartesian coordinates.
Definition: polar_match.h:136
PM_TYPE pm_psm(const PMScan *lsr, PMScan *lsa)
Match two laser scans using polar scan matching.
void pm_plotScan(PMScan *ls, const char *col, double diameter=2.0, bool connect_lines=false)
const PM_TYPE PM_D2R
Conversion factor for converting degrees to radians.
Definition: polar_match.cpp:68


lidar_egomotion
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:10