19 double *v = (
double*) malloc(
sizeof(
double)*n);
20 int i=0;
for(i=0;i<n;i++) {
27 int *v = (
int*) malloc(
sizeof(
int)*n);
28 int i=0;
for(i=0;i<n;i++) {
61 for(i=0;i<ld->
nrays;i++) {
76 for(i=0;i<nrays;i++) {
120 for(i=0;i<ld->
nrays;i++) {
134 double pose_x = pose[0];
135 double pose_y = pose[1];
136 double pose_theta = pose[2];
137 double cos_theta = cos(pose_theta);
138 double sin_theta = sin(pose_theta);
139 const int nrays = ld->
nrays ;
143 int i;
for(i=0;i<nrays;i++) {
145 double x0 = points[i].
p[0],
149 sm_error(
"ld_compute_world_coords(): I expected that cartesian coords were already computed: ray #%d: %f %f.\n", i, x0, y0);
152 points_w[i].
p[0] = cos_theta * x0 -sin_theta*y0 + pose_x;
153 points_w[i].
p[1] = sin_theta * x0 +cos_theta*y0 + pose_y;
157 for(i=0;i<nrays;i++) {
158 double x = points_w[i].
p[0];
159 double y = points_w[i].
p[1];
160 points_w[i].
rho = sqrt( x*x+y*y);
161 points_w[i].
phi = atan2(y, x);
171 for(i=0;i<ld->
nrays;i++) {
181 sm_error(
"NULL pointer given as laser_data*.\n");
186 int max_nrays = 10000;
187 if(ld->
nrays < min_nrays || ld->
nrays > max_nrays) {
192 sm_error(
"Invalid min / max theta: min_theta = %f max_theta = %f\n",
196 double min_fov =
deg2rad(20.0);
197 double max_fov = 2.01 *
M_PI;
199 if( fov < min_fov || fov > max_fov) {
204 sm_error(
"Min_theta (%f) should be theta[0] (%f)\n",
209 sm_error(
"Min_theta (%f) should be theta[0] (%f)\n",
214 double min_reading = 0;
215 double max_reading = 100;
216 int i;
for(i=0;i<ld->
nrays;i++) {
217 double th = ld->
theta[i];
221 sm_error(
"Ray #%d: r = %f theta = %f but valid is %d\n",
222 i, r, th, ld->
valid[i]);
225 if( !( min_reading < r && r < max_reading ) ) {
226 sm_error(
"Ray #%d: %f is not in interval (%f, %f) \n",
227 i, r, min_reading, max_reading);
233 sm_error(
"Ray #%d: valid = %d but theta = %f\n",
234 i, ld->
valid[i], th);
257 if (num_valid < ld->nrays * 0.10) {
258 sm_error(
"Valid: %d/%d invalid: %d.\n", num_valid, ld->
nrays, num_invalid);
268 unsigned int hash = 0;
271 for(i = 0; i < (unsigned)ld->
nrays; i++) {
273 hash ^= ((i & 1) == 0) ? ( (hash << 7) ^ (str) ^ (hash >> 3)) :
274 (~((hash << 11) ^ (str) ^ (hash >> 5)));
277 return (hash & 0x7FFFFFFF);
void ld_dealloc(struct laser_data *ld)
double *restrict cov_alpha
int * alloc_int_array(int n, int def)
double *restrict readings_sigma
INLINE int ld_valid_corr(LDP ld, int i)
INLINE int ld_valid_ray(LDP ld, int i)
int ld_valid_fields(LDP ld)
double *restrict true_alpha
int *restrict *restrict up_smaller
double *restrict readings
int count_equal(const int *v, int n, int value)
void ld_alloc(LDP ld, int nrays)
int *restrict alpha_valid
point2d *restrict points_w
int *restrict *restrict *restrict *restrict down_smaller
struct correspondence *restrict corr
unsigned int ld_corr_hash(LDP ld)
void ld_compute_world_coords(LDP ld, const double *pose)
void ld_compute_cartesian(LDP ld)
int *restrict *restrict *restrict down_bigger
double * alloc_double_array(int n, double def)
LDP ld_alloc_new(int nrays)
int ld_num_valid_correspondences(LDP ld)
void sm_error(const char *msg,...)
double rad2deg(double rad)