|
% Program for 2R Robotic Arm
clear all
close all
clc
%Inputs
L1=1;
L2=0.5;
theta1=linspace (0,90,14);
theta2=linspace (0,90,14);
ct=1;
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
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',2);
axis([-0.1 1.5 0 1.5]);
pause (0.1)
M(ct)=getframe(gcf);
ct=ct+1;
end
end
movie(M)
Videofile=VideoWriter('Robotic_arm.avi','Uncompressed AVI');
open(Videofile)
writeVideo(Videofile,M)
|
- Used a programming language online Matlab
- Starting the program by using commands
- Providing an input variable like predetermining the length/values of the robotic arms.
- Adding the Cr (compression ratio) value as a specific digit.
- Calculating the position of Link-1. From the fixed Support, the initial value of X and Y for the Link-1 (X0, Y0) and the final value is (X1, Y1)
- Calculating the position of the Link-2. For Link-2 starting point is the Ending point if the Link-1 ie (X1, Y1) and the Ending point is (X2, Y2)
- Providing the values for theta1 and theta2 using the linspace command.where, theta = 0 to 90 degree for 14 values.
- Providing the equation for the x1,y1,x2, and y2 for defining the coordinates of both robotic arms.
- Providing the axis number and plotting all coordinate values.
- All figures are assigned to a variable M_, one at a time using compression ratio.
- Use the pause command to make the plot authentic look.
- Ended the 'for' loop twice.
- using the movie command to combine all the plotted images saved in the M_ file to create a movie.
- Finally, the movie is saved in the .avi format.
|