Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear; clc; close all;
- dt = 0.1; ts = 10; t = 0:dt:ts;
- x = 0; y = 0; psi = 0;
- eta = [x; y; psi];
- a = 0.1; d = 0.2; l = 0.5;
- mr_co = [-l/2, l/2, l/2, -l/2;
- -d, -d, d, d];
- % MR_CO FOR OMNI WHEEL NOT NEEDED AS PER SIR
- %mr_co = [l, (-sqrt((l^2)-((w/2)^2))),(-sqrt((l^2)-((w/2)^2)));
- % 0, w/2, -w/2];
- %For Kinematics use u v r
- %u = 0.4; v = 0; r = 0.2;
- %zeta=[u;v;r];
- % For Kinematics of DIFFERENTIAL bot use this W and omega
- %omega = [0.4;0.4];
- %W = [a/2,a/2; 0,0; -a/(2*d), a/(2*d)];
- %zeta=(W * omega);
- % For Kinematics of OMNI bot use this W and omega
- %omega = [0; 0.2; -0.2;]; % angular velocities of three wheels
- %W = a/3*[0,-sqrt(3),sqrt(3); 2,-1,-1; 1/l,1/l,1/l]
- %zeta=(W * omega);
- % For Kinematics of MECHANUM bot use this W and omega
- %omega = [0.5;0.5;0.5;0.5]; % angular velocities of four wheels
- %W = a/4*[1,1,1,1; 1,-1,1,-1; -1/(d-l),-1/(d-l),1/(d-l),1/(d-l)];
- %zeta=(W * omega);
- for i = 1:length(t)
- Jacobian = [cos(eta(3,i)), -sin(eta(3,i)), 0;
- sin(eta(3,i)), cos(eta(3,i)), 0;
- 0, 0, 1];
- eta_dot = Jacobian * zeta;
- eta(:,i+1) = eta(:,i) + dt * eta_dot;
- end
- figure
- for i = 1:length(t)
- pos = [cos(eta(3,i)), -sin(eta(3,i));
- sin(eta(3,i)), cos(eta(3,i))] * mr_co;
- fill(pos(1,:)+eta(1,i), pos(2,:)+eta(2,i), 'o')
- hold on, grid on, axis equal;
- plot(eta(1,1:i), eta(2,1:i), 'b-');
- axis([-1 5 -1 5]);
- xlabel('x[m]'); ylabel('y[m]');
- legend('MR','Path'), set(gca,'fontsize',24)
- pause(0.001);
- hold off;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement