Challenge

Week 2- 2R Robotic Arm Challenge

%forward kinematics of 2d robot
close all
clear all
clc
%inputs for arms
L1=1; %length of arm 1
L2=0.5;%length of arm 2
theata1=linspace(0,90,8); %dividing theata1 from 0-90 into 8 equal parts
theata2=linspace(0,90,4);%dividing theata2 from 0-90 into 4 equal parts
ct=1; %initializing count to 1
for i=1:length(theata1)
THEATA1=theata1(i) %getting THEATA1 value
for j=1:length(theata2)
THEATA2=theata2(j)%getting THEATA2 value for the respective value of THEATA 1
x0=0; %initializing initial coordiantes
y0=0;%initializing initial coordiantes
x1=L1*cosd(THEATA1)%initializing coordiantes at point 1 i.e inbetween joint of arm 1 and 2
y1=L1*sind(THEATA1)%initializing coordiantes at point 1 i.e inbetween joint of arm 1 and 2
x2=x1+L2*cosd(THEATA2)%initializing coordiantes at point 2 i.e end point of arm 2
y2=y1+L2*sind(THEATA2)%initializing coordiantes at point 2 i.e end point of arm 2
%plotting
figure(ct)
hold on
plot([x0 x1],[y0 y1],'linewidth',3,'color','r')
plot([x1 x2],[y1 y2],'linewidth',3,'color','g')
axis([-1 1 0 1.5])
pause(0.8)
xlabel('x axis')
ylabel('y axis')
grid on
M(ct)=getframe(gcf) %getting frame and storing the same in M
ct=ct+1 %incrementing the count for the next frame

end
end
movie(M) %creating the movie from frames
videofile=VideoWriter('2drobot.avi','uncompressed AVI'); % giving movie a name i.e 2drobot in avi format which must be uncompressed
open(videofile);
writeVideo(videofile,M);
close(videofile);https://drive.google.com/file/d/1RbKcnQ9Y0IDwh02kh8fmadm4wm6EnOEg/view?usp=sharing

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.