Project

2R-Robotic Arm

AIM:

To simulate the forward kinematics of a 2R Robotic Arm.

PROGRAMMING LANGUAGE USED IS MATLAB.

OBJECTIVE OF THE PROJECT:

The Robotic arm will be a two link upon which forward kinematics is being applied (Forward kinematics refers to process of obtaining position and velocity of end effector, given the known joint angles and angular velocities.)

THE ABOVE IMAGE EXPLAINS THE WORKING OF THE 2R Robotic ARM mathematically.

CODE:-

%%CODE FOR THE FORWARD KINEMATICS SIMULATION OF A 2R-ROBOTIC ARM

clear all %Clears the stored variables from the Workspace
close all
clc %Clears the command window

%%PROVIDING THE INPUT
l1=1;
l2=0.5;
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
ct=1; %%Using ct for iterations of the frame or Advancing the frame number to save it in and can be displayed in the form of a movie
for i=1:length(theta1) %Using for loop for plotting multilple values of theta this loop is used for link 1
THETA1=theta1(i);
for j=1:length(theta2)%Using for loop for plotting multilple values of theta this loop is used for link 2
THETA2=theta2(j);

%%Providing the coordinates of the base of the 2r Robotic Arm
x0=0;
y0=0;

%The explanation of the below calulations is given in the figure
%above

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


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

plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3)%Using plot command to plot the coordinates
axis([-0.1 1.5 0 1.5])%Axis command helps us provided the axis to the plot
pause(0.05) %pause command helps to pause the code for the time specfied,it helps in making the code look more animated
M(ct)=getframe(gcf); %capturing the frame obtained by the loop movement in ct
ct=ct+1;%%Advancing the frame number
end
end
movie(M) %Generating the movie of the code using the movie command with help of the frames saved in ct
Videofile=VideoWriter('Rovot.avi','Uncompressed AVI'); %using videoriter to generate a AVI file of the frames saved
open(Videofile) %opening the video file
writeVideo(Videofile,M)
close(Videofile) %closing the videofile

YOUTUBE VIDEO LINK

ERRORS FACED WHILE PROGRAMMING

[ERROR 1]-MATLAB IS CASE SENSETIVE

STEPS TAKEN-While creating the video use "VideoWriter" not "videowriter" or "Videowriter" or "videoWriter".

[ERROR 2] using "SIND" and "COSD" in the code because matlab by default considers angles in radians we have to convert them into degrees

OUTPUT OF THE CODE

The simulation of the forward kinematis of a 2R-Robotic arm manipulator is done and we observed that for each 10 degree of movement of the Link 1 there is 90 degree movemnt of the link 2.

USE OF THE FOLLOWING FUNCTIONS USED WHILE PROGRAMMING

FOR LOOP- For loop is used here for the iteration of the theta values from 0 to 90 degrees I is used as the outer loop and J is used as the inner loop ,i is used for the movement of the link 1 and J is used for the movement of link 2.

COSD and SIND are used to covert the Radians into Degrees,because MATLAB by default takes angles in radians.

PAUSE - We have paused the code so that the process can be visualised more clearly .

Ct-Ct is used for saving the frames in order to create a movie of the frames

Getframe-Similarly getframe is used to capture the frame and then by fast movement of those frames it can be converted into a movie

Movie -Movie command is used to create a movie of the frames captured .

VideoWriter -It is to create a Video file of the movie created and save in the pc hard disc.

Plot - The plot command is used to plot the graphs of the coordinates provided.

Axis- The axis command is used to create the axis upon which we are going to plot the coordinates.

Linspace-The linspace command is useful in creating an array of values specified by the user.

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.