17 int main(
int argc,
const char** argv)
31 sm_info(
" simulats one scan from map. \n\nUsage:\n");
38 if(!file_map)
return -2;
56 if(!file_output)
return -1;
60 if(!file_poses)
return -2;
62 JO jo_pose;
int num = 0;
80 for(
int i=0;i<ld->
nrays;i++) {
81 ld->
theta[i] = - fov/2 + fov * i / (ld->
nrays-1);;
83 double rho, alpha;
int stuff_id;
89 double relative_alpha = alpha-ld->
true_pose[2];
93 relative_alpha +=
M_PI;
109 fputs(
"\n", file_output);
125 #define jo_expect_array(a) (a!=0 && json_object_is_type(a, json_type_array)) 126 #define jo_expect_object(a) (a!=0 && json_object_is_type(a, json_type_object)) 127 #define jo_expect_string(a) (a!=0 && json_object_is_type(a, json_type_string)) 128 #define jo_expect_array_size(a,n) ( (a!=0) && (json_object_is_type(a, json_type_array)&& (jo_array_length(a)==n))) 129 #define jo_expect_array_size_min(a,n) ( (a!=0) && (json_object_is_type(a, json_type_array)&& (jo_array_length(a)>=n))) 132 #define expect(a) if(!a) { \ 133 sm_error("Invalid format: \n\t %s \n", #a); \ 137 #define expect_s(a, s) if(!a) { \ 138 sm_error("Invalid format: %s \n\t %s \n", s, #a); \ 143 return cos(a1)*cos(a2)+sin(a1)*sin(a2);
170 env.
stuff.push_back(s);
178 double pmin[2],pmax[2];
183 env.
stuff.push_back(
new Segment(pmin[0],pmin[1],pmax[0],pmin[1]));
184 env.
stuff.push_back(
new Segment(pmax[0],pmax[1],pmax[0],pmin[1]));
185 env.
stuff.push_back(
new Segment(pmax[0],pmax[1],pmin[0],pmax[1]));
186 env.
stuff.push_back(
new Segment(pmin[0],pmin[1],pmin[0],pmax[1]));
bool ray_tracing(const double p[2], const double direction, double &out_distance, double &out_alpha, int *stuff_id) const
std::vector< Stuff * > stuff
void sm_set_program_name(const char *name)
struct json_object * json_object_object_get(struct json_object *this, const char *key)
double normalize_0_2PI(double t)
int main(int argc, const char **argv)
void options_double(struct option *, const char *name, double *p, double def_value, const char *desc)
double cosine_between_angles(double a1, double a2)
FILE * open_file_for_writing(const char *filename)
double *restrict true_alpha
double *restrict readings
bool load_env_from_json(Environment &env, JO jo)
struct option * options_allocate(int n)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
#define jo_expect_array(a)
FILE * open_file_for_reading(const char *filename)
#define jo_expect_string(a)
void options_print_help(struct option *options, FILE *f)
#define jo_expect_object(a)
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)
JO json_read_stream(FILE *f)
LDP ld_alloc_new(int nrays)
int jo_read_from_double_array(JO jo, double *p, int n, double when_null)
void sm_error(const char *msg,...)
#define jo_expect_array_size(a, n)
int options_parse_args(struct option *ops, int argc, const char *argv[])
#define jo_expect_array_size_min(a, n)