All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Object: write a program in Matlab to simulate the forward kinematics of a 2R Robotic arm and Create an animation file of the plot Code: clear all close all clc %input l1=1; l2=0.5; theta1=linspace(0,90,10); theta2=linspace(0,90,10); ct=1; for i = 1:length(theta1) THETA1=theta1(i); for j=1:length(theta2) THETA2=theta2(j);…
KURUVA GUDISE KRISHNA MURHTY
updated on 07 Apr 2022
Object:
write a program in Matlab to simulate the forward kinematics of a 2R Robotic arm and Create an animation file of the plot
Code:
clear all
close all
clc
%input
l1=1;
l2=0.5;
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
ct=1;
for i = 1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
xo=0;
yo=0;
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%plotting
plot([xo x1],[yo y1],[x1 x2],[y1 y2],'LineWidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.03)
M(ct) = getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile = VideoWriter('forward_kinamatics.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Output:
Drive link:
https://drive.google.com/file/d/1NnKAzZ1C2-iwLIYbcolDlZ4S7bcADfAP/view?usp=sharing
Drive link:(screen record)
https://drive.google.com/file/d/1aZEeoM-LmhaaSCq-edr9t18HJxGU1KkC/view?usp=sharing
Youtube link:https://youtu.be/1vPoHKDF5nA
Report:
%Input
The length of the first arm is taken 1m, the length of the second arm is taken 0.5m, theta1 is the angle between the X-axis (Xo, Yō) to Y-axis (X1, Y1) of the first arm and theta2 is the angle between X-axis (X1, Y1) to Y-axis (X2, Y2).
Theta1 and Theta2 was taken in linspace of 0 to 90 differences of 10 that should be theta1 is linspace(0,90,10) and theta2 is linspace(0,90,10) and counter should be 1.
For loop
For statements loop a specific number of times and keep track of each iteration with an incrementing index variable.
Using for loop I should be taken as 1 to the length of theta1 that is THETA1= theta1(I) same as j=1 to a length of theta2 that is THETA2= theta2(j).
The starting point of the first arm is Xo, Yō and the ending point of the first arm is X1=length1*cosd(THETA1), Y1= length1*sind(THETA1), and the starting of the second arm X1=length1*cosd(THETA1), Y1= length1*sind(THETA1) and the ending point of second arm X2=X1+length2*cosd(THETA2), Y2=Y1+length2*sind(THETA2).
Plotting
Polt should represent the whole arm is as the plot ([Xo, X1], [Yo, Y1], [X1, X2], [Y1, Y2]) and the linewidth is 3.
Axes are taken as axis (-0.1 1.5 0 1.5), pause off 0.03 is slow down the speed of movement and the counter should be taken as CT=ct+1.
Creating the plot animation to use M(CT)= getframe(gcf) and the file should be saved as forward_kinematics.avi is as saved in video format
when I run the program I didn't face any errors in the program and the command window was showed an empty 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...
Project 1 : CFD Meshing for Tesla Cyber Truck
CFD Meshing for Tesla Cyber Truck Initial Model First of all…
09 Nov 2022 05:46 PM IST
Week 10 - Simulating Combustion of Natural Gas.
COMBUSTION Combustion is defined as a chemical reaction in which a hydrocarbon reacts with an oxidant to form products, accompanied by the release of energy in the form of heat. Combustion manifests as awode domain during the design, analysis, and performance characteristics stage by being an integral part of various…
08 Nov 2022 07:38 PM IST
Week 9 - Parametric study on Gate valve.
Theory: Introduction: Gate valves are designed for fully open or fully closed service. They are installed in pipelines as isolating valves and should not be used as control or regulating valves. Operation of a gate valve is performed doing an either clockwise to close (CTC) or clockwise…
07 Nov 2022 05:07 PM IST
Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
Angles to test: θ=100 θ=250 θ=450 Expected Results Validate Hydro-dynamic length with the numerical result Validate the fully developed flow velocity profile with its analytical profile Validate maximum velocity and pressured drop for fully developed flow Post-process Shear stress and validate…
06 Nov 2022 06:53 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.