Challenge

Week 2- 2R Robotic Arm Challenge

https://drive.google.com/file/d/1ROtVmcuL8BVQwoTHXqTV8zu-zlZPSw04/view?usp=sharing

%prgram to simulate a forward kinematic of a 2R robotic arm in Matlab

clear all
close all 
clc

%In industries robotic arms can be used in different areas for minimizing human efforts and for completing the targets in a short period of time, a simple robotic arm consists the two links one is known as the fixed link and another one is the moveable link.

%Giving the value of the counter for obtaining the output on single graphs

ct=1;
% Let's assume the length of both links in meter(m)

l1=5

l2=15

%lets assume the values of theta angle from 0 to 90 degrees, which is shown the movement of the links from the starting position of the link to the ending position of the link

%theta1 is the angle made by link 1 with the base axis

theta1=linspace(0,90,15)

%theta2 is the angle made by link 2 with the base axis

theta2=linspace(0,90,15)

%ct is used as a counter command for displaying each single value

ct=1

%for loop is used for repeating the action again and again

for  i=1:length(theta1)

    THETA1=theta1(i)
  
 for j=1:length(theta2)

     THETA2=theta2(j)
      
 
  %coordinates of the link are writtten below x0,y0 & x1,y1 & x2,y2


  %x0 and y0 are coordinates of link 1 at the starting point of the link 

 x0=0;
 y0=0;

 %x1 and y1 are the coordinates of link 1 at the ending of the link1

 x1=l1*cosd(THETA1)
 y1=l1*sind(THETA1)

 %x2 and y2 are the coordinates of link 2 at the ending of the link the coordinates x1 and x2 act as the starting coordinate of the link2 which we already have to define

 x2=x1+l2*cosd(THETA2)
 y2=y1+l2*sind(THETA2)

 
 %ploting the position of the link on diffrent angle on the graph point


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

 axis([-0.1 20 0 20])

 pause(0.3)

 %M is used for creating the movie and M is an array that stores the value of angles at a different position

 M(ct)=getframe(gcf)

 ct=ct+1

 end

 end 


 movie(M)
 
 videofile=VideoWriter('forward_kinematic_arm_2_R.avi','Uncompressed AVI')

 open(videofile)
 
 writeVideo(videofile,M)

 close(videofile)




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.