Challenge

Week 2- 2R Robotic Arm Challenge

Program explanation-

clear all, close all, clc for clearing previous commands etc.

1) take inputs when theta1 and theta2 are known with length of links we can calculate the position of robotic arm using matlab

so lets take theta1 and theta2 are starts from 0 degree to 90 degree with 30 interval values.

2) lests assume we have 4m long link1 and 3m long link2.

3) takes a cordinates we know links1 starts at fixed base so here cordnates are (x0=0, y0=0) now to calculate next coedinates which are (x1,x2,y1,y2) we need touse for loop to take geometry calculations.by applying simple geometry we can calculate a remaining coordinates using theta. we get

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

4) to plot a graph use plot command and fill cordinates, linewidth and color for better visualization

5) give axis and grids to plot

6) now using getframe we can captured frames and put in a loop so we use ct basically here we stop the programme at each frame.

7) here our for loop end which applied for caluclating remaining coordnates.

8) to generate animated movie use movie(m) code

9)noe generete video file using videofile =(videowriter) give specific name and make it uncmpresse for clear visualization

10) now write video file is hard disk and close video file to back to codes

done....

link is below

forward kinematic robotic arm

or

https://youtu.be/HNmXthKi08Y

% forward kinemartics of robotic arm using matlab


clear all 
close all 
clc


% inputs

theta1 = linspace(0,90,30);
theta2 = linspace(0,90,30);

l1 = 4; % length of 1st link
l2 = 3; % length of 2nd link

% use for loop

ct = 1; %counter

for i = 1:length(theta1)
    THETA1  = theta1(i);
    for j = 1:length(theta2)
        THETA2 = theta2(j);

       % input coordinates
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);


% plotiing

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
grid on
axis([-0.1 9 -0.1 9])
pause(0.03)
m(ct) = getframe(gcf);
ct = ct+1;

    end
end

% creating animation

movie(m)
videofile = VideoWriter('forward_kinematics_of_robotic_arm','Uncompressed AVI');
open(videofile)
writeVideo(videofile,m)
close(videofile)
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.