Challenge

2R Robotic Arm Challenge

Programm for 2R robotic arm

%forward kinematics of robotic arm using for loop

close all
clc
%inputs
l1=1;
l2=0.5;
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
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
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'LineWidth',3);
        axis([-0.1 1.5 0 1.5])
        pause(0.03)
        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)

You tube video link-https://youtu.be/Z_areCPesyI

Explanation:

Firstly i had specify the values of l1,l2

then by using linspace i had specified valus of theta1 and theta2 i.e. degree in between 0 to 90 and 10 values.

Then by using for loop i have calculated various values of THETA1 and THETA2

Then i have calculated various values of x1 x2 y1 y2

Then getting all these value i have plotted plot and created animation by taking a pause of 0.03

For getting various frames i have used getframe command

and after that I have created a movie by using VideoWriter.

Errors:

While completing this challenge I have faced lots of errors

Such as I have wrote THETA instead of THETA1 and THETA2.

Secondly I had not given space between [x0x1],[y0y1] etc.

third, I had used lowercase while writing word VideoWriter

Fourth I had missed to write ct=1

Steps taken to overcome the errors

I have eleminited above errors by

Writing THETA1 and THETA2

giving space in between [x0x1],[y0,y1]

writing proper word i.e. VideoWriter

Specifying value of ct.

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.