Robotic Arm: Team Blue

From ENGR005 2008
Revision as of 00:09, 17 November 2008 by Esilver1 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Dinh | Parasrampuria | Silverblatt-Buser | Weiner

Design of the Robot Arm


Solidworks Model

Programming the Robot Arm through MATLAB


The approach that Team Blue used in making the MATLAB code for drawing an inscribed circle in a square proved to be frustrating at times. First, the team drew out a flow chart of what previous functions they had composed. gotoAngles, forwardKinematics, and inverseKinematicsf were the functions that the team used.


Most of the issues were syntax issues which came from combining codes together and not having the same variables in functions. They were solved with help from Professor Cheever. However, the largest problem was discovered when the robot arm's drawing was skewed and was not a perfect square. An example of this can be seen in the photo below. The cause of this was discovered to be the calibrations done on the servo motors. Also, a mix up on identifying the length of the lower and upper arm distorted the first attempted drawings.

The motors used weren't exact and so the team had to measure and compensate for how much the motor was skewed. This measurement was not close enough and therefore, the angles made were not exact.

Other than these issues, the team did not incur many other issues when writing the MATLAB code.

Photograph of the Robot Arm


The Robot Arm on the day of demonstration. This would have been a great picture except for the feet.


A close up of the Robot Arm's Drawing. NOTE: This photo was enhanced in order to clearly show the skewed angles of the drawing.


Forward Kinematics

function [x1, y1, x2, y2] = forwardKinematics(la, lb, theta_a, theta_b) %Calculate locations of arms of robot theta_a = theta_a * pi/180;  %Convert angles to radians. theta_b = theta_b * pi/180;

x1 = la*cos(theta_a);  %find positions y1 = la*sin(theta_a); x2 = x1 + lb*cos(theta_b); y2 = y1 + lb*sin(theta_b);

Inverse Kinematics

function [theta_a, theta_b] = inverseKinematicsf(x2, y2) %Define robot geometry la=11.6; lb=8; % Find theta_a and theta_b theta_a= atan2(y2,x2) + acos((la^2 + (x2^2 + y2^2)-lb^2 )/(2*la*sqrt(x2^2 + y2^2))); theta_b= atan2((y2-la*sin(theta_a))/lb,(x2-la*cos(theta_a))/lb);

% Convert to degrees theta_a = theta_a*180/pi; theta_b = theta_b*180/pi;


Go to Angles

function gotoAngles(s,theta_a,theta_b,T)

%Create a new serial communications link

pwB= (theta_b-150)/(-.1); %invert P to theta equation for B pwB=round(pwB); %round answer to integer %cmd=['#4P' num2str(pw) 'T' num2str(T)]

%pwA=(theta_a-140)/(-.093); %invert P to theta equation for A pwA= (theta_a-10)/(-.2) theta_a pwA=round(pwA); %round answer to integer cmd=['#1P' num2str(pwA) '#4P' num2str(pwB) 'T' num2str(T)]

fprintf(s,cmd); % ...



Final Code

T=100; la=11.6, lb=8

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

[ta tb]=inverseKinematicsf(13,-10); tbnew=tb-ta; [ta tbnew] gotoAngles(s,ta,tbnew,T);

x2=[13 10 10 13 13 13]; y2=[-10 -10 -13 -13 -10 -11.5];

for i=1:(length(x2)-1),

   for j=1:length(x2i)
       [ta tb]=inverseKinematicsf(x2i(j),y2i(j));
       [ta tbnew]


numPts = 50 phi = linspace(0,360,numPts)

x0=11.5;  %Define center (x0,y0) of circle and radius (r) y0=-11.5; r=1.5;

% loop through all the values of phi for i=1:length(phi),

  x2=x0+r*cosd(phi(i)); %x2 and y2 trace out a circle.
  [aa bb]=inverseKinematicsf(x2, y2);
  gotoAngles(s, aa, bbnew, T);