Difference between revisions of "Robotic Arm: Team November"
(→MatLab Code for Physical Model) |
|||
Line 31: | Line 31: | ||
% loop through all the values of phi | % loop through all the values of phi | ||
for i=1:length(phi), | for i=1:length(phi), | ||
− | + | x2=x0+r*cos(phi(i)); %x2 and y2 trace out a circle. | |
− | + | y2=y0+r*sin(phi(i)); | |
− | + | %First do inverse kinematics to find angles... | |
− | + | la=4.5; | |
− | + | lb=3.75; | |
− | + | [theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2, y2); | |
− | + | %Then do forward kinematics to find arm locations. | |
− | + | %[xa ya xb yb] = forwardKinematics(la, lb, theta_a, theta_b); | |
− | + | pause(0.1); %delay 1/10 second | |
− | + | gotoAngles(s,theta_a,theta_b-theta_a,750); | |
end | end | ||
Line 52: | Line 52: | ||
%Draw and animate the arm; | %Draw and animate the arm; | ||
numPts = 10; %the number of points in the animation | numPts = 10; %the number of points in the animation | ||
+ | |||
x2=linspace(6.5+r,6.5+r,numPts) %generate an array of x2 ... | x2=linspace(6.5+r,6.5+r,numPts) %generate an array of x2 ... | ||
y2=linspace(r,-r,numPts) %... and y2 values to define a line. | y2=linspace(r,-r,numPts) %... and y2 values to define a line. | ||
Line 57: | Line 58: | ||
% loop through all the values of x2 and y2 | % loop through all the values of x2 and y2 | ||
for i=0:numPts, | for i=0:numPts, | ||
− | + | x2=6.5+r | |
− | + | y2=r-(i*(2*r/numPts)) | |
− | + | %First do inverse kinematics to find angles... | |
− | + | la=4.5; | |
− | + | lb=3.75; | |
− | + | [theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2, y2); | |
− | + | pause(0.1); %delay 1/10 second | |
gotoAngles(s,theta_a,theta_b-theta_a,750); | gotoAngles(s,theta_a,theta_b-theta_a,750); | ||
Line 79: | Line 80: | ||
for i=1:length(x2), | for i=1:length(x2), | ||
− | + | %First do inverse kinematics to find angles... | |
− | + | la=4.5; | |
− | + | lb=3.75; | |
− | + | [theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2(i), y2(i)); | |
− | + | pause(0.1); %delay 1/10 second | |
− | + | gotoAngles(s,theta_a,theta_b-theta_a,750); | |
end | end | ||
Line 98: | Line 99: | ||
for i=1:length(x2), | for i=1:length(x2), | ||
− | + | %First do inverse kinematics to find angles... | |
− | + | la=4.5; | |
− | + | lb=3.75; | |
− | + | [theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2(i), y2(i)); | |
− | + | pause(0.1); %delay 1/10 second | |
− | + | gotoAngles(s,theta_a,theta_b-theta_a,750); | |
end | end | ||
Line 117: | Line 118: | ||
for i=1:length(x2), | for i=1:length(x2), | ||
− | + | %First do inverse kinematics to find angles... | |
− | + | la=4.5; | |
− | + | lb=3.75; | |
− | + | [theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2(i), y2(i)); | |
− | + | pause(0.1); %delay 1/10 second | |
− | + | gotoAngles(s,theta_a,theta_b-theta_a,750); | |
end | end |
Revision as of 14:53, 13 November 2008
Members
Jared Nolan, David D'Annunzio, Daniel Cabrera, Tony Blekicki
MatLab Code for Physical Model
%[thetaA, thetaB] = inverseKinematicsfunction(4.5, 3.75,6.5,-1.5);
% This script takes input from the user and uses it to test the function % gotoAngles
s=instrfind; %Find any serial links (we can have only 1) delete(s); %... and delete. %Create a new serial communications link s=serial('COM1','Baudrate',115200,'Terminator','CR'); fopen(s); %... and open it
% set pulsewidth on channels 1 & 2to 1500 microseconds (over 200 mS) fprintf(s,'#1P1500#2P1500T200');
%Draw and animate the arm; numPts = 20; %the number of points in the animation phi = linspace(0,2*pi,numPts); %angle goes from 0 to 2*pi.
x0=6.5; %Define center (x0,y0) of circle and radius (r) y0=0; r=1.06066;
% loop through all the values of phi for i=1:length(phi), x2=x0+r*cos(phi(i)); %x2 and y2 trace out a circle. y2=y0+r*sin(phi(i));
%First do inverse kinematics to find angles... la=4.5; lb=3.75; [theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2, y2);
%Then do forward kinematics to find arm locations. %[xa ya xb yb] = forwardKinematics(la, lb, theta_a, theta_b);
pause(0.1); %delay 1/10 second
gotoAngles(s,theta_a,theta_b-theta_a,750);
end
%Draw and animate the arm;
numPts = 10; %the number of points in the animation
x2=linspace(6.5+r,6.5+r,numPts) %generate an array of x2 ... y2=linspace(r,-r,numPts) %... and y2 values to define a line.
% loop through all the values of x2 and y2 for i=0:numPts, x2=6.5+r y2=r-(i*(2*r/numPts))
%First do inverse kinematics to find angles... la=4.5; lb=3.75;
[theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2, y2);
pause(0.1); %delay 1/10 second
gotoAngles(s,theta_a,theta_b-theta_a,750);
end
%Draw the second side; numPts = 10; %the number of points in the animation x2=linspace(6.5+r,6.5-r,numPts) %generate an array of x2 ... y2=linspace(-r,-r,numPts) %... and y2 values to define a line.
% loop through all the values of x2 and y2 for i=1:length(x2),
%First do inverse kinematics to find angles... la=4.5; lb=3.75;
[theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2(i), y2(i));
pause(0.1); %delay 1/10 second
gotoAngles(s,theta_a,theta_b-theta_a,750); end
%Draw the third side; numPts = 10; %the number of points in the animation x2=linspace(6.5-r,6.5-r,numPts) %generate an array of x2 ... y2=linspace(-r,r,numPts) %... and y2 values to define a line.
% loop through all the values of x2 and y2 for i=1:length(x2),
%First do inverse kinematics to find angles... la=4.5; lb=3.75;
[theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2(i), y2(i));
pause(0.1); %delay 1/10 second
gotoAngles(s,theta_a,theta_b-theta_a,750); end
%Draw the fourth side; numPts = 10; %the number of points in the animation x2=linspace(6.5-r,6.5+r,numPts) %generate an array of x2 ... y2=linspace(r,r,numPts) %... and y2 values to define a line.
% loop through all the values of x2 and y2 for i=1:length(x2),
%First do inverse kinematics to find angles... la=4.5; lb=3.75;
[theta_a, theta_b]= inverseKinematicsfunction(la, lb, x2(i), y2(i));
pause(0.1); %delay 1/10 second
gotoAngles(s,theta_a,theta_b-theta_a,750); end