Newer
Older
abgabensammlungSS15 / mr / ub8 / localize_ekf / motion_diff.m
@MaxXximus92 MaxXximus92 on 22 Jun 2015 827 bytes ea8 scheiss code
function [ xnew G] = motion_diff( x, u )
%MOTION_DIFF Compute differential drive motion model

l = 0.1; % distance between both wheels

theta = x(3);
sl = u(1);
sr = u(2);
if(sr~=sl)
% YOUR CODE STARTS HERE %
deltaTheta= (sr-sl)/l;
r= (sl+sr)/(sr-sl) *l/2;

% fill this with the result of applying the motion model

xnew= x+ [r*(sin(theta+deltaTheta)-sin(theta));
          r*(-cos(theta+deltaTheta)-cos(theta));
          deltaTheta];
      
G = [1,0,r*(cos(theta+deltaTheta)-cos(theta));
    0,1,r*(sin(theta+deltaTheta)-sin(theta));
    0,0,1];      
else
xnew= x+[sl*cos(theta);
        sl*sin(theta);
        0];
G = [1,0,r*(cos(theta+deltaTheta)-cos(theta));
    0,1,r*(sin(theta+deltaTheta)-sin(theta));
    0,0,1];    
end    
% fill this with the motion Jacobian G
% G=zeros(3,3)



% YOUR CODE ENDS HERE %     

end