Challenge

Week 2- 2R Robotic Arm Challenge

https://drive.google.com/file/d/1-GcCwFRvbTAoJwIGBa2n4gyboFUC35D9/view?usp=sharing

clc
close all
l1=1;
l2=0.5;
theta1=linspace(0,75,10);
theta2=linspace(0,75,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);
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',5)
        axis([0 1.5 0 1.5])
        pause(0.03)
        M(ct)=getframe(gcf);
        ct=ct+1;
    end
end
movie(M)
videofile=VideoWriter('twor_robotic_arm.m','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)

    

AIM

To stimulate the forward kinematics of a 2R robotic arm.The objective here is to have multiple values of theta1 and theta2 and for each value of theta1 and theta2, we are going to make a plot and going to stick it all together and make an animation

GOVERNING EQUATION

x0=0

y0=0

x1=L1*cosd(THETA1)

y1=L1*sind(THETA1)

x2=x1+L2*cosd(THETA2)

y2=y1+L2*sind(THETA2)

CODE EXPLANATION

To stimulate the robotic arm, first we need to find the position of the links

Considering the base as (x0,y0)=(0,0),length of link1(l1=1)&link2(l2=0.5).theta1and theta2 are array of size [1*10].

To repeat the calculation for each value of theta1 and theta2 ,we use FOR LOOP.

As the value of “i” changes, we get the value from original array theta1 i:e if i=1 ,we assign the first value of array theta1 to the variable THETA1 and same for inner loop and assign the values to THETA2 until loop ends.

Here for each position of link1, the link2 takes multiple positions.Plot command is used to plot the frame. Axis is specified.

Command”pause” is used to pause each and every frame.counter is going to start with one, for each time for loop is getting executed I am incrementing counter by one.Ct represent each and every frame.

Save an individual frames in an array M.

command “getframe(gcf)” is for getting particular plot and save it in M.

Command “movie(M)” is to generate a movie with all frames.

And create a new AVI file to dump out all those frames.

Open the file and write the frames in Videofile.

CONCLUSION

So, we stimulate the robotic arm by using multiple values of THETA1 and THETA2

Attached the screenshots of error. i haven't typed the apostrophe for file name and a square bracket for plotting line command. Clear these errors by typing them.

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.