2 #include "../csm/csm_all.h" 7 int main(
int argc,
const char * argv[]) {
16 sm_error(
"Invalid laser data (#%d in file)\n", count);
32 double sum_weight = 0;
36 sum_x += weight[i] * x[i];
37 sum_weight += weight[i];
39 return sum_x / sum_weight;
45 for(i=0;i<ld->
nrays;i++) {
46 if(-1 == ld->
cluster[i])
continue;
48 int this_cluster = ld->
cluster[i];
49 int indexes[ld->
nrays];
53 for(j=i;j<ld->
nrays;j++)
54 if(ld->
cluster[j]==this_cluster)
55 indexes[nindexes++] = j;
57 double alpha[nindexes];
58 double alpha_weight[nindexes];
59 for(j=0;j<nindexes;j++) {
60 alpha[j] = ld->
alpha[indexes[j]];
61 alpha_weight[j] = 1 / ld->
cov_alpha[indexes[j]];
64 double est_alpha =
weighted_mean(alpha, alpha_weight, nindexes);
67 double rho_weight[nindexes];
68 for(j=0;j<nindexes;j++) {
70 double theta = ld->
theta[i];
71 double x = cos(theta) * ld->
readings[i];
72 double y = sin(theta) * ld->
readings[i];
73 rho[j] = cos(est_alpha) * x + sin(est_alpha) * y;
74 rho_weight[j] = 1 / ( cos(est_alpha) * cos(theta)
75 + sin(est_alpha) * sin(theta) );
80 for(j=0;j<nindexes;j++) {
82 double theta = ld->
theta[i];
83 ld->
readings[i] = est_rho / (cos(est_alpha) * cos(theta)
84 + sin(est_alpha) * sin(theta));
87 i = indexes[nindexes-1];
double *restrict cov_alpha
void ld_linearize(LDP ld)
void sm_set_program_name(const char *name)
void ld_write_as_json(LDP ld, FILE *stream)
int ld_valid_fields(LDP ld)
double weighted_mean(double *x, double *weight, int n)
LDP ld_read_smart(FILE *)
int main(int argc, const char *argv[])
double *restrict readings
void sm_error(const char *msg,...)