4 #include "../csm/csm_all.h" 26 "There are TWO ways to define the input to this program.\n" 28 "Say that in file A there are the scans \n" 32 "and in file B there are the scans \n" 36 "With this command line: \n" 38 " sm1 --file1 A --file2 B \n" 40 "the matchings will be: \n" 42 " (A1, B1), (A2, B2), etc.\n" 44 "While with this command line:\n" 46 " sm1 --file1 A --file2 A\n" 48 "the matchings will be \n" 50 " (A1, A2), (A3, A4), (A5, A6), ... \n" 54 int main(
int argc,
const char*argv[]) {
63 "File with first series of scans (at pose1)");
65 "File with second series of scans (at pose2)");
67 "File for journaling -- if left empty, journal not open.");
69 options_int(ops,
"algo", &
p.
algo, 0,
"Which algorithm to use (0:(pl)ICP 1:gpm-stripped 2:HSM) ");
76 fprintf(stderr,
"\n\nUsage:\n");
86 if(!file1 || !file2)
return -1;
104 if(feof(file1))
break;
110 if(feof(file2))
break;
120 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");
123 sm_error(
" I will quit it here. \n");
134 sm_icp(¶ms, &result);
break;
136 sm_gpm(¶ms, &result);
break;
138 sm_hsm(¶ms, &result);
break;
146 sprintf(casename,
"sm1_failure_matching%d", count);
147 sm_error(
"sm1: matching #%d failed. Writing a special case %s.\n", count, casename );
150 char file_config[256],file1[256],file2[256],
file_jj[256],script[256];
152 sprintf(file_config,
"%s.config", casename);
153 sprintf(file1,
"%s_laser_ref.json", casename);
154 sprintf(file2,
"%s_laser_sens.json", casename);
155 sprintf(file_jj,
"%s.journal", casename);
156 sprintf(script,
"%s.sh", casename);
158 FILE * f = fopen(file_config,
"w");
162 f = fopen(file1,
"w");
166 f = fopen(file2,
"w");
170 f = fopen(script,
"w");
171 fprintf(f,
"#!/bin/bash\n");
172 fprintf(f,
"%s -config %s -file1 %s -file2 %s -debug 1 -file_jj %s -write_post_mortem 0 \n",
173 argv[0], file_config, file1, file2, file_jj);
174 fprintf(f,
"sm_animate -in %s -out %s_anim.pdf \n", file_jj, casename);
201 if(file2 != file1) fclose(file2);
void options_banner(const char *message)
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 sm_hsm(struct sm_params *input, struct sm_result *output)
const char * friendly_pose(const double *pose)
void sm_options(struct sm_params *p, struct option *ops)
FILE * open_file_for_writing(const char *filename)
void options_dump(struct option *options, FILE *f, int write_desc)
JO result_to_json(struct sm_params *p, struct sm_result *r)
struct option * options_allocate(int n)
LDP ld_from_json_stream(FILE *file)
const char * json_object_to_json_string(struct json_object *this)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
void sm_debug_write(int flag)
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)
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)
int main(int argc, const char *argv[])
void jj_set_stream(FILE *f)
int options_parse_args(struct option *ops, int argc, const char *argv[])