1 #include <gsl/gsl_vector.h> 4 #include "../csm_all.h" 9 const double a = -1.0/6.0;
10 const double b = +1.0/120.0;
12 return x * (.99 + x2 * ( a + b * x2));
16 #define DEBUG_SEARCH(a) ; 20 for(i=0;i<ld->
nrays;i++) {
45 double x = a[0] - b[0];
46 double y = a[1] - b[1];
53 #define SQUARE(a) ((a)*(a)) 67 for(i=0;i<laser_sens->
nrays;i++) {
73 const double *p_i_w = points_w[i].p;
74 double p_i_w_nrm2 = points_w[i].rho;
75 double p_i_w_phi = points_w[i].phi;
79 int to = laser_ref->
nrays-1;
81 int start_cell = (int) ((p_i_w_phi - laser_ref->
min_theta) * C1);
86 double best_dist = 42;
91 we_start_at = start_cell;
93 we_start_at = last_best + 1;
95 if(we_start_at > to) we_start_at = to;
96 if(we_start_at < from) we_start_at = from;
98 int up = we_start_at+1;
99 int down = we_start_at;
100 double last_dist_up = 0;
101 double last_dist_down = -1;
104 int down_stopped = 0;
106 DEBUG_SEARCH(printf(
"i=%d p_i_w = %f %f\n",i, p_i_w[0], p_i_w,[1]));
107 DEBUG_SEARCH(printf(
"i=%d [from %d down %d mid %d up %d to %d]\n",
108 i,from,down,start_cell,up,to));
110 while ( (!up_stopped) || (!down_stopped) ) {
111 int now_up = up_stopped ? 0 :
112 down_stopped ? 1 : last_dist_up < last_dist_down;
121 up_stopped = 1;
continue; }
123 if(!laser_ref->
valid[up]) {
130 if((last_dist_up < best_dist) || (j1==-1) )
131 j1 = up, best_dist = last_dist_up;
134 if (up > start_cell) {
135 double delta_theta = (laser_ref->
theta[up] - p_i_w_phi);
140 double min_dist_up = p_i_w_nrm2 *
141 ((delta_theta >
M_PI*0.5) ? 1 :
mysin(delta_theta));
144 if(
SQUARE(min_dist_up) > best_dist) {
145 up_stopped = 1;
continue;
151 (laser_ref->
readings[up] < p_i_w_nrm2)
168 down_stopped = 1;
continue; }
169 if(!laser_ref->
valid[down]) {
173 if( (last_dist_down < best_dist) || (j1==-1) )
174 j1 = down, best_dist = last_dist_down;
176 if (down < start_cell) {
177 double delta_theta = (p_i_w_phi - laser_ref->
theta[down]);
178 double min_dist_down = p_i_w_nrm2 *
179 ((delta_theta >
M_PI*0.5) ? 1 :
mysin(delta_theta));
180 if(
SQUARE(min_dist_down) > best_dist) {
181 down_stopped = 1;
continue;
183 down += (laser_ref->
readings[down] < p_i_w_nrm2) ?
190 DEBUG_SEARCH(printf(
"i=%d j1=%d dist=%f\n",i,j1,best_dist));
193 if( (-1==j1) || (best_dist > max_correspondence_dist2) ) {
198 if( 0==j1 || j1 == (laser_ref->
nrays-1)) {
209 if((j2up==-1)&&(j2down==-1)) {
213 if(j2up ==-1) { j2 = j2down; }
else 214 if(j2down==-1) { j2 = j2up; }
else {
217 j2 = dist_up < dist_down ? j2up : j2down;
223 laser_sens->
corr[i].
j1 = j1;
224 laser_sens->
corr[i].
j2 = j2;
INLINE int ld_next_valid_up(LDP ld, int i)
void ld_create_jump_tables(struct laser_data *ld)
INLINE int ld_valid_ray(LDP ld, int i)
enum correspondence::@5 type
int *restrict *restrict up_smaller
double *restrict readings
double max_correspondence_dist
point2d *restrict points_w
int *restrict *restrict *restrict *restrict down_smaller
INLINE double mysin(double x)
void find_correspondences_tricks(struct sm_params *params)
struct correspondence *restrict corr
INLINE void ld_set_null_correspondence(LDP ld, int i)
INLINE int ld_next_valid_down(LDP ld, int i)
INLINE double local_distance_squared_d(const double *a, const double *b)
int *restrict *restrict *restrict down_bigger
int use_point_to_line_distance