Week 2- 2R Robotic Arm Challenge
Forward kinematics 2R Robotic Arm animation
Steps involved:
Inputs we given are L1,L2,theta1,theta2,ct.
In order to calculate the values we need to use forloop command.
After we got the values we need to plot the values.
To get the correct view we are starting the axis with -0.1 from x axis and y axis and need to pause the animation of about 0.5 sec.
We are storing all the values in an arrey that is 'm'.
Creating a movie with the values that are stored in 'm'.
Through the 'getframe' command we are creating the video frames.
Using linspace command arrey is formed.


ERRORS and solutions:
x1 y1 x2 y2 values are changed because of substituting theta instead of THETA so that the whole graph got different.
For plotting separate values we must use ([],...) this form.
After starting the forloop command inputs are unvalid so, Inputs must be given before starting the forloop command.
%forward kinematics of 2R robotic arm animation
close all
clear all
clc
%inputs
l1 = 3
l2 = 5
% theta
theta1 = linspace(0,90,5);
theta2 = linspace(0,90,5);
%for loop
ct = 1;
for i = 1:length(theta1)
THETA1 = theta1(i)
for j = 1:length(theta2)
THETA2 = theta2(j)
%coordinates
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 8,-0.1 8])
pause(0.5)
m(ct) = getframe(gcf)
ct = ct+1
end
end
movie(m)
videofile = VideoWriter('forward_kinematics_of_2r_robotic_arm_animation.avi','uncompressed AVI')
open(videofile)
writeVideo(videofile,m)
close(videofile)