Challenge

Week 3.2 - 2R Robotic Arm Challenge

 % 2D arm robot
%Input 

%fixed point of first link
x1=0                        (Initial link is fixed at x1=0 y1=0)

y1=0

%length of link 1&2
l1=2

l2=1

%angle made with x axis by the links

theta1=linspace(0,90,20) (Angle made by first link with x axis)

theta2=linspace(0,90,20) (Angle made by second link with x axis from fixed point)

r=1;

%determining the position of each link at different angle

 for i=1:length(theta1)                (Each value of angle theta1 is used to generate each 
                                        position of link 1)

     X=theta1(i)

x2=l1*cosd(X)
y2=l1*sind(X)

 

 
 for j=1:length(theta2)                 (Each value of angle theta2 is used to generate 
                                         the position of link 2)

   Y=theta2(j)

x3=x2+l2*cosd(Y)

 y3=y2+l2*sind(Y)

 

%Plotting of positions of links at different angle 


plot([x1 x2],[y1 y2],[x2 x3],[y2 y3],'linewidth',3) (Plot syntax:plot([cordinates of x], 
                                                     [cordinates of y])

title('welding robot')

axis([-1 3 0 3])

pause(0.5)

%making the animation of the robot movement

m(r)=getframe(gcf)

 r=r+1;             (For getting repeated frames)
 
 end

 end

 movie(m)   (Syntax:movie(filename_of_frame) )

 videofile=VideoWriter('robotic arm,matlab video')

 open(videofile)

 writeVideo(videofile,m)

 close(videofile)


Error occured in coding:

  Instead of using i=1:length(array) used i=array as a statement in forloop this resulted in error in plotting of output.

 An error also occured in plotting because of not using the for loop to assign theta values to equation


Steps taken to avoid error:

   Step wise execution was done to avoid the error caused in plotting. All the codes where executed step wise to have error free program.


               youtube link :  https://youtu.be/06zFt-kYoOI
https://youtu.be/06zFt-kYoOI
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.