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)
void ld_remove_small_clusters(LDP ld, int min_size)
void jj_add_int(const char *name, int v)
void sm_set_program_name(const char *name)
void ld_write_as_json(LDP ld, FILE *stream)
void cluster_convolve(const int *cluster, const double *original, int n, double *dest, double *filter, int filter_len, int negate_negative)
int main(int argc, const char *argv[])
void ld_compute_orientation(LDP ld, int size_neighbourhood, double sigma)
void jj_loop_enter(const char *loop_name)
int ld_valid_fields(LDP ld)
LDP ld_read_smart(FILE *)
double *restrict readings
void ld_mark_cluster_as_invalid(LDP ld, int cluster)
int *restrict alpha_valid
int cluster_find_max(int *cluster, double *v, int n)
int find_max(int *v, int n)
int ld_max_cluster_id(LDP ld)
void jj_add_int_array(const char *name, int *v, int n)
void ld_simple_clustering(LDP ld, double threshold)
int ld_cluster_size(LDP ld, int i0)
void array_abs(double *v, int n)
void jj_add_double_array(const char *name, double *v, int n)
void sm_error(const char *msg,...)
void ld_cluster_curv(LDP ld)
void jj_context_enter(const char *context_name)