forward kinematics of a 2R Robotic Arm
AIM:
- To stimulate the forward kinematics of a 2R Robotic Arm
OBJECTIVES OF THE PROJECT:
- The main objective of the project is to visualize the movement of 2-R Robotic arm in a plane which can be very useful in finding the precise points in a plane which can be reached by the arm.
BODY OF THE CONTENT:
clear
close all
clc
%% input parameters of the robotic arm
l1=8; %primary arm length
l2=5; %secondary arm length
p0=0; %base for the robaotic arm
%% constructing frames for diffrent angles of arms
ct=1;
for i=linspace(0,90,20) %for the primary arm
x1=l1*cosd(i);
y1=l1*sind(i);
for j=linspace(0,90,20) %for the secondary arm
x2=x1+l2*cosd(j);
y2=y1+l2*sind(j);
%plotting the arms
plot([p0 x1],[p0 y1],'b-','linewidth',2);
hold on
plot([x1 x2],[y1 y2],'r-','linewidth',2);
plot(x2,y2);
hold off
axis([0 15 0 15]);
grid on
xlabel('x');
ylabel('y');
legend('primary arm','seconadary arm')
pause(0.03);
movievector(ct)= getframe(gcf);
ct=ct+1
end
end
%% Saving the movie
kinematics = VideoWriter('Robotic Arm');
kinematics.FrameRate=10;
%opening the video writer object, write the movie, close it
open(kinematics);
writeVideo(kinematics,movievector);
close(kinematics);
- INPUT
- In the first part of the program taking the inputs for the lengths of primary secondary arm, as well as setting the base as the origin.
- CONSTRUCTING FRAMES
- Defining Ct which will be holding the capturing the frames the number of times the iteration occurs.
- Then the first for loop is for the primary arm motion and x1, y1 defining the end points of the arm.
- The second or the inner for loop is for the secondary motion of the arm whose starting points will be the end points of the first arm and x2,y2 defining the end points of that arm.
- (PLOTTING)
- Plotting the arms using hold on and hold off so that it should not overwrite the command of the 1st plot statement.
- Getting the frame using getframe command which is stored in the variable movievector.
- Some of the frames can be seen below.
- CREATING OBJECT
- Saving the object in the variable kinematics by the name of robotic arm (by default it will be save in the form .avi) using the command ‘ViedoWriter’, giving the fps of 10.
- OPENING THE ‘VideoWriter’ OBJECT, WRITING OVER IT,CLOSING IT
- After opening the VideoWriter object writeVideo command is used to write the frames saved in the movievector variable and than closing the object.
- A video link below which shows the simulation of the robotic arms.
- https://youtu.be/psjDfQ0t7Dc
CONCLUSION:
- The limitations of this project is that it is working in a single plane but not in 3-D it can be solved by considering the rotation of the arms in X-Z plane as well which will give a quite good overview on the arm.
- It can be done by giving the initial rotation to the arm in X-Z plane than plotting these arms in 3-d using the command ‘plot3’ and than stimulate it.