sm0.c
Go to the documentation of this file.
1 #include <time.h>
2 
3 #include "../csm/csm_all.h"
4 
5 
6 extern int distance_counter;
7 int main(int argc, const char*argv[]) {
8  FILE * file;
9  if(argc==1) {
10  file = stdin;
11  } else {
12  const char * filename = argv[1];
13  file = fopen(filename,"r");
14  if(file==NULL) {
15  fprintf(stderr, "Could not open '%s'.\n", filename);
16  return -1;
17  }
18  }
19 
20  struct sm_params params;
21  struct sm_result result;
22 
23  params.max_angular_correction_deg = 5;
24  params.max_linear_correction = 0.2;
25  params.max_iterations = 30;
26  params.epsilon_xy = 0.001;
27  params.epsilon_theta = 0.001;
28  params.max_correspondence_dist = 2;
29  params.sigma = 0.01;
30  params.restart = 1;
31  params.restart_threshold_mean_error = 3.0 / 300.0;
32  params.restart_dt= 0.1;
33  params.restart_dtheta= 1.5 * 3.14 /180;
34 
35  params.clustering_threshold = 0.05;
36  params.orientation_neighbourhood = 3;
37  params.use_corr_tricks = 1;
38 
39  params.do_alpha_test = 0;
40  params.outliers_maxPerc = 0.85;
41 
42  params.outliers_adaptive_order =0.7;
43  params.outliers_adaptive_mult=2;
44  params.do_visibility_test = 1;
45  params.do_compute_covariance = 0;
46 
47  int num_matchings = 0;
48  int num_iterations = 0;
49  clock_t start = clock();
50 
51  if(!(params.laser_ref = ld_read_smart(file)) ) {
52  printf("Could not read first scan.\n");
53  return -1;
54  }
55 
56  gsl_vector *u = gsl_vector_alloc(3);
57  gsl_vector *x_old = gsl_vector_alloc(3);
58  gsl_vector *x_new = gsl_vector_alloc(3);
59  while(! (params.laser_sens = ld_read_smart(file)) ) {
60  copy_from_array(x_old, params.laser_ref->odometry);
61  copy_from_array(x_new, params.laser_sens->odometry);
62  pose_diff(x_new,x_old,u);
63  vector_to_array(u, params.first_guess);
64 
65  sm_gpm(&params,&result);
66  /* sm_icp(&params,&result); */
67 
68  num_matchings++;
69  num_iterations += result.iterations;
70 
71  ld_free(params.laser_ref);
72  params.laser_ref = params.laser_sens;
73  }
74 
75  clock_t end = clock();
76  float seconds = (end-start)/((float)CLOCKS_PER_SEC);
77 
78  sm_debug("sm0: CPU time = %f (seconds) (start=%d end=%d)\n", seconds,(int)start,(int)end);
79  sm_debug("sm0: Total number of matchings = %d\n", num_matchings);
80  sm_debug("sm0: Total number of iterations = %d\n", num_iterations);
81  sm_debug("sm0: Avg. iterations per matching = %f\n", num_iterations/((float)num_matchings));
82  sm_debug("sm0: Avg. seconds per matching = %f\n", seconds/num_matchings);
83  sm_debug("sm0: that is, %d matchings per second\n", (int)floor(num_matchings/seconds));
84  sm_debug("sm0: Avg. seconds per iteration = %f (note: very imprecise)\n", seconds/num_iterations);
85  sm_debug("sm0: Number of comparisons = %d \n", distance_counter);
86  sm_debug("sm0: Avg. comparisons per ray = %f \n",
87  (distance_counter/((float)num_iterations*params.laser_ref->nrays)));
88 
89  ld_free(params.laser_ref);
90 
91  gsl_vector_free(u);
92  gsl_vector_free(x_old);
93  gsl_vector_free(x_new);
94  return 0;
95 }
int do_alpha_test
Definition: algos.h:79
double odometry[3]
Definition: laser_data.h:39
int iterations
Definition: algos.h:146
double epsilon_xy
Definition: algos.h:29
int max_iterations
Definition: algos.h:27
double max_angular_correction_deg
Definition: algos.h:22
void copy_from_array(gsl_vector *v, double *x)
int orientation_neighbourhood
Definition: algos.h:77
double clustering_threshold
Definition: algos.h:75
int main(int argc, const char *argv[])
Definition: sm0.c:7
double max_linear_correction
Definition: algos.h:24
LDP ld_read_smart(FILE *)
double outliers_adaptive_mult
Definition: algos.h:66
int use_corr_tricks
Definition: algos.h:36
double restart_dt
Definition: algos.h:43
double sigma
Definition: algos.h:124
void ld_free(LDP ld)
Definition: laser_data.c:87
double restart_threshold_mean_error
Definition: algos.h:41
double max_correspondence_dist
Definition: algos.h:34
double outliers_maxPerc
Definition: algos.h:53
void pose_diff(const gsl_vector *pose2, const gsl_vector *pose1, gsl_vector *res)
LDP laser_ref
Definition: algos.h:14
int do_visibility_test
Definition: algos.h:96
LDP laser_sens
Definition: algos.h:16
int restart
Definition: algos.h:39
double restart_dtheta
Definition: algos.h:45
double first_guess[3]
Definition: algos.h:19
void sm_debug(const char *msg,...)
Definition: logging.c:88
int distance_counter
Definition: math_utils.c:46
int do_compute_covariance
Definition: algos.h:114
double outliers_adaptive_order
Definition: algos.h:65
double epsilon_theta
Definition: algos.h:31
void sm_gpm(struct sm_params *input, struct sm_result *output)
Definition: gpm.c:11
void vector_to_array(const gsl_vector *v, double *x)


csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23