All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim : To simulate the Forward Kinematics of a 2R Robotic Arm using MATLAB Program and tracing the Workspace of the End Effector using an Animation. Description : A Robotic Arm is a programmable Mechanical Arm which may be the sum total of Mechanism or a part of complex shape. The links are connected by joints…
RAJAMAHANTI HARSHITH
updated on 28 Aug 2020
Aim :
To simulate the Forward Kinematics of a 2R Robotic Arm using MATLAB Program and tracing the Workspace of the End Effector using an Animation.
Description :
A Robotic Arm is a programmable Mechanical Arm which may be the sum total of Mechanism or a part of complex shape. The links are connected by joints which allow either Rotational or Translational Movement. 2R Robotic Arm is a Robotic Arm with 2 Rotational joints. The links of the Robotic Arm form a kinematic chain and the terminus of this kinematic chain is called End Effector. The End Effector interacts with the Environment. Both the links of the Robotic Arm are restricted to a 90 degree rotation with respect to the axis.
Degree of Freedom (DOF) of each link = 1
Kinematics of the Robotic Arm :
Kinematics is the analysis of motion without considering the forces.Forward kinematics (for a robot arm) takes as input joint angles, and calculates the Cartesian position and orientation of the end effector. Inverse kinematics takes as input the Cartesian end effector position and orientation, and calculates joint angles. Inverse kinematics is used for trajectory planning.
Figure :
l1 is the length of 1st link and l2 is the length of 2nd link. Considering that link 1 is attached to the horizontal plane and making an angle θ1 with the horizontal. The link 2 is connected to link 1 and makes angle θ2 with horizontal. The co ordinates of (x0,y0) (x1,y1) and (x2,y2) are shown in figure.
MATLAB CODE :
%program for forward kinematics of a 2 arm robotic manipulator
clear all
close all
clc
%Inputs for link 1 and link 2
l1=1;
l2=0.5;
%Taking set of angles for θ1 and θ2 with same interval using linspace command
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
%Initializing the counter variable
ct=1;
%for loop programming
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
%co ordinates calculation
x0=0;
y0=0;
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+(l2*cosd(THETA2));
y2=y1+(l2*sind(THETA2));
%plotting the values
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
%setting the X axis and Y axis limits
axis([-0.1 1.5 0 1.5])
%pausing the code in sec
pause(0.2)
%Getting all the frames in a single matrix
M(ct)=getframe(gcf);
%Incrementing the counter variable
ct=ct+1;
end
end
%creating an animation and extracting the video file
movie(M)
videofile=VideoWriter('forward_kinematics.avi','uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)
Explanation for the code:
At first the input values for the lengths of the links are taken and now the set of values of θ1 and θ2 are taken such for different locations of the links the workspace will be traced.For one θ1 value of link 1 ten θ2 values of link is obtained.This can be acheived by the for loop and nested for loop operations. All the co ordinate value calculations and plotting commands should be included in the nested for loop.So 100 positions of links will be traced by these loops. Pause command pauses the code for a particular time period before executing the next incremental step in a for loop so it creates an illusion like animation.
getframe : It collects the frame and stores the frame in it
movie : It generates an animation using the frames collected
videofile=videoWriter() : It assigns file name and file format
open(videofile) : It opens the video file
writeVideo(videofile,M) : It writes the video with plot frames in array M
close(videofile) : It closes the video file
Output plots :
Using basic plot command plotting all the link positions in a single frame with out any animation
All the 100 link positions will be displaced in a seperate frames if figure(ct) is placed above the plotting command.It displays each link position independently.
Animation video youtube link : https://youtu.be/mfQ9D7Um558
Conclusion :
Hence an animation video is created to enhance the positions of the End Effector.Its very important to know the work space locations in most of the Robotic applications like Welding a complex frame structure,Drilling applications,palletization in industries and some laser cutting operations.
Error :
Error rectification:
'videowriter' and 'writevideo' are undefined functions as they are case-sensitive. 'VideoWriter' and 'WriteVideo' are the actual commands to rectify the error
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...
3D simulation of water in a curved pipe using snappyhexmesh in openfoam
Aim : To simulate the flow of water in a curved pipe using snappyhexmesh in openfoam Geometry in Meshlab : The different .stl files can be viewed in Meshlabs and the identification of refinement zones would become easy . Input data: velocity of water at the pipe inlet = 7m/sec at 25 deg blockMeshDict File : FoamFile…
02 Jun 2021 04:49 AM IST
2D simulation of flow over a square obstacle using openfoam
Aim : To calculate velocity contour and dragforce on a square obstacle placed in the air field and to automate the simulation process in openfoam Geometry : The geometry is created by blockMeshDict file in Openfoam. Input data : velocity at inlet = 10 m/sec Temperature at inlet = 25 deg c Reynolds number= Re…
01 Jun 2021 10:59 PM IST
Emission characterization on a CAT3410 engine
Emission Characterization on a CAT3410 Engine Aim: To run the simulation for emission characterization on a CAT3410 Engine. Objective: To run the simulation for emission characterization on a CAT3410 engine for two different piston profiles (i.e. Open-w,…
11 Apr 2021 09:06 PM IST
FINAL TEST
Q1. What is the Compression ratio for the engine? From the Volume vs Crank Angle Plot Here the maximum volume is = 0.0005738 and the minimum volume is = 5.7032 e-5 m^3 And the compression ratio is Maximum Volume / Minimum Volume = 0.0005738 / 5.7032e-5 = 10.06 Q2. Modify the compression ratio for this…
09 Apr 2021 11:25 PM 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.