Week 2- 2R Robotic Arm Challenge
close all
clear all
clc
% forward kinematics of Robotic Arm
%Inputs
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
l1 = 1 ;
l2 = 0.5;
% equations to be used for kinematic analysis
% X = 0;
%Y = 0;
%x1 = l1*cosd(THETA1);
%y1 = l1*sind(THETA1);
%x2 = x1 + l2*cosd(THETA2);
%Y2 = y1 + l2*sind(THETA2);
% we are using two 'for' loop here because we wants all possible positions
% of theta2 for one positions of theta1;
% for getting no of plots we have to write ct = 1 before starting loop
% and ct = ct +1 after plot command to get no of plots for different
% positions of theta;
ct = 1
for i = 1: length(theta1);
THETA1 = theta1(i);
for j = 1 : length(theta2);
THETA2 = theta2(j);
% we are defining our loops over entire length of theta by length command
% THETA1 and THETA2 are then calculated along the loop an we are using
% this values values in our equation;
x = 0;
y = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);
figure(ct);
hold on
plot([x x1],[y y1 ],[x1 x2],[y1 y2 ])
axis([-0.1 2 0 3]);
pause(0.3);
% with these programme i am able to get 100 plots for each and every
% combinations of robotic arm. now i wants to make a movie of this plots
% lets define M(ct) for getting movie of frames
M(ct) = getframe(gcf);
ct = ct +1
end
end
% now lets create videofile and write this frames in videofile to get
% movie of frames or plots.
videofile = VideoWriter('kinematics_of_robotic_arm.avi','Uncompressed AVI');
%I have just made a videofile and given name using VideoWriter command.
open(videofile);
writeVideo(videofile,M); % this command is for writing frames in videofile
close(videofile);
% now we have got video of different plots.
during this challenge i got some errors and screenshots for same are attached in this box . i have fixed all the errors by writing command properly.
in this error i have given bracket before then i corrected it

i have writter theta instead of theta1

I have written Movie(M) command so i was got this error but after removing Movie(M) command i got correct outputhttps://youtu.be/0e5YgjGxbaY
