00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00027 /*************************************************************************************/ 00028 /* */ 00029 /* File: MbICP.h */ 00030 /* Authors: Luis Montesano and Javier Minguez */ 00031 /* Modified: 1/3/2006 */ 00032 /* */ 00033 /* This library implements the: */ 00034 /* */ 00035 /* J. Minguez, F. Lamiraux and L. Montesano */ 00036 /* Metric-Based Iterative Closest Point, */ 00037 /* Scan Matching for Mobile Robot Displacement Estimation */ 00038 /* IEEE Transactions on Roboticics (2006) */ 00039 /* */ 00040 /*************************************************************************************/ 00041 /* 00042 * This program is free software; you can redistribute it and/or modify 00043 * it under the terms of the GNU General Public License as published by 00044 * the Free Software Foundation; either version 2 of the License, or 00045 * (at your option) any later version. 00046 * 00047 * This program is distributed in the hope that it will be useful, 00048 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00049 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00050 * GNU General Public License for more details. 00051 * 00052 * You should have received a copy of the GNU General Public License 00053 * along with this program; if not, write to the Free Software 00054 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00055 * 00056 */ 00057 00058 /* **************************************************************************************** */ 00059 // This file contains inner information of the MbICP that you want to see from the outside 00060 /* **************************************************************************************** */ 00061 00067 #ifndef MbICP2 00068 #define MbICP2 00069 00070 #include "MbICP.h" 00071 #include "TData.h" 00072 00073 #ifdef __cplusplus 00074 extern "C" { 00075 #endif 00076 00077 // --------------------------------------------------------------- 00078 // --------------------------------------------------------------- 00079 // Types definition 00080 // --------------------------------------------------------------- 00081 // --------------------------------------------------------------- 00082 00083 00084 // ************************ 00085 // Associations information 00086 00087 /* 00088 typedef struct{ 00089 float rx,ry,nx,ny,dist; // Point (nx,ny), static corr (rx,ry), dist 00090 int numDyn; // Number of dynamic associations 00091 float unknown; // Unknown weight 00092 int index; // Index within the original scan 00093 int L,R; 00094 }TAsoc; 00095 */ 00096 00097 // ************************ 00098 // Scan inner matching parameters 00099 typedef struct{ 00100 /* --------------------- */ 00101 /* --- Thresold parameters */ 00102 /* Bw: maximum angle diference between points of different scans */ 00103 /* Points with greater Bw cannot be correspondent (eliminate spurius asoc.) */ 00104 /* This is a speed up parameter */ 00105 float Bw; 00106 00107 /* Br: maximum distance difference between points of different scans */ 00108 /* Points with greater Br cannot be correspondent (eliminate spurius asoc.) */ 00109 float Br; 00110 00111 /* --------------------- */ 00112 /* --- Inner parameters */ 00113 00114 /* L: value of the metric */ 00115 /* When L tends to infinity you are using the standart ICP */ 00116 /* When L tends to 0 you use the metric (more importance to rotation */ 00117 float LMET; 00118 00119 /* laserStep: selects points of each scan with an step laserStep */ 00120 /* When laserStep=1 uses all the points of the scans */ 00121 /* When laserStep=2 uses one each two ... */ 00122 /* This is an speed up parameter */ 00123 int laserStep; 00124 00125 /* ProjectionFilter: */ 00126 /* Eliminate the points that cannot be seen given the two scans (see Lu&Millios 97) */ 00127 /* It works well for angles < 45 \circ*/ 00128 /* 1 : activates the filter */ 00129 /* 0 : desactivates the filter */ 00130 int ProjectionFilter; 00131 00132 /* MaxDistInter: maximum distance to interpolate between points in the ref scan */ 00133 /* Consecutive points with less Euclidean distance than MaxDistInter are considered to be a segment */ 00134 float MaxDistInter; 00135 00136 /* filtrado: in [0,1] sets the % of asociations NOT considered spurious */ 00137 float filter; 00138 00139 /* AsocError: in [0,1] */ 00140 /* One way to check if the algorithm diverges if to supervise if the number of associatios goes below a thresold */ 00141 /* When the number of associations is below AsocError, the main function will return error in associations step */ 00142 float AsocError; 00143 00144 /* --------------------- */ 00145 /* --- Exit parameters */ 00146 /* MaxIter: sets the maximum number of iterations for the algorithm to exit */ 00147 /* More iterations more chance you give the algorithm to be more accurate */ 00148 int MaxIter; 00149 00150 /* error_th: in [0,1] sets the maximum error ratio between iterations to exit */ 00151 /* In each iteration, the error is the residual of the minimization */ 00152 /* When error_th tends to 1 more precise is the solution of the scan matching */ 00153 float error_th; 00154 00155 /* errx_out,erry_out, errt_out: minimum error of the asociations to exit */ 00156 /* In each iteration, the error is the residual of the minimization in each component */ 00157 /* The condition is (lower than errx_out && lower than erry_out && lower than errt_out */ 00158 /* When error_XXX tend to 0 more precise is the solution of the scan matching */ 00159 float errx_out,erry_out, errt_out; 00160 00161 /* IterSmoothConv: number of consecutive iterations that satisfity the error criteria */ 00162 /* (error_th) OR (errorx_out && errory_out && errt_out) */ 00163 /* With this parameter >1 avoids random solutions */ 00164 int IterSmoothConv; 00165 00166 }TSMparams; 00167 00168 // ************************ 00169 // Structure to store the scans in polar and cartesian coordinates 00170 00171 /* 00172 typedef struct { 00173 int numPuntos; 00174 Tpf laserC[MAXLASERPOINTS]; // Cartesian coordinates 00175 Tpfp laserP[MAXLASERPOINTS]; // Polar coordinates 00176 }Tscan; 00177 */ 00178 00179 // --------------------------------------------------------------- 00180 // --------------------------------------------------------------- 00181 // Variables definition 00182 // --------------------------------------------------------------- 00183 // --------------------------------------------------------------- 00184 00185 00186 // ************************ 00187 // Static structure to initialize the SM parameters 00188 extern TSMparams params; 00189 00190 // Original points to be aligned 00191 extern Tscan ptosRef; 00192 extern Tscan ptosNew; 00193 00194 // At each step:: 00195 00196 // Those points removed by the projection filter (see Lu&Millios -- IDC) 00197 extern Tscan ptosNoView; // Only with ProjectionFilter=1; 00198 00199 // Structure of the associations before filtering 00200 extern TAsoc cp_associations[MAXLASERPOINTS]; 00201 extern int cntAssociationsT; 00202 00203 // Filtered Associations 00204 extern TAsoc cp_associationsTemp[MAXLASERPOINTS]; 00205 extern int cntAssociationsTemp; 00206 00207 // Current motion estimation 00208 extern Tsc motion2; 00209 00210 #ifdef __cplusplus 00211 } 00212 #endif 00213 00214 #endif