Week 2- 2R Robotic Arm Challenge
AIM:
We aim to make a 'two arm robot' with the help of programming (MATLAB)
Formula:
LINSPACE:
Generate linearly spaced vector
LINSPACE(x1,x2,n)
FOR LOOP:
The formula 'FOR LOOP' is used.
in which 'FOR LOOP' to repeat spacified number of times
which is,
for i = value;
statements
end
PLOT COMMAND:
and that the formula 'plot' is used.
plot command is used got for final results, which is we look at 2D and 3D graphis.
Explain the code:
first
start the program at clear all, close all, clc,
then define all inputs,then use the formula of 'for loop' and define the all coordinates value
then plotting and define the 'x-axis and y-axis, title"getframe(gcf)"capture figure or axis as per movie frmae
write movie command and VideoWrite command with file name and uncompressed.avi for better quality
then open file, save file, and close file.
clear all
close all
clc
% Inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,8);
theta2 = linspace(0,90,8);
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
figure(1)
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',4)
axis([0 1.6 0 1.6])
xlabel('X axis')
ylabel('Y axis')
title('2R Robotic arm Manupulator')
pause(0.02);
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter('engine_kinematics.m','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
RESULTS:
Robotic Arm - link here
generated error-
this error was came.
solution-
because in 'movie' command 'M' was capital type, then again type of small 'm' in movie command