Challenge

Week 2- 2R Robotic Arm Challenge

FORWARD KINEMATICS OF A 2R ROBOTIC ARM

there are two arms ,so that we take it as L1 as first &L2 as second

L1 is of length 1 & L2 is of length 0.5

first we put L1 is making an angle 30degrees and L2 is making an angle 15degrees respectively.

lets get in to program,

providing inputs;

%inputs

l1=1;
l2=0.5;
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
x0=0;
y0=0;

x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);

x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);

lets get into programming,

this is the program made by me.

clear all
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([-.2 2 0 2]);
pause(.003)
ct=ct+1;
M(ct)=getframe(gcf);
    end
end

video(M)
videofile=videowriter('forward_kinematic.avi','uncompressed AVI')
open(videofile)
writevideo(videofile,M)
close(videofile)

starting with clear all,close all clc

providing inputs for suitable variables.

lispace is used to connect the series.

Both arm should travel 90 degrees to left with 10 equal intervals with respect to each other.

for loop is used in this program.the two arms should involve in th for loop,but in on loop its not possiblr,so we provide another loop for the second arm inside the first loop which is having first arm.

x0=0;
y0=0;

x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);

x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);

first point of arm 1 (x0,y0)is taken as (0,0)

x1 y1,x2 y2 is so calculated using simple trignometry.

next step is plotting .

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
axis([-.2 2 0 2]);
pause(.003)
ct=ct+1;
M(ct)=getframe(gcf);

ploting the two arms with line width 3,axis are arranged by first X parameter and then Y parameter.

setting a axis limit of x as -2 to 2 and y as 0 to 2

plot movement is paused in a timing .003

ct is counting as ct+1 ,so that it will add each steps to the last position of arm.

M is representing the code for movie.

M(ct)=getframe(gfc);

now we can end the for loop by end code twice,because two for loop is present.

video(M)
videofile=videowriter('forward_kinematic.avi','uncompressed AVI')
open(videofile)
writevideo(videofile,M)
close(videofile)

video file is set in this format.so as to open it in a suitable manner .

M is for 'movie'

AVI is video format.

step by step operation is written,open, then play(write),then close the video.

I am attaching the video of forward kinematics of robotic arm in this.

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.