6 #include "../csm/csm_all.h" 25 void spit(
LDP ld, FILE * stream);
27 int main(
int argc,
const char*argv[]) {
36 options_string(ops,
"out_stats", &
p.file_out_stats,
"",
"Output file (stats) ");
38 "File for journaling -- if left empty, journal not open.");
39 options_int(ops,
"algo", &
p.algo, 0,
"Which algorithm to use (0:(pl)ICP 1:gpm-stripped 2:HSM) ");
41 options_int(ops,
"debug", &
p.debug, 0,
"Shows debug information");
42 options_int(ops,
"recover_from_error", &
p.recover_from_error, 0,
"If true, tries to recover from an ICP matching error");
51 fprintf(stderr,
"\n\nUsage:\n");
61 if(!file_in)
return -1;
63 if(!file_out)
return -1;
65 if(strcmp(
p.file_jj,
"")) {
72 if(strcmp(
p.file_out_stats,
"")) {
74 if(!file_out_stats)
return -1;
80 sm_error(
"Could not read first scan.\n");
84 sm_error(
"Invalid laser data in first scan.\n");
92 spit(laser_ref, file_out);
99 sm_error(
"Invalid laser data in (#%d in file).\n", count);
110 sm_error(
"The 'odometry' field is set to NaN so I don't know how to get an initial guess. I usually use the difference in the odometry fields to obtain the initial guess.\n");
113 sm_error(
" I will quit it here. \n");
119 double ominus_laser[3], temp[3];
121 oplus_d(ominus_laser, odometry, temp);
127 sm_icp(¶ms, &result);
break;
129 sm_gpm(¶ms, &result);
break;
131 sm_hsm(¶ms, &result);
break;
133 sm_error(
"Unknown algorithm to run: %d.\n",
p.algo);
138 if(
p.recover_from_error) {
139 sm_info(
"One ICP matching failed. Because you passed -recover_from_error, I will try to recover." 140 " Note, however, that this might not be good in some cases. \n");
141 sm_info(
"The recover is that the displacement is set to 0. No result stats is output. \n");
146 ld_free(laser_ref); laser_ref = laser_sens;
149 sm_error(
"One ICP matching failed. Because I process recursively, I will stop here.\n");
150 sm_error(
"Use the option -recover_from_error if you want to try to recover.\n");
160 spit(laser_sens, file_out);
166 fputs(
"\n", file_out_stats);
170 ld_free(laser_ref); laser_ref = laser_sens;
void sm_set_program_name(const char *name)
void sm_icp(struct sm_params *input, struct sm_result *output)
void ld_write_as_json(LDP ld, FILE *stream)
void copy_d(const double *from, int n, double *to)
void sm_hsm(struct sm_params *input, struct sm_result *output)
const char * friendly_pose(const double *pose)
int ld_valid_fields(LDP ld)
void sm_options(struct sm_params *p, struct option *ops)
FILE * open_file_for_writing(const char *filename)
LDP ld_read_smart(FILE *)
JO result_to_json(struct sm_params *p, struct sm_result *r)
struct option * options_allocate(int n)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
int main(int argc, const char *argv[])
void sm_debug_write(int flag)
void spit(LDP ld, FILE *stream)
FILE * open_file_for_reading(const char *filename)
void oplus_d(const double x1[3], const double x2[3], double res[3])
void options_print_help(struct option *options, FILE *f)
void ominus_d(const double x[3], double res[3])
const char * file_out_stats
void sm_info(const char *msg,...)
int any_nan(const double *d, int n)
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])
void sm_error(const char *msg,...)
void sm_gpm(struct sm_params *input, struct sm_result *output)
void jj_set_stream(FILE *f)
int options_parse_args(struct option *ops, int argc, const char *argv[])