# Difference between revisions of "Robotic Arm: Team A-November"

Line 13: | Line 13: | ||

==MatLab== | ==MatLab== | ||

To draw the circle inside the square, and to create a real time on-screen simulation we used one script. here is he source for that script: | To draw the circle inside the square, and to create a real time on-screen simulation we used one script. here is he source for that script: | ||

+ | |||

+ | s=instrfind; %Find any serial links (we can have only 1) | ||

+ | delete(s); %... and delete. | ||

+ | %Create a new serial communications link - don't worry about details, | ||

+ | s=serial('COM1','Baudrate',115200,'Terminator','CR'); | ||

+ | fopen(s); %... and open it | ||

+ | la=18; %length of the upper arm | ||

+ | lb=17.5; %length of the lower arm | ||

+ | T=.25; % time for each movment | ||

+ | numPts=40; %number of points on each side of the square (1/4 of the number of pts on the circle) | ||

+ | r=5; % radius of the circle | ||

+ | %generate arrays for x2 and y2 (the end of the arm). | ||

+ | x2=[linspace(20,20,numPts*.5), linspace(20,10,numPts), linspace(10,10,numPts), linspace(10,20,numPts), linspace(20,20,numPts*.5)]; | ||

+ | y2=[linspace(15,20,numPts*.5), linspace(20,20,numPts), linspace(20,10,numPts), linspace(10,10,numPts), linspace(10,15,numPts*.5)]; | ||

+ | clf % clear the figure. | ||

+ | % loop through all the values of x2 and y2 | ||

+ | for i=1:length(x2), | ||

+ | %First do inverse kinematics to find angles... | ||

+ | [theta_a, theta_b]= InverseKinematics(la, lb, x2(i), y2(i)); | ||

+ | %Then do forward kinematics to find arm locations. | ||

+ | [xa ya xb yb] = forwardKinematics(la, lb, theta_a, theta_b); | ||

+ | gotoPts(s,x2(i), y2(i), la, lb, T*1000); | ||

+ | subplot(1,2,1); %generate 1x2 plots, choose plot 1 | ||

+ | plot([0 xa xb],[0 ya yb],'b','LineWidth',2); | ||

+ | axis([-35 35 -35 35]); | ||

+ | axis('square'); | ||

+ | subplot(1,2,2); %choose second plot | ||

+ | plot(xb,yb,'r.') %plot red dots | ||

+ | axis([8 22 8 22]); | ||

+ | axis('square'); | ||

+ | hold on; %don't erase this plot. | ||

+ | pause (T); | ||

+ | end | ||

+ | theta=linspace(0, 2*pi, 4*numPts); %Generate and arry of angles theta around the circle. | ||

+ | %we will draw 1 point at each angle. | ||

+ | % loop through all the values of x2 and y2 | ||

+ | for i=1:length(theta), | ||

+ | x2=r*cos(theta(i))+15; %find x & y for each theta, for the unit circle, | ||

+ | y2=r*sin(theta(i))+15; % then scales by the radius and shifts to (15,15) (the center of the drawing) | ||

+ | %First do inverse kinematics to find angles for each servo... | ||

+ | [theta_a, theta_b]= InverseKinematics(la, lb, x2, y2); | ||

+ | %Then do forward kinematics to find arm locations for the simulation. | ||

+ | [xa ya xb yb] = forwardKinematics(la, lb, theta_a, theta_b); | ||

+ | gotoPts(s,x2, y2, la, lb, T*1000); | ||

+ | subplot(1,2,1); %generate 1x2 plots, choose plot 1 | ||

+ | plot([0 xa xb],[0 ya yb],'b','LineWidth',2); | ||

+ | axis([-35 35 -35 35]); | ||

+ | axis('square'); | ||

+ | subplot(1,2,2); %choose second plot | ||

+ | plot(xb,yb,'b.') %plot blue dots | ||

+ | axis([8 22 8 22]); | ||

+ | axis('square'); | ||

+ | hold on; %don't erase this plot. | ||

+ | pause (T); | ||

+ | end |

