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. 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,…
Ayush Kumar
updated on 15 Sep 2020
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.
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 6 - Data analysis
AIM :TO WRITE A PYTHON PROGRAM WHICH READS THE ENGINE OUTPUT PARAMETER DATA FILE AND PERFORM THE REQUIRED OBJECTIVES The programming language used is Python 2.OBJECTIVE : To read the data from a given data file. To take the file name as an input from the user and check whether the file is present or not. To plot a graph…
16 Aug 2021 10:01 AM IST
Week 3 - Solving second order ODEs
Aim: To write a program to simulate the transient behavior of a simple pendulum.(Simulate the motion between 0-20 sec, for angular displacement=0,angular velocity=3 rad/sec at time t=0) To create an animation of its motion. Theory: A pendulum is a weight suspended from a pivot so that it can swing freely. When…
14 Jul 2021 08:05 AM IST
Week 5 - Curve fitting
AIM- To write a PYTHON code that performs curve-fitting on the relationship between cp and Temperature and finding the PERFECT FIT for the following. THEORY- Curve fitting is the process of constructing a curve, or mathematical functions, which possess the closest proximity to the real series of…
14 Jul 2021 06:10 AM IST
Week 2 Air standard Cycle
AIM:To generate the PV diagram and to determine the thermal efficiency of the engine. The programming language used is Python THEORY: Otto Cycle is an idealized thermodynamic cycle that describes the working of a spark-ignition engine. The cycle consists of 4 processes as illustrated in the figure below: it consists…
12 Jul 2021 09:38 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.