2 #include "../csm/csm_all.h"
14 int main(
int argc,
const char * argv[]) {
35 sm_error(
"Invalid laser data (#%d in file)\n", count);
49 void cluster_convolve(
const int*cluster,
const double*original,
int n,
double*dest,
double*filter,
int filter_len,
int negate_negative)
55 if(cluster[i] == -1) {
61 for(j=-(filter_len-1);j<=(filter_len-1);j++) {
63 if(i2<0) i2=0;
if(i2>=n) i2=n-1;
64 if(cluster[i2] != cluster[i]) i2 = i;
65 double coeff = filter[abs(j)];
66 if(j<0 && negate_negative) coeff *= -1;
67 dest[i] += original[i2] * coeff;
70 sm_error(
"i: %d; something wrong after processing i2: %d cluster[i2]=%d original[i2] = %f \n", i, i2, cluster[i2], original[i2]);
80 if(cluster[i] == -1)
continue;
81 if( (
max == -1) || (v[i] > v[
max]) )
90 if( (
max == -1) || (v[i] > v[
max]) )
101 int this_cluster = ld->
cluster[i0];
104 for(i=i0;i<ld->
nrays;i++)
105 if(ld->
cluster[i] == this_cluster)
107 else if(ld->
cluster[i] != -1)
break;
114 for(i=0;i<ld->
nrays;) {
115 int this_cluster = ld->
cluster[i];
117 if(this_cluster == -1) { i++;
continue; }
120 if(cluster_size < min_size) {
121 for(;i<ld->
nrays;i++)
122 if(ld->
cluster[i] == this_cluster)
124 else if(ld->
cluster[i] != -1)
break;
131 for(i=0;i<ld->
nrays;i++) {
138 int i=0;
for(i=0;i<n;i++) v[i] = fabs(v[i]);
143 int min_cluster_size = 10;
144 double sigma = 0.005;
145 int orientation_neighbours = 4;
147 double near_peak_threshold = 0.4;
168 double filter[10] = {.5, .4, .3, .2, .2, .2, .2, .2, .2, .2};
169 double deriv_filter[7] = {0, .6, .3, .2, .2, .2, .1};
170 double smooth_alpha[n];
171 double deriv_alpha[n];
183 for(i=0;i<ld->
nrays;i++)
199 int peak_cluster = ld->
cluster[peak];
200 int up = peak;
double threshold = near_peak_threshold * deriv_alpha[peak];
201 while(up<n-1 && (ld->
cluster[up]==peak_cluster) && deriv_alpha[up+1] > threshold) up++;
203 while(down>1 && (ld->
cluster[up]==peak_cluster) && deriv_alpha[down-1] > threshold) down--;
205 for(j=down;j<=up;j++) {
212 for(j = up+1; j<ld->
nrays; j++) {
213 if(ld->
cluster[j] == peak_cluster)