%matlab code for kinematic forward kinematics of 2r robotic arm
clear all
close all
clc
%inputs taken
%arms lenghth in mm
arm1 = 1
arm2 = 2
%arm angle in degree
angle1 = linspace(0,90,10);
angle2 = linspace(0,90,10)
% counter for the program
ct =1
% operaating condition for the robotic arm
for i = 1: length (angle1)
ANGLE1 = angle1(i);
for j = 1:length(angle2)
ANGLE2 = angle2(j);
x0 = 0;
y0 = 0;
x1 =arm1*cosd(ANGLE1);
y1 =arm1*sind(ANGLE1);
x2 = arm1 + arm2*cosd(ANGLE2);
y2 = arm1 + arm2*sind(ANGLE2);
% the plotting of the robotic arm
plot([x0 x1],[y0 y1],[x1 x2], [y1 y2], 'linewidth',3,'color','r')
axis([-0.1 1.5 0 1.5])
pause(0.2)
M(ct) = getframe(gcf)
%counter incremented for each execution of the "for" loop
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter ('Forward_kinematics_roboticarm.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
report:
AIM
code for then working of the 2d robotic arm
theory:the robotic arm is dependent on the 2 angle and the length of the arm the motion is with changing with respect to the angle between the arms and the lenghth of the arm
Procedure:
1.lenght of the arms
arm1 = 1
arm2 = 2
2.angle of the arm
angle1 = linspace(0,90,10);
angle2 = linspace(0,90,10). linspce to create the spaced values.
3.ct =1
the count is set to one
4.the operating condition
for i = 1: length (angle1)
ANGLE1 = angle1(i);
for j = 1:length(angle2)
ANGLE2 = angle2(j);
5.the initial condiotion values.
x0 = 0;
y0 = 0;
6.the next conditions
x1 =arm1*cosd(ANGLE1);
y1 =arm1*sind(ANGLE1);
x2 = arm1 + arm2*cosd(ANGLE2);
y2 = arm1 + arm2*sind(ANGLE2);
7.to plot the points in the graph :
plot([x0 x1],[y0 y1],[x1 x2], [y1 y2], 'linewidth',3,'color','r')
axis([-0.1 1.5 0 1.5])
8.pause
The pause function also temporarily stops the execution
9.M(ct) = getframe(gcf)
getframe captures the current axes as it appears on the screen as a movie frame
10.the animation generator code:
movie(M)
videofile = VideoWriter ('Forward_kinematics_roboticarm.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)