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);
void options_banner(const char *message)
void sm_set_program_name(const char *name)
void ld_write_as_json(LDP ld, FILE *stream)
double *restrict readings_sigma
void options_double(struct option *, const char *name, double *p, double def_value, const char *desc)
int ld_valid_fields(LDP ld)
FILE * open_file_for_writing(const char *filename)
double *restrict true_alpha
int main(int argc, const char *argv[])
double *restrict readings
struct option * options_allocate(int n)
LDP ld_from_json_stream(FILE *file)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
int *restrict alpha_valid
FILE * open_file_for_reading(const char *filename)
void options_print_help(struct option *options, FILE *f)
void options_string(struct option *, const char *name, const char **p, const char *def_balue, const char *desc)
void sm_error(const char *msg,...)
int options_parse_args(struct option *ops, int argc, const char *argv[])