Challenge

Week 2- 2R Robotic Arm Challenge

Explanation of the code:

  • starting programm by useing comments
  • started by basic command(i.e clc,close all clear all..) to make sure command and workspace has no date
  • providing the data required to exuctue the programm calcilations.
  • provind the length valves for links or robatic arms i.e l1and l2 and theta valve using linspace command for theta 0 to 90 degrees for 15 valves.
  • instating the for loop command to get desirable variables
  • again insatating for loop command for second aram movement
  • and then providing the equations for x1,x2,y1,y2 of coordinates of both robatic arm.
  • plot the equations and provind the axis
  • use the pause command tho plot look realistic.
  • incrementing the ct+1 for every loop executes the command.
  • and assign all the variables as m.
  • using movie command animated plot exectes by saving all the in m file.
  • end animated plot saved in AVI format.

MATLAB code:

% program for 2 arm robatic challange

clear all

close all

clc

% data requried

l1=1;

l2=0.5;

theta=linspace(0,90,10);

theta=linspace(0,90,10);

ct=1;

% for loop

for i=1:length(theta1);

THEATA1=theta(1);

for j=1:length(theta2);

THETA2=theat2(j):

x0=0;

y0=0;

x1=l1*cosd(THETA1)

y1=l1*sind(THETA1);

x2=x1+cosd(THETA2);

y2=y1+sind(THEAT2);

% plotting

plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3)

axis([-0.5 1.2 0 1.5])

pause (0.03)

m(ct)=ct+1;

end

end

% animation ploting

movie(m)

videofile=videowriter('robatic_arm-animation',uncompressed AVI')

open(vidEofile)

writevideo(viedofile,m)

close (videofile)

Error faced in programming:

* error foumd during exicution

*use of semi colon(;) in coding results no output date in command window

*typo error

*saving of animated file .

screen shoots of errors and steps taken to over come it:

  • In line 14 i wrote l1+cosd(theta1) and corrected it.l1*cosd(theta1) like wise all link co ordinates

  • In line 23 i worte y2=x2+l2*sind(THETA2)i corrected to y2=y1+sind(THETA2) after corrected result attaached in below fig

  • Here i dont specify the valve of ct after this error i mentiond the valve of ct.

  • animated plot was obtained in the result.
  • check the programm and identified the code error and rectified.

NOTE: program file and animated AVi file is attached

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.