Week 2- 2R Robotic Arm Challenge
animation link:-
code:-
clear all
close all
clc
% inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,4);
theta2 = linspace(0,90,4);
ct=1
for i = 1:length(theta1)
THETA1 = theta1(i)
for j = 1:length(theta2)
THETA2 = theta2(j)
x0 = 0
y0 = 0
x1 = 0+l1*cosd(THETA1)
y1 = 0+l1*sind(THETA1)
x2 = x1+l2*cosd(THETA2)
y2 = y1+l2*sind(THETA2)
%plotting
figure(ct)
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-1 1.5 0 1.5])
pause (0.3)
M(ct) = getframe(gcf)
ct = ct+1
end
end
movie(M)
Videofile = VideoWriter('forward_kinematics avi','uncompressed avi');
open(Videofile)
writeVideo(Videofile,M)
close(Videofile)
Conclusion:-
The given 2R Robotic arm should be run at matlab succesfully;
Explanation:-
* It will be start at clear all close all and clc and also used as to clear tha editer window and commend window and work space
* Let tha assume tha input veriable of length1 and length2
*And it take tha theta1 and theta2 to used at linspace command
* Let counter can be assume ct = 1 and using for loop command
* The variable of i = 1:length of theta1 and variable of j = 1:length of theta2
* Let can assumed tha variable of THETA1 = theta1 of i and tha variable of THETA2 = theta2 of j
* It can provide tha point of x0 y0 x1 y1 x2 y2 in tha robotic arm
* In that points of x0 = 0, y0 = 0 , x1 = l1*cosd(THETA1),y1= l1*sind(THETA1) , x2 = x1+l2*cosd(THETA2) , y2 = y1+l2*sind(THETA2)
* Fainally make the plotting is that let can be plot of x0 y0 x1 y1 x2 y2 and tha linewidth of 3
* And we can assume tha axis of -1 1.5 0 1.5 and pause it at 0.3 and it run
* Further the use it on end command both of the for command
* A movie will be provide at using tha movie command
* The videofile is equal to the videowriter of forward kinematics avi and uncompressed avi
* Get tha movie frame to use tha open videofile and make tha writevideo of videofile and movie (M)
* Obviously close tha videofile and it run