Go to the documentation of this file.
6 #include <linux/limits.h>
10 #include <cairo-pdf.h>
14 #include "../csm/csm_all.h"
15 #include "../csm/laser_data_drawing.h"
16 #include "../csm/laser_data_cairo.h"
48 "This program draws laser scans.\n"
50 "IMPORTANT: it is likely you have to set one or more parameters. \n"
51 " the default parameters are OK to draw very long laser logs\n\n";
53 int main(
int argc,
const char* argv[]) {
61 p.laser.rays.draw = 0;
62 p.laser.points.draw = 0;
63 p.laser.normals.draw = 0;
64 p.laser.countour.width = 0.1;
65 p.pose_path.width = 0.1;
66 p.pose_path.color =
"#f00";
71 options_string(
ops,
"out", &
p.output_filename,
"",
"output file (if empty, input file + '.pdf')");
73 options_double(
ops,
"dimension", &
p.dimension, 500.0,
"dimension of the image (points)");
74 options_double(
ops,
"offset_theta_deg", &
p.offset_theta_deg, 0.0,
" rotate entire map by this angle (deg) ");
76 options_string(
ops,
"use", &
p.use,
"estimate",
"One in 'odometry','estimate','true_pose'");
77 options_double(
ops,
"distance_xy", &
p.distance_xy, 5.0,
" Minimum distance between scans (m) ");
78 options_double(
ops,
"distance_th_deg", &
p.distance_th_deg, 45.0,
" Minimum distance between scans (deg) ");
79 options_double(
ops,
"start_pose_width", &
p.start_pose_width, 0.4,
"First pose | Circle width");
84 sm_error(
"Could not parse arguments.\n");
90 if(strlen(
p.output_filename)==0) {
92 sprintf(
buf,
"%s.pdf",
p.input_filename);
100 "Use one in 'odometry','estimate','true_pose'.\n",
p.use);
113 if(!input_file)
return 0;
115 LDP*scans;
int nscans;
118 p->use_reference,
p->distance_xy,
deg2rad(
p->distance_th_deg) ) ){
119 sm_error(
"Could not read map from file '%s'.\n",
p->input_filename);
124 sm_error(
"I could not read any scan from file '%s'.\n",
p->input_filename);
128 sm_debug(
"Read map: %d scans in total.\n", nscans);
131 double bb_min[2], bb_max[2];
132 double offset[3] = {0,0,0};
135 bb_min[0] -=
p->padding;
136 bb_min[1] -=
p->padding;
137 bb_max[0] +=
p->padding;
138 bb_max[1] +=
p->padding;
141 sm_debug(
"Bounding box: %f %f -- %f %f.\n", bb_min[0], bb_min[1],
142 bb_max[0], bb_max[1]);
146 int max_width_points =
p->dimension;
147 int max_height_points =
p->dimension;
148 cairo_surface_t *surface;
152 bb_min, bb_max, &surface, &cr))
return 0;
155 if(
p->pose_path.draw) {
161 if(nscans > 0 &&
p->laser.pose.draw) {
162 cairo_set_source_rgb(cr, 0.3, 0.0, 1.0);
164 cairo_arc(cr, pose0[0], pose0[1],
p->start_pose_width, 0.0, 2*
M_PI);
172 int k;
for(k=0;k<nscans;k++) {
177 double offset[3] = {0,0,
deg2rad(
p->offset_theta_deg) };
178 double world_pose[3];
179 oplus_d(offset, pose, world_pose);
187 cairo_show_page (cr);
190 cairo_surface_destroy (surface);
void sm_debug(const char *msg,...)
void cr_lda_draw_pose_path(cairo_t *cr, LDP *scans, int nscans, ld_reference use_reference)
void lda_get_bounding_box(LDP *lda, int nld, double bb_min[2], double bb_max[2], double offset[3], ld_reference use_reference, double horizon)
double * ld_get_reference_pose(LDP ld, ld_reference use_reference)
int ld_read_some_scans_distance(FILE *file, LDP **array, int *num, ld_reference which, double d_xy, double d_th)
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)
void ls_add_options(line_style *ls, struct option *ops, const char *prefix, const char *desc_prefix)
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 sm_set_program_name(const char *name)
const char * output_filename
void cr_ld_draw(cairo_t *cr, LDP ld, ld_style *p)
struct option * options_allocate(int n)
FILE * open_file_for_reading(const char *filename)
const char * input_filename
ld_reference ld_string_to_reference(const char *s)
void options_print_help(struct option *options, FILE *f)
void ls_set_defaults(line_style *ls)
void sm_error(const char *msg,...)
void oplus_d(const double x1[3], const double x2[3], double res[3])
void lds_add_options(ld_style *lds, struct option *ops, const char *prefix, const char *desc_prefix)
char * my_strdup(const char *s)
void cr_set_style(cairo_t *cr, line_style *ls)
int log2pdf(log2pdf_params *p)
void options_string(struct option *, const char *name, const char **p, const char *def_balue, const char *desc)
int options_parse_args(struct option *ops, int argc, const char *argv[])
void lds_set_defaults(ld_style *lds)
int main(int argc, const char *argv[])
void options_banner(const char *message)
ld_reference use_reference
csm
Author(s): Andrea Censi
autogenerated on Wed Aug 17 2022 02:50:33