## Revision as of 18:43, 18 November 2008

Team A-November is a lab group for the E-5 Robot Arm project. The A-November arm consists of two servos, two pieces of aluminum tubing, and various other hardware,used to create an arm of total length 35.5 cm with two degrees of freedom and the ability to be controlled by a computer. Specifically the arm draws a circle in a box, when a MatLab script is run.

## Team Members

## Design

To build the arm we were given two servos and our choice of several brackets and pieces of tubing. First we attached the servo motors to brackets so that they could be attached to other parts. The first bracket (the "shoulder") is a stand that holds the motor fixed several inches above the writing surface. The second, "elbow", bracket consists of a piece of sheet metal used to attach the servo to the upper arm and a "C" shaped bracket attached to output of the servo on one end and the lower arm on the other. The aluminum tubes we used were longer than most of the choices available because we felt that the shorter arms would limit both the range of motion of the arm and the size of our drawings. As we were choosing parts to make the arm we did use smaller tubes originally, but in the end we found that we preferred the longer arm. As we found out when we were testing it, the long arm did have its drawbacks. The distance from the servos of the pencil made every jerk of the motor a big jump. A smaller, sturdier design may have produced smoother drawings.

## MatLab

To draw the circle inside the square, and to create a real time on-screen simulation we used one script. here is he source for that script:

s=instrfind; %Find any serial links (we can have only 1) delete(s); %... and delete. %Create a new serial communications link - don't worry about details, s=serial('COM1','Baudrate',115200,'Terminator','CR'); fopen(s); %... and open it la=18; %length of the upper arm lb=17.5; %length of the lower arm T=.25; % time for each movment numPts=40; %number of points on each side of the square (1/4 of the number of pts on the circle) r=5; % radius of the circle %generate arrays for x2 and y2 (the end of the arm). x2=[linspace(20,20,numPts*.5), linspace(20,10,numPts), linspace(10,10,numPts), linspace(10,20,numPts), linspace(20,20,numPts*.5)]; y2=[linspace(15,20,numPts*.5), linspace(20,20,numPts), linspace(20,10,numPts), linspace(10,10,numPts), linspace(10,15,numPts*.5)]; clf % clear the figure. % loop through all the values of x2 and y2 for i=1:length(x2), %First do inverse kinematics to find angles... [theta_a, theta_b]= InverseKinematics(la, lb, x2(i), y2(i)); %Then do forward kinematics to find arm locations. [xa ya xb yb] = forwardKinematics(la, lb, theta_a, theta_b); gotoPts(s,x2(i), y2(i), la, lb, T*1000); subplot(1,2,1); %generate 1x2 plots, choose plot 1 plot([0 xa xb],[0 ya yb],'b','LineWidth',2); axis([-35 35 -35 35]); axis('square'); subplot(1,2,2); %choose second plot plot(xb,yb,'r.') %plot red dots axis([8 22 8 22]); axis('square'); hold on; %don't erase this plot. pause (T); end theta=linspace(0, 2*pi, 4*numPts); %Generate and arry of angles theta around the circle. %we will draw 1 point at each angle. % loop through all the values of x2 and y2 for i=1:length(theta), x2=r*cos(theta(i))+15; %find x & y for each theta, for the unit circle, y2=r*sin(theta(i))+15; % then scales by the radius and shifts to (15,15) (the center of the drawing) %First do inverse kinematics to find angles for each servo... [theta_a, theta_b]= InverseKinematics(la, lb, x2, y2); %Then do forward kinematics to find arm locations for the simulation. [xa ya xb yb] = forwardKinematics(la, lb, theta_a, theta_b); gotoPts(s,x2, y2, la, lb, T*1000); subplot(1,2,1); %generate 1x2 plots, choose plot 1 plot([0 xa xb],[0 ya yb],'b','LineWidth',2); axis([-35 35 -35 35]); axis('square'); subplot(1,2,2); %choose second plot plot(xb,yb,'b.') %plot blue dots axis([8 22 8 22]); axis('square'); hold on; %don't erase this plot. pause (T); end