5 int main(
int argc,
const char * argv[]) {
8 const char*input_filename;
9 const char*output_filename;
14 options_string(ops,
"in", &input_filename,
"stdin",
"input file (log)");
15 options_string(ops,
"out", &output_filename,
"stdout",
"output file ");
16 options_double(ops,
"max_xy", &max_xy, 100.0,
"Max admissible xy displacement");
18 "Max admissible theta displacement (deg)");
21 sm_info(
"computes odometry statistics.\n\nOptions:\n");
29 if(!input_stream || !output_stream)
return -1;
33 sm_error(
"Cannot read first scan.\n.");
37 int count = 0, valid = 0;
40 double avg_correction[3] = {0,0,0};
41 double max_correction[3] = {0,0,0};
43 double diff_true_pose[3], diff_odometry[3], diff_estimate[3];
57 fputs(
"\n", output_stream);
60 laser_ref = laser_sens;
62 int use_it = (fabs(diff[0]) < max_xy) && (fabs(diff[1]) < max_xy) &&
63 (fabs(diff[2]) <
deg2rad(max_theta_deg));
66 int i;
for(i=0;i<3;i++) {
67 avg_correction[i] += diff[i];
68 max_correction[i] = GSL_MAX(max_correction[i], fabs(diff[i]));
76 int i;
for(i=0;i<3;i++)
77 avg_correction[i] /= valid;
79 fprintf(stderr,
"Used %d/%d rays (%.1f %%)\n", valid, count, (100.0 *valid)/count);
81 fprintf(stderr,
"Avg: %f %f %f = %fdeg \n",
82 avg_correction[0], avg_correction[1], avg_correction[2],
rad2deg(avg_correction[2]));
83 fprintf(stderr,
"Max: %f %f %f = %fdeg \n",
84 max_correction[0], max_correction[1], max_correction[2],
rad2deg(max_correction[2]));
void sm_set_program_name(const char *name)
void options_double(struct option *, const char *name, double *p, double def_value, const char *desc)
FILE * open_file_for_writing(const char *filename)
LDP ld_read_smart(FILE *)
struct option * options_allocate(int n)
void jo_add_double_array(JO root, const char *name, const double *v, int n)
FILE * open_file_for_reading(const char *filename)
void options_print_help(struct option *options, FILE *f)
void sm_info(const char *msg,...)
void options_string(struct option *, const char *name, const char **p, const char *def_balue, const char *desc)
void pose_diff_d(const double pose2[3], const double pose1[3], double res[3])
int main(int argc, const char *argv[])
void sm_error(const char *msg,...)
int options_parse_args(struct option *ops, int argc, const char *argv[])
double rad2deg(double rad)