26 #define M_PI 3.14159265358979323846
30 #define BIG_INITIAL_ERROR 1000000.0F
123 float L,
int laserStep,
126 int ProjectionFilter,
128 int MaxIter,
float error_ratio,
129 float error_x,
float error_y,
float error_t,
int IterSmoothConv){
132 printf(
"-- Init EM params . . ");
138 params.error_th=error_ratio;
141 params.laserStep=laserStep;
142 params.MaxDistInter=MaxDistInter;
144 params.ProjectionFilter=ProjectionFilter;
145 params.AsocError=AsocError;
149 params.IterSmoothConv=IterSmoothConv;
163 Tsc *sensorMotion,
Tsc *solution){
172 while (numIteration<
params.MaxIter){
181 resMStep=
MStep(solution);
185 else if (resMStep==-1)
212 static Tscan ptosNewRef;
217 float cp_ass_ptX,cp_ass_ptY,cp_ass_ptD;
220 float q1x, q1y, q2x,q2y,p2x,p2y, dqx, dqy, dqpx, dqpy, qx, qy,dx,dy;
245 if (
params.ProjectionFilter==1){
314 dx=p2x-qx; dy=p2y-qy;
315 dist=dx*dx+dy*dy-(dx*qy-dy*qx)*(dx*qy-dy*qx)/(qx*qx+qy*qy+LMET2);
335 for (J=L+1;J<=R;J++){
343 dqpx=q1x-p2x; dqpy=q1y-p2y;
344 A=1/(p2x*p2x+p2y*p2y+LMET2);
353 else if (landaMin>1){
356 qx=(1-landaMin)*q1x+landaMin*q2x;
357 qy=(1-landaMin)*q1y+landaMin*q2y;
369 tmp_cp_indD=dx*dx+dy*dy-(dx*qy-dy*qx)*(dx*qy-dy*qx)/(qx*qx+qy*qy+LMET2);
372 if (tmp_cp_indD < cp_ass_ptD){
375 cp_ass_ptD=tmp_cp_indD;
380 if (cp_ass_ptD<
params.Br){
405 printf(
"Number of associations too low <%d out of %f>\n",
423 float error_ratio, error;
424 float cosw, sinw, dtx, dty, tmp1, tmp2;
459 printf(
"All assoc: %d Filtered: %d Percentage: %f\n",
472 printf(
"estim_cp: <%f %f %f>\n",estim_cp.
x, estim_cp.
y,estim_cp.
tita);
473 printf(
"New impl: <%f %f %f>\n",estim_cp.
x, estim_cp.
y,estim_cp.
tita);
476 cosw=(float)cos(estim_cp.
tita); sinw=(float)sin(estim_cp.
tita);
477 dtx=estim_cp.
x; dty=estim_cp.
y;
484 for (i = 0; i<cnt;i++){
487 error = error+ tmp1+tmp2;
493 printf(
"<err,errk1,errRatio>=<%f,%f,%f>\n estim=<%f,%f,%f>\n",
494 error,
error_k1,error_ratio, estim_cp.
x,estim_cp.
y, estim_cp.
tita);
500 if (fabs(1.0-error_ratio)<=
params.error_th ||
501 (fabs(estim_cp.
x)<
params.errx_out && fabs(estim_cp.
y)<
params.erry_out
538 float A1, A2, A3, B1, B2, B3, C1, C2, C3, D1, D2, D3;
542 A1=0;A2=0;A3=0;B1=0;B2=0;B3=0;
543 C1=0;C2=0;C3=0;D1=0;D2=0;D3=0;
548 for (i=0; i<cnt; i++){
549 X1[i]=cp_ass[i].
nx*cp_ass[i].
nx;
550 Y1[i]=cp_ass[i].
ny*cp_ass[i].
ny;
551 X2[i]=cp_ass[i].
rx*cp_ass[i].
rx;
552 Y2[i]=cp_ass[i].
ry*cp_ass[i].
ry;
553 X2Y2[i]=cp_ass[i].
rx*cp_ass[i].
ry;
555 X1X2[i]=cp_ass[i].
nx*cp_ass[i].
rx;
556 X1Y2[i]=cp_ass[i].
nx*cp_ass[i].
ry;
557 Y1X2[i]=cp_ass[i].
ny*cp_ass[i].
rx;
558 Y1Y2[i]=cp_ass[i].
ny*cp_ass[i].
ry;
560 K[i]=X2[i]+Y2[i] + LMETRICA2;
561 DS[i]=Y1Y2[i] + X1X2[i];
563 X2DsD[i]=cp_ass[i].
rx*DsD[i];
564 Y2DsD[i]=cp_ass[i].
ry*DsD[i];
566 Bs[i]=X1Y2[i]-Y1X2[i];
569 A1=A1 + (1-Y2[i]/K[i]);
570 B1=B1 + X2Y2[i]/K[i];
571 C1=C1 + (-cp_ass[i].
ny + Y2DsD[i]);
572 D1=D1 + (cp_ass[i].
nx - cp_ass[i].
rx -cp_ass[i].
ry*BsD[i]);
575 B2=B2 + (1-X2[i]/K[i]);
576 C2=C2 + (cp_ass[i].
nx-X2DsD[i]);
577 D2=D2 + (cp_ass[i].
ny -cp_ass[i].
ry +cp_ass[i].
rx*BsD[i]);
581 C3=C3 + (X1[i] + Y1[i] - DS[i]*DS[i]/K[i]);
582 D3=D3 + (Bs[i]*(-1+DsD[i]));
602 estimacion->
x=-
VDATA(vecSol,0);
603 estimacion->
y=-
VDATA(vecSol,1);