-
Notifications
You must be signed in to change notification settings - Fork 0
/
estimatePoseError.m
30 lines (22 loc) · 1.12 KB
/
estimatePoseError.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function [prob] = estimatePoseError(oldPose,oxpos,oypos,newPose,xpos,ypos,timeTaken,omega,v)
if (xpos == ypos && oxpos == oypos)
mu = 0;
xstar = 0.5 * (xpos + oxpos) + mu * (oypos - ypos);
ystar = 0.5 * (ypos + oypos) + mu * (oxpos - xpos);
angleChange = newPose-oldPose;
else
mu =((oxpos - xpos)*cos(oldPose) + (oypos - ypos)*sin(oldPose));
mu = mu / ((oypos - ypos)*cos(oldPose) + (oxpos - xpos)*sin(oldPose));
mu = 0.5 * mu;
xstar = 0.5 * (xpos + oxpos) + mu * (oypos - ypos);
ystar = 0.5 * (ypos + oypos) + mu * (oxpos - xpos);
angleChange = atan2(ypos - ystar, xpos - xstar) - atan2(oypos - ystar, oxpos - xstar);
end
rstar = sqrt(power((oxpos - xstar),2) + power((oypos - ystar),2));
vhat = (angleChange/timeTaken) * rstar;
omegahat = (angleChange/timeTaken);
gammahat = ((newPose-oldPose)/timeTaken) - omegahat;
prob = normpdf(v - vhat, 0, 0.15*abs(v) + 0.15*abs(omega));
prob = prob * normpdf(omega-omegahat,0, 0.15*abs(v) + 0.15*abs(omega));
prob = prob * normpdf(gammahat,0, 0.15*abs(v) + 0.15*abs(omega));
end