11 #include "../csm/csm_all.h" 12 #include "../csm/laser_data_drawing.h" 13 #include "../csm/laser_data_cairo.h" 44 int main(
int argc,
const char** argv)
55 options_int(ops,
"write_info", &p.
write_info, 0,
"Writes informations and statistics in the picture.");
57 options_int(ops,
"zoom_ray", &p.
zoom_ray, -1,
"If >= 0, the action is zoomed on a particular ray.");
67 sm_info(
"Draws ICP animation. It reads the output created by sm2 when given the 'file_jj' switch. \n\nUsage:\n");
91 JO jo_sens =
jo_get(jo,
"laser_sens");
92 if(!jo_ref || !jo_sens) {
93 sm_error(
"Could not get laser_ref/laser_sens.\n");
99 if(!laser_ref || !laser_sens) {
100 sm_error(
"Could not read laser_ref/laser_sens from JSON representation.\n");
107 double ld_min[2], ld_max[2];
109 double zero[3] = {0,0,0};
111 sm_error(
"Not enough good points to establish bounding box.\n");
129 sm_info(
"Bounding box: %f %f -- %f %f\n", ld_min[0], ld_min[1], ld_max[0], ld_max[1]);
131 cairo_surface_t *surface;
135 ld_min, ld_max, &surface, &cr))
return 0;
137 JO iterations =
jo_get(jo,
"iterations");
139 fprintf(stderr,
"Could not read iterations.\n");
145 sm_info(
"Displaying %d iterations.\n", niterations);
148 for(it=0;it<niterations;it++) {
151 double x_old[3], x_new[3];
162 JO corr0 =
jo_get(iteration,
"corr0");
163 JO corr1 =
jo_get(iteration,
"corr1");
164 JO corr2 =
jo_get(iteration,
"corr2");
165 if(!corr1 || !corr2 || !corr0) {
166 sm_error(
"Iteration %d: could not read correspondences (field 'corr<i>'). Probably ICP failed here?\n", it);
169 cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
173 cairo_set_source_rgb (cr, 1.0, 0.0, 1.0);
177 cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
189 cairo_identity_matrix(cr);
190 cairo_set_font_size (cr, 20.0f);
191 cairo_select_font_face (cr,
"Sans",
192 CAIRO_FONT_SLANT_NORMAL,
193 CAIRO_FONT_WEIGHT_NORMAL);
196 sprintf(text,
"Iteration #%d: x_old: %s", it,
friendly_pose(x_old));
197 cairo_move_to(cr, 0.0, -20.0 );
198 cairo_show_text(cr, text);
204 cairo_show_page (cr);
211 cairo_surface_destroy (surface);
void cr_ld_draw_corr(cairo_t *cr, LDP laser_ref, LDP laser_sens)
int json_object_array_length(struct json_object *this)
void sm_set_program_name(const char *name)
void ls_add_options(line_style *ls, struct option *ops, const char *prefix, const char *desc_prefix)
void lds_add_options(ld_style *lds, struct option *ops, const char *prefix, const char *desc_prefix)
int json_object_is_type(struct json_object *this, int type)
int create_pdf_surface(const char *file, int max_width_points, int max_height_points, double bb_min[2], double bb_max[2], cairo_surface_t **surface_p, cairo_t **cr)
const char * friendly_pose(const double *pose)
INLINE int ld_valid_ray(LDP ld, int i)
void options_double(struct option *, const char *name, double *p, double def_value, const char *desc)
void cr_set_reference(cairo_t *cr, double *pose)
void set_defaults(anim_params *p)
void cr_ld_draw(cairo_t *cr, LDP ld, ld_style *p)
struct option * options_allocate(int n)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
int jo_read_double_array(JO s, const char *name, double *p, int n, double when_null)
FILE * open_file_for_reading(const char *filename)
struct correspondence *restrict corr
void ld_compute_world_coords(LDP ld, const double *pose)
void options_print_help(struct option *options, FILE *f)
void ls_set_defaults(line_style *ls)
void sm_info(const char *msg,...)
int main(int argc, const char **argv)
void options_string(struct option *, const char *name, const char **p, const char *def_balue, const char *desc)
int json_to_corr(JO array, struct correspondence *corr, int n)
JO json_read_stream(FILE *f)
void ld_compute_cartesian(LDP ld)
void cr_set_style(cairo_t *cr, line_style *ls)
struct json_object * json_object_array_get_idx(struct json_object *this, int idx)
void sm_error(const char *msg,...)
int draw_animation(anim_params *p, JO jo, const char *filename)
void lds_set_defaults(ld_style *lds)
int options_parse_args(struct option *ops, int argc, const char *argv[])
int ld_get_bounding_box(LDP ld, double bb_min[2], double bb_max[2], double pose[3], double horizon)