Challenge

Week 2- 2R Robotic Arm Challenge

Program to stimulate the forward kinematics of a 2R robotic arm.

Program - 1

the below program is substituted in program - 2 second loop.

% Program to stimulate the forward kinematics of 2R  robotic arm
% inputs
l1 = 1;
l2 = 0.5;

theta1 = 45;
theta2 = 30;

% link 1 origin points
x0 = 0;
y0 = 0;

% link 1-end oints
x1 = l1*cosd(theta1);
y1 = l1*sind(theta1);

% link 2-end points
x2 = x1+l2*cosd(theta2);
y2 = y1+l2*sind(theta2);

% figure
line([x0 x1],[y0 y1],'linewidth',3,'Color','b');
line([x1 x2],[y1 y2],'linewidth',3,'color','r');

The above program is used for forward kinematic of a 2R robotic arm.

Line command is used to figure the plot with two links.

Error - 1

Some of the errors which occurred during the operation of programming are,

The above error occurred due to invalid implementation of the command or mismatcing .

To overcome the error

To overcome error the mismatching command is replaced.

Error-2

The above error is occurred due to unrecognized function of x2.

The error can be eliminated by implementing the required function of x2.

Error-3

The above error occurred due to unrecognized function of theta.

The error can be eliminated by implementing the required function of theta.

Program - 2

%  Program to stimulate forward kinematics of a 2R robotic arm
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([-0.1 1.5 0 1.5]);
        pause(0.3)
        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)

In the above program by substituting the program - 1 in second loop by changing it's theta values from

theta1 = THETA1

theta2 = THETA2.

ct represents counter.

Ploting is done by arranging all link points in one line ,by this we can get forward kinematic robotic arm .

Axis is provided .

Two loops are used in the program - 2 in kinematic 2R robotic arm.

Because two links are present in 2R robotic arm.

Workspace - 1

The workspace provides all the values of output of the program.

Workspace - 2

the remaining output values are shown in the above workspace.

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.