All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
- 1. Aim: To plot the forward kinematics of a 2R robotic arm using MATLAB. - 2. objective: - To perform the animation of a 2R robotics arm - Represent the motion of two arms of a robot. - Use of for loops to perform the operations. - 3. Method: - The program shown below gives the idea of the operation…
Neel sanap
updated on 17 Sep 2020
- 1. Aim: To plot the forward kinematics of a 2R robotic arm using MATLAB.
- 2. objective:
- To perform the animation of a 2R robotics arm
- Represent the motion of two arms of a robot.
- Use of for loops to perform the operations.
- 3. Method:
- The program shown below gives the idea of the operation of the two arms.
- All the necessary inputs are given and commands are also specified wherever necessary.
- The most important point here is to understand the working of a 'for loop'.
- Here is the independent motion of both the arms are required and for each motion of 1st arm, a number of motion for 2nd arm are required.
- To obtain this requirement the for loop is used.
% This is a MATLAB program for forward kinematics of a 2R robotic arm
% manipulator
clear all
close all
clc
%input parameters like length and theta angle for two arms
% l1 & l2 = length of 1st & 2nd arm in meter
% theta1 & theta2 are angle from horizontal axis in degree
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
ct =1;
% ct is a counter which represents each and every frame
% for each value of theta1, theta2 is having a number of values, 10 in this
% case. so for this, we need to give another for loop for theta2. for each
% for loop, the loop counter variable is different.
% THATE1 & THETA2 are variables which contain 1 value of theta1
for i = 1: length(theta1)
THETA1 = theta1(i);
for j = 1: length(theta2)
THETA2 = theta2(j);
x0 = 0;
y0 = 0;
%cosd is used as cos only expect the value in radian
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);
%plotting- plot command needs the list of start and end values of
%both x any y
plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.1)
M(ct) = getframe(gcf);
% M is an array where we are going to store all figure windows
ct = ct+1;
end
end
movie(M) % matlab will generate movie with all frames
videofile = VideoWriter('forward_kinematics1.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
- The plots shown below represent the different motions of the two arms depending upon the theta1 and theta2 angles.
- From the plot and the video, it can be seen that for each theta change of link 1(blue link), link 2(red link) is having a number of motions. Here in this case 10.
- Both links red and blue represent the two robotic arms having some definite motion.
Plot at the begin of the program at theta1=0,theta2>0 |
Plot at the begin of the program at theta1>0,theta2>0 |
Plot at the begin of the program at theta1=0,theta2>0 |
Plot at the begin of the program at theta1=90,theta2=0 |
![]() |
- The plot is shown represent the error occurred during running the program. - The first error was Movie command which creates a movie has to be as 'movie', whereas in the program by mistake it was 'Movie'. - Another error was on line 44 where 'VideoWriter' was needed instead of 'Videowriter'. |
-4. Learning outcome:
- Understanding the use of a 'for loop'.
- Understanding the application of a for in for loop.
- Able to perform an animation of a robotic arm.
- Understanding the command like linespace, getframe, get current frame, for loop, movie.
-5. Conclusion:
- Using the for in for loop result in two different motion of arms i.e while link 1 is at a particular theta angle, link 2 is able to complete its cycle and this cycle repeats again and again as per limiting values.
- For loop can be used to perform the same task again and again and can be used in a different manner as shown above.
Youtube link: https://youtu.be/j6eEpuilwQ0
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...
Photo Realistic Rendering
Title: modelling of the chopper model in Solidworks. - Objectives: - To model different parts of the chopper along with proper constraints. - To do assembly of the chopper model. - Perform the rendering operations. - Introduction: - Designing or modelling of a vehicle generally starts with the styling team,…
01 Sep 2021 10:25 AM IST
Benchmarking
2. Prepare a report explaining what is benchmarking. Benchmarking involved a comparison between similar products on some dimensions of performance. It can be used to compare the availability and delivery of features in a product and in this form often provide the basis of consumer tests and review. These look at products…
30 Jun 2021 05:26 AM IST
Design of backdoor
- Aim: To design the back door of an automobile using the styling surface along with necessary reinforcement and embosses. - Method: - Back door: - A car door is a type of door, typically hinged, but sometimes attached by other mechanisms such as tracks, in front of an opening that is used for entering and exiting a vehicle.…
24 Jun 2021 06:51 PM IST
Roof challenge
- Aim: To design the Automotive roof rail and all the necessary components to improve the strength of the roof as per the master section. - Method: - An automobile roof or car top is the portion of an automobile that sits above the passenger compartment, protecting the vehicle occupants from sun, wind, rain, and other…
22 May 2021 06:44 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.