All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
% A program to simulate the forward kinematics of a 2R Robotic Arm clear allclose allclc % Taking inputs% Length of link-1 (L1) and link-2 (L2) in meterL1=1;L2=0.5; % Angle traced by link-1 in degrees (theta_1)theta_1=linspace(0,90,11); % Angle traced by link-2 in degrees (theta_2)theta_2=linspace(0,90,21); % Initialising…
Dhanu Manthri
updated on 21 Jul 2022
% A program to simulate the forward kinematics of a 2R Robotic Arm
clear all
close all
clc
% Taking inputs
% Length of link-1 (L1) and link-2 (L2) in meter
L1=1;
L2=0.5;
% Angle traced by link-1 in degrees (theta_1)
theta_1=linspace(0,90,11);
% Angle traced by link-2 in degrees (theta_2)
theta_2=linspace(0,90,21);
% Initialising base coordinates of link-1
x_0=0;
y_0=0;
ct=1;
i=1:length(theta_1)
THETA_1 = theta_1(i); %taking particular values of angle traced by link-1 in order.
for j = 1:length(theta_2) % Iterating all values of theta_2 for particular value of theta_1
THETA_2=theta_2(j); %taking particular values of angle traced by link-2 in order.
% Calculating the coordinates of end point of link-1
x_1=x_0+L1*cosd(THETA_1);
y_1=y_0+L1*sind(THETA_1);
% Calculating the coordinates of the end of link-2
% End coordinates for link-1 are the start coordinates for link-2
x_2=x_1+L2*cosd(THETA_2);
y_2=y_1+L2*sind(THETA_2);
% Plotting the robotic arm for simulation
plot([x_0 x_1],[y_0 y_1],[x_1 x_2],[y_1 y_2], "linewidth",2);
axis([-0.1 1.5 0 1.5]);
% Pausing the current plot for a while before movoing to the next
% plot
pause(0.03);
% Capturing the current plot to combine later
M(ct) = getframe(gcf);
% Incrementing ct so that each frame is captured in M
ct=ct+1;
end
EXPLANATION OF THE PROGRAM:
1.Lengths of both the links are taken as input. Length of link-1 (L1) is taken as 1m and length of link-2 (L2) is taken as 0.5m.
2.Angles traced by both the links, for link-1 and for link-2 is taken as input. The angles traced are varied over a range to simulate the movement of the robotic arm.
3.Base position of link-1 (x0,y0)is considered as origin (0,0).
4.Then two for loops are used to iterate over the range of angles traced by both the links. For each particular angle of link-1 , link-2 is moved over its entire range , to obtain different positions of end effector at that angle of link-1.
5.For a particular value of θ1 and θ2, the end position of link-1 is calculated by these equations.
x1 = x0 + L1 ⋅cos(θ1)
y1 = y0 + L1 ⋅sin(θ1)
The end position of link-1 is also the start position of link two. The end position for link-2 is calculated by these equations.
x2 = x1 + L2 ⋅cos(θ2)
y2 = y1 + L2 ⋅sin(θ2)
6.Then for each particular position of lin-1 and link-2 , a plot is made which is then captured frame by frame to make a movie.
7.A video file of '.avi' format is made to save the movie.
8.The movie is then written into the videofile and the final animation is thus created.
OUTPUT :
The output is obtained in form of an animated video clip. This animation can be viewed by visiting the link mentioned below.
https://youtu.be/9QOsVcTAxNM
CONCLUSION :
A simulation of the forward kinematics of a 2R Robotic Arm in 2D workspace was created using MATLAB program.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 14 challenge
AIM : To assemble the Butterfly Valve by using the sub parts created and apply the GD&T to the Butterfly Valve assembly drawing.Introduction:Butterfly Valve:A butterfly valve is a valve that isolates or regulates the flow of a fluid. The closing mechanism is a disk that rotates. A butterfly valve is from…
08 Nov 2024 01:47 PM IST
Week 12- Final project
DEVELOPEMET OF DOOR TRIM PANEL AIM: To develop a door trim panel following the design…
28 Mar 2024 05:54 AM IST
Week 11 - Project - A pillar Design with Master Section
A PILLAR DESIGN WITH MASTER SECTION AIM: To create the A Pillar Design with the master section given as the…
14 Mar 2024 06:16 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.