Go to the documentation of this file. 1 #include <gsl/gsl_rng.h>
2 #include <gsl/gsl_randist.h>
8 #include "../csm/csm_all.h"
19 int main(
int argc,
const char * argv[]) {
28 "Size of discretization (disabled if 0)");
30 "Std deviation of gaussian noise (disabled if 0)");
32 "Use lambertian model cov = sigma^2 / cos(beta^2) where beta is the incidence. Need have alpha or true_alpha.");
34 "Seed for random number generator (if 0, use GSL_RNG_SEED env. variable).");
40 fprintf(stderr,
"A simple program for adding noise to sensor scans.\n\nUsage:\n");
53 gsl_rng *
rng = gsl_rng_alloc (gsl_rng_ranlxs0);
55 gsl_rng_set(
rng, (
unsigned int)
p.seed);
57 LDP ld;
int count = 0;
60 sm_error(
"Invalid laser data (#%d in file)\n", count);
65 for(i=0;i<ld->
nrays;i++) {
66 if(!ld->
valid[i])
continue;
70 double add_sigma =
p.sigma;
80 alpha = ld->
alpha[i];;
82 }
else have_alpha = 0;
86 double beta = (alpha+
M_PI) - ld->
theta[i];
87 add_sigma =
p.sigma / cos(beta);
89 sm_error(
"Because lambertian is active, I need either true_alpha[] or alpha[]");
96 *reading += gsl_ran_gaussian(
rng, add_sigma);
104 if(
p.discretization > 0)
105 *reading -= fmod(*reading ,
p.discretization);
double *restrict readings_sigma
int ld_valid_fields(LDP ld)
double *restrict true_alpha
double *restrict readings
FILE * open_file_for_writing(const char *filename)
LDP ld_from_json_stream(FILE *file)
int *restrict alpha_valid
void options_double(struct option *, const char *name, double *p, double def_value, const char *desc)
void sm_set_program_name(const char *name)
struct option * options_allocate(int n)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
FILE * open_file_for_reading(const char *filename)
int main(int argc, const char *argv[])
void options_print_help(struct option *options, FILE *f)
void sm_error(const char *msg,...)
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 ld_write_as_json(LDP ld, FILE *stream)
void options_banner(const char *message)
csm
Author(s): Andrea Censi
autogenerated on Wed Aug 17 2022 02:50:33