4 #include <gsl/gsl_matrix.h> 9 #include "../csm_all.h" 21 for(i=0;i<ld->
nrays;i++) {
24 if( r <= min_reading || r > max_reading)
40 sm_debug(
"sm_icp: laser_sens has %d/%d; laser_ref has %d/%d rays valid\n",
49 sm_debug(
"sm_icp: laser_sens has %d/%d; laser_ref has %d/%d rays valid (after removing outside interval [%f, %f])\n",
75 gsl_vector * x_new = gsl_vector_alloc(3);
83 gsl_vector * minus_x_old = gsl_vector_alloc(3);
86 gsl_vector_free(minus_x_old);
92 if(!
icp_loop(params, x_old->data, x_new->data, &error, &nvalid, &iterations)) {
93 sm_error(
"icp: ICP failed for some reason. \n");
102 double best_error = error;
103 gsl_vector * best_x = gsl_vector_alloc(3);
104 gsl_vector_memcpy(best_x, x_new);
114 double perturb[6][3] = {
117 {0,0,dth}, {0,0,-dth}
120 int a;
for(a=0;a<6;a++){
121 sm_debug(
"-- Restarting with perturbation #%d\n", a);
123 gsl_vector * start = gsl_vector_alloc(3);
124 gvs(start, 0,
gvg(x_new,0)+perturb[a][0]);
125 gvs(start, 1,
gvg(x_new,1)+perturb[a][1]);
126 gvs(start, 2,
gvg(x_new,2)+perturb[a][2]);
127 gsl_vector * x_a = gsl_vector_alloc(3);
128 double my_error;
int my_valid;
int my_iterations;
129 if(!
icp_loop(&my_params, start->data, x_a->data, &my_error, &my_valid, &my_iterations)){
130 sm_error(
"Error during restart #%d/%d. \n", a, 6);
133 iterations+=my_iterations;
135 if(my_error < best_error) {
136 sm_debug(
"--Perturbation #%d resulted in error %f < %f\n", a,my_error,best_error);
137 gsl_vector_memcpy(best_x, x_a);
138 best_error = my_error;
140 gsl_vector_free(x_a); gsl_vector_free(start);
160 val cov0_x, dx_dy1, dx_dy2;
162 laser_ref, laser_sens, best_x,
163 &cov0_x, &dx_dy1, &dx_dy2);
183 res->
error = best_error;
187 gsl_vector_free(best_x);
189 gsl_vector_free(x_new);
190 gsl_vector_free(x_old);
248 gsl_vector * x_new = gsl_vector_alloc(3);
256 gsl_vector * minus_x_old = gsl_vector_alloc(3);
257 ominus(x_old,minus_x_old);
259 gsl_vector_free(minus_x_old);
265 if(!
icp_loop(params, x_old->data, x_new->data, &error, &nvalid, &iterations)) {
266 sm_error(
"icp: ICP failed for some reason. \n");
274 double best_error = error;
275 gsl_vector * best_x = gsl_vector_alloc(3);
276 gsl_vector_memcpy(best_x, x_new);
285 double perturb[6][3] = {
288 {0,0,dth}, {0,0,-dth}
291 int a;
for(a=0;a<6;a++){
292 sm_debug(
"-- Restarting with perturbation #%d\n", a);
294 gsl_vector * start = gsl_vector_alloc(3);
295 gvs(start, 0,
gvg(x_new,0)+perturb[a][0]);
296 gvs(start, 1,
gvg(x_new,1)+perturb[a][1]);
297 gvs(start, 2,
gvg(x_new,2)+perturb[a][2]);
298 gsl_vector * x_a = gsl_vector_alloc(3);
299 double my_error;
int my_valid;
int my_iterations;
300 if(!
icp_loop(&my_params, start->data, x_a->data, &my_error, &my_valid, &my_iterations)){
301 sm_error(
"Error during restart #%d/%d. \n", a, 6);
304 iterations+=my_iterations;
306 if(my_error < best_error) {
307 sm_debug(
"--Perturbation #%d resulted in error %f < %f\n", a,my_error,best_error);
308 gsl_vector_memcpy(best_x, x_a);
309 best_error = my_error;
311 gsl_vector_free(x_a); gsl_vector_free(start);
324 val cov0_x, dx_dy1, dx_dy2;
326 laser_ref, laser_sens, best_x,
327 &cov0_x, &dx_dy1, &dx_dy2);
347 res->
error = best_error;
351 gsl_vector_free(x_new);
352 gsl_vector_free(x_old);
353 gsl_vector_free(best_x);
gsl_vector * vector_from_array(unsigned int n, double *x)
gsl_matrix * egsl_v2gslm(val)
void ominus(const gsl_vector *x, gsl_vector *res)
int orientation_neighbourhood
void ld_create_jump_tables(struct laser_data *ld)
void ld_compute_orientation(LDP ld, int size_neighbourhood, double sigma)
INLINE int ld_valid_ray(LDP ld, int i)
double clustering_threshold
int ld_valid_fields(LDP ld)
void sm_journal_open(const char *file)
double restart_threshold_mean_error
double *restrict readings
void find_correspondences(struct sm_params *params)
int count_equal(const int *v, int n, int value)
void sm_icp(struct sm_params *params, struct sm_result *res)
void compute_covariance_exact(LDP laser_ref, LDP laser_sens, const gsl_vector *x, val *cov0_x, val *dx_dy1, val *dx_dy2)
void egsl_print_spectrum(const char *s, val v)
const char * gsl_friendly_pose(gsl_vector *v)
void sm_icp_xy(struct sm_params *params, struct sm_result *res)
void jj_add(const char *name, JO jo)
void egsl_push_named(const char *name)
void ld_simple_clustering(LDP ld, double threshold)
void ld_compute_world_coords(LDP ld, const double *pose)
void find_correspondences_tricks(struct sm_params *params)
void sm_debug(const char *msg,...)
int do_compute_covariance
int icp_loop(struct sm_params *params, const double *q0, double *x_new, double *total_error, int *nvalid, int *iterations)
void ld_compute_cartesian(LDP ld)
void ld_invalid_if_outside(LDP ld, double min_reading, double max_reading)
void sm_error(const char *msg,...)
void visibilityTest(LDP ld, const gsl_vector *x_old)
double rad2deg(double rad)
void egsl_pop_named(const char *name)
void egsl_print(const char *str, val v)
void vector_to_array(const gsl_vector *v, double *x)
void jj_context_enter(const char *context_name)