Week 2- 2R Robotic Arm Challenge
Aim:- To write a program in MATLAB to simulate the forward kinematics of a 2R Robotic arm.
Introduction:- Robotic arm is a type of mechanical arm, usually programmable, with a similar function to a human arm, the arm may be the sum of the total mechanism or may be part of a more complex robot. the links of such a manipulator are connected by joints allowing rotational motion . Robotics is gaining tremendous importance for mechanical & automotive engineers in today's world. while designing a robot, the important step is to predict the required motion of the robot as per the desired application. this is very useful in complex operations such as the welding of complex frames. for this purpose, it is very important to learn the kinematics of links as the robotic arm is generally a mechanism that consists of multiple links.
Step1:- Clearing command windows and workspace closing all plots.
Step2:- Defining the length of both the links L1 &L2.
Step3:- Defining both angles (theta1 & theta2) which are changing from 0-90 in intervals by using the space command.
Step4:- Defining variables ct which will help create a movie of our plot.
Step5:- we want to create many plots for link1 concerning the different values of theta1, hence we are using for loop.
Step6:- Defining starting co-ordination of link 1.
Step7:- Calculating the coordination of the endpoint of link 1.
Step8:- We want 2 create many plots for link 2 concerning different values of theta2 hence we are using for loop.
Step9:- Calculating coordination of endpoint link 2.
Step10:- Plotting both the links concerning the corresponding value of theta1 & theta2.
Step11:- Defining limit or both axis.
Step12:- Pausing each plot for a certain time.
Step13:- Explanation of storing each other in array M.
Step14:- Explanation of creating and storing movies with the help of this program.
ERRORS - while executing problems
final program
%forward robotic arm 2
clear all
close all
clc
%inputs
l1=1;
l2=0.5;
theta1=linspace(0,90,4);
theta2=linspace(0,90,4);
ct=1
for i=1:length(theta1)
for j=1:length(theta2)
THETA1=theta1(i);
THETA2=theta2(j);
x0=0;
y0=0;
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
axis([-0.1 1.5 0 1.5]);
pause(0.3)
M(ct)=getframe(gcf);
ct =ct+1;
end
end
movie(M)
videofile=VideoWriter(' forward_kinematics.avi',' Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
MOVIE:-Animation
RESULTS:-
1) The animation shows the entire workspace of the 2R Robotic arm.
2) The constrained were achieved and can be observed in the animation.
youtube link :- https://youtu.be/HRMu93Ll7uk