Challenge

Week 2- 2R Robotic Arm Challenge

A program in Matlab to simulate the forward kinematics of a 2R Robotic Arm

Inputs:

l1- length of th arm1

l2- length of the arm2

thet1/theta1 - degree for arm1 movement

thet2/theta2- degree for arm2 movement

x1,y1 - coordinates for arm1

x2,y2- coordinates for arm2

Formula:

`x1=l1sin(theta1)`

`y1=l1cos(theta2)`

`x2=x1+l2sin(theta2)`

`y2=y1+l2cos(theta2)`

Program:

close all
clear all
clc

%inputs

l1=1;
l2=0.5;
thet1=linspace(0,30,10);
thet2=linspace(0,10,10);

ct=1;
% calculation 
for i=1:length(thet1);
    theta1=thet1(i);
    for j=1:length(thet2);
        theta2=thet2(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

% creating video file 

movie(m)
videofile=VideoWriter('robo.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,m)
close(videofile)

Output:

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.