00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _POLAR_MATCH_
00039 #define _POLAR_MATCH_
00040
00041 #include <stdio.h>
00042
00043
00044
00045
00046
00047
00048
00049
00050 #define PM_PSD_SCANNER 0
00051 #define PM_HOKUYO_URG_04LX 1
00052 #define PM_SICK_LMS200 2
00053 #define PM_HOKUYO_UTM_30LX 3
00054 #define PM_VSCAN 4
00055
00056
00057
00058
00059
00060 #define PM_LASER PM_VSCAN
00061
00062
00063
00064 #define PM_LASER_NAME "VirtualScan" ///< The name of the laser range finder.
00065 #define PM_L_POINTS 720 ///< Maximum number of points in a scan.
00066 #define PM_FOV 360 ///< Field of view of the laser range finder in degrees.
00067 #define PM_MAX_RANGE 100000 ///< [cm] Maximum valid laser range.
00068 #define PM_MIN_VALID_POINTS 80 ///< Minimum number of valid points for scan matching.
00069 #define PM_SEARCH_WINDOW 10 ///< Half window size which is searched for correct orientation.
00070 #define PM_CORRIDOR_THRESHOLD 25.0 ///< Threshold for angle variation between points to determine if scan was taken of a corridor.
00071
00072
00073
00074
00075 #define PM_TIME_DELAY 0 ///<[s] Time delay (time registration error) in the laser measurements. Use 0.02 for SLAMbot.
00076 #define PM_LASER_Y 0 ///<@brief [cm] Y coordinate of the laser on the robot.
00077
00078
00079
00080
00081
00082 #define PM_MIN_RANGE 10.0f ///< [cm] Minimum valid laser range for the reprojected current scan.
00083 #define PM_SEG_MAX_DIST 80.0 ///< The distance between points to break a segment.
00084 #define PM_WEIGHTING_FACTOR 30*30 ///< Parameter used for weighting associated points in the position calculation of PSM. Try setting it to 30*30 for laser odometry.
00085 #define PM_CHANGE_WEIGHT_ITER 10 ///< The number of iterations after which the weighting factor is reduced to weight down outliers.
00086
00087 #define PM_TYPE double ///< The variable type used in calculations. Change it to double for higher accuracy and lower speed.
00088
00089 #define PM_MAX_ERROR 100 ///< [cm] Maximum distance between associated points used in pose estimation. Try setting it to 30 for laser odometry.
00090
00091 #define PM_STOP_COND 0.1 ///< If the pose change (|dx|+|dy|+|dth|) is smaller than this PSM scan matching stops.
00092 #define PM_MAX_ITER 500 ///< Maximum number of iterations for PSM.
00093 #define PM_MAX_ITER_ICP 500 ///< Maximum number of iterations for ICP
00094 #define PM_STOP_COND_ICP 0.1 ///< Stopping condition for ICP. The pose change has to be smaller than this.
00095
00096 #define PM_MIN_STD_XY 5.0 ///<[cm] The minimum match result standard deviation in X or Y direction. Used in covariance estimation.
00097 #define PM_MIN_STD_ORIENTATION 4.0 ///<[degrees] The minimum standard deviation of the orientation match. Used in covariance estimation.
00098 #define PM_MATCH_ERROR_OFFSET 5.0 ///<[cm] Offset subtracted from average range residual when scaling the covariance matrix.
00099
00100 #define PM_ODO -1 ///< Show results with odometry only in mapping_with_matching().
00101 #define PM_PSM 1 ///< Polar scan matching - matching bearing association rule.
00102 #define PM_ICP 3 ///< Scan matching with iterative closest point association rule.
00103
00104 #define PM_TIME_FILE "results/iterations.txt" ///< When generating results, timing is data is saved into this file from the matching algorithms. i|time|ax|ay|ath[deg] is saved. Does not work in the moment.
00105
00106
00107 #define PM_RANGE 1 ///< Measurement tag: range reading is longer than PM_MAX_RANGE.
00108 #define PM_MOVING 2 ///< Measurement tag: range reading corresponds to a moving point. Not implemented yet.
00109 #define PM_MIXED 4 ///< Measurement tag: range reading is a mixed pixel.
00110 #define PM_OCCLUDED 8 ///< Measurement tag: range reading is occluded.
00111 #define PM_EMPTY 16 ///< Measurement tag: no measurment (between 2 segments there is no interpolation!)
00112
00113 extern PM_TYPE pm_fi[PM_L_POINTS];
00114 extern PM_TYPE pm_si[PM_L_POINTS];
00115 extern PM_TYPE pm_co[PM_L_POINTS];
00116 extern const PM_TYPE PM_D2R;
00117 extern const PM_TYPE PM_R2D;
00118
00128 struct PMScan
00129 {
00130 double t;
00131 PM_TYPE rx;
00132 PM_TYPE ry;
00133 PM_TYPE th;
00134 PM_TYPE r[PM_L_POINTS];
00135 PM_TYPE x[PM_L_POINTS];
00136 PM_TYPE y[PM_L_POINTS];
00137 int bad[PM_L_POINTS];
00138
00139
00140 int seg[PM_L_POINTS];
00141 };
00142
00143 void pm_init(const char* filename=NULL, FILE **fin=NULL);
00144 int pm_readScan(FILE *fin, PMScan *ls);
00145 void pm_save_scan(PMScan *act,const char *filename);
00146
00147 void pm_preprocessScan(PMScan *ls);
00148
00149 PM_TYPE pm_psm( const PMScan *lsr,PMScan *lsa);
00150 PM_TYPE pm_icp( const PMScan *lsr,PMScan *lsa);
00151
00152 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);
00153 void pm_plotScan(PMScan *ls, const char *col,double diameter = 2.0, bool connect_lines = false);
00154 void pm_show_segmentation(const PMScan *ls);
00155 void pm_plotScan4Thesis(PMScan *lsr,PMScan *lsa);
00156 void pm_plotTime4Thesis(PM_TYPE xt, PM_TYPE yt, PM_TYPE tht,int *iter=NULL,double *time=NULL);
00157
00158 bool pm_is_corridor(PMScan *act);
00159 PM_TYPE pm_error_index(PMScan *lsr,PMScan *lsa);
00160 PM_TYPE pm_error_index2 ( PMScan *ref,PMScan *cur, int* associatedPoints=NULL );
00161 PM_TYPE pm_corridor_angle(PMScan *act);
00162 void pm_cov_est(PM_TYPE err, double *c11,double *c12, double *c22, double *c33,
00163 bool corridor=false, PM_TYPE corr_angle=0);
00164
00165 void pm_unit_test(int matching_alg = PM_PSM, bool interactive=true);
00166 #endif