5 #include <linux/limits.h> 10 #include <cairo-pdf.h> 14 #include "../csm/csm_all.h" 18 const char*
reference_name[4] = {
"invalid",
"odometry",
"estimate",
"true_pose"};
44 void ld_getbb(
LDP ld,
double*x0,
double*y0,
double*x1,
double*y1,
47 int main(
int argc,
const char*argv[]) {
49 fprintf(stderr,
"carmen2pdf:\t *** Please use log2pdf instead. ***\n\n");
65 options_string(ops,
"use", &p.
use,
"estimate",
"One in 'odometry','estimate','true_pose'");
68 sm_error(
"Could not parse arguments.\n");
82 int i;
for(i=1;i<=3;i++)
87 "Use one in 'odometry','estimate','true_pose'.\n", p.
use);
116 *bx = (wx-bb->
x0) * scale;
117 *by = bb->
height- (wy-bb->
y0) * scale;
135 sm_error(
"Invalid laser data (#%d in file)\n", counter);
142 bb->
x0 = GSL_MIN(x0, bb->
x0);
143 bb->
x1 = GSL_MAX(x1, bb->
x1);
144 bb->
y0 = GSL_MIN(y0, bb->
y0);
145 bb->
y1 = GSL_MAX(y1, bb->
y1);
158 sm_info(
"Considering %d of %d scans.\n", considered, counter+1);
170 switch(use_reference) {
177 sm_error(
"Required field '%s' not set in laser scan.\n",
179 sm_error(
"I will abruptly exit() because of a panic attack.\n");
193 double wwidth = bb.
x1-bb.
x0;
194 double wheight= bb.
y1-bb.
y0;
195 if(wwidth > wheight) {
205 cairo_surface_t *surface;
207 cairo_status_t status;
210 cr = cairo_create (surface);
211 status = cairo_status (cr);
214 sm_error(
"Failed to create pdf surface for file %s: %s\n",
220 int first_pose=1;
double old_pose_bx=0,old_pose_by=0;
233 cairo_set_line_width(cr, 0.5);
234 cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
235 cairo_move_to(cr, old_pose_bx, old_pose_by);
236 cairo_line_to(cr, bx, by);
237 cairo_close_path(cr);
253 int begin_new_stroke;
256 } draw_info[ld->
nrays];
259 int last_valid = -1;
int first = 1;
260 int i;
for(i=0;i<ld->
nrays;i++) {
263 draw_info[i].valid = 0;
266 draw_info[i].valid = 1;
269 pose, &(draw_info[i].w[0]), &(draw_info[i].w[1]),
270 &bb, &(draw_info[i].b[0]), &(draw_info[i].b[1]));
274 draw_info[i].begin_new_stroke = 1;
275 draw_info[i].end_stroke = 0;
279 draw_info[i].begin_new_stroke = near ? 0 : 1;
280 draw_info[i].end_stroke = 0;
281 draw_info[last_valid].end_stroke = draw_info[i].begin_new_stroke;
286 draw_info[last_valid].end_stroke = 1;
294 double big_interval = 0.3;
295 for(i=0;i<ld->
nrays;i++) {
if(draw_info[i].valid==0)
continue;
299 }
else interval[i] = big_interval;
302 cairo_set_source_rgb(cr, 1.0, 0.5, 0.5);
303 cairo_set_line_width(cr, 0.1);
305 int j=0;
for(j=0;j<2;j++)
306 for(i=0;i<ld->
nrays;i++) {
if(draw_info[i].valid==0)
continue;
309 ld->
readings[i] + (j ? interval[i] : -interval[i]),
310 pose, 0, 0, &bb, &(b[0]), &(b[1]));
312 if(draw_info[i].begin_new_stroke)
313 cairo_move_to(cr, b[0], b[1]);
315 cairo_line_to(cr, b[0], b[1]);
316 if(draw_info[i].end_stroke)
324 cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
325 cairo_set_line_width(cr, 0.5);
326 for(i=0;i<ld->
nrays;i++) {
327 if(draw_info[i].valid==0)
continue;
328 double *b = draw_info[i].b;
329 if(draw_info[i].begin_new_stroke)
330 cairo_move_to(cr, b[0], b[1]);
332 cairo_line_to(cr, b[0], b[1]);
333 if(draw_info[i].end_stroke)
344 cairo_show_page (cr);
347 cairo_surface_destroy (surface);
355 point[0] = cos(phi) * rho;
356 point[1] = sin(phi) * rho;
364 if( (bb!=0) & (bx!=0) & (by!=0) )
365 bb_w2b(bb, pw[0], pw[1], bx, by);
367 if((x!=0) && (y!=0)) {
368 *x = pw[0]; *y = pw[1];
378 int i;
for(i=0;i<ld->
nrays;i++) {
379 if(!ld->
valid[i])
continue;
380 if(ld->
readings[i]>horizon)
continue;
389 *x0 = GSL_MIN(*x0, x);
390 *y0 = GSL_MIN(*y0, y);
391 *x1 = GSL_MAX(*x1, x);
392 *y1 = GSL_MAX(*y1, y);
int should_consider(struct params *p, int counter)
int main(int argc, const char *argv[])
double distance_squared_d(const double a[2], const double b[2])
void sm_set_program_name(const char *name)
void transform_d(const double point2d[2], const double pose[3], double result2d[2])
double *restrict readings_sigma
void get_bb(struct params *p, struct bounding_box *bb)
void ld_get_buffer_polar(double phi, double rho, const double *pose, double *x, double *y, struct bounding_box *bb, double *bx, double *by)
void ld_getbb(LDP ld, double *x0, double *y0, double *x1, double *y1, reference use_reference, double horizon)
void options_double(struct option *, const char *name, double *p, double def_value, const char *desc)
int ld_valid_fields(LDP ld)
void ld_get_world(LDP ld, int i, double *x, double *y, reference use_reference)
double * ld_get_reference(LDP ld, reference use_reference)
void carmen2pdf(struct params p)
LDP ld_read_smart(FILE *)
double *restrict readings
void bb_w2b(struct bounding_box *bb, double wx, double wy, double *bx, double *by)
struct option * options_allocate(int n)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
const char * input_filename
const char * output_filename
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 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 sm_error(const char *msg,...)
const char * reference_name[4]
int options_parse_args(struct option *ops, int argc, const char *argv[])