Challenge

Week 2- 2R Robotic Arm Challenge

Aim - To write a program to simulate the forward kinematics of a 2R Robotic arm.

Objective -

1. To solve and simulate the forward kinematics of a 2R robotic arm and understand how to movement of manipulator.

2. Create the working animation of 2R robotic arm.

Theory - A robotic arm is a robot manipular, it’s programmable with similar functions of human arm. The likes of manipulator are connected with joints which allowing either rotational motion or translation (linear) displacement. The links of the manipulator cans be consider to form of kinematic chain.

  • In the image shown above, it have 4 components-
    1. The base, which is clamped to the surface and all other links are joined through hinge joint.
    2. Link 1 (L1) making θ1 with horizontal.
    3. Link 2 (L2) making θ2 with horizontal.
    4. The device attached to the manipulator which interacts with its environment to perform tasks is called the end-effector.
  • For our diagram we have assumed the length of link 1 and link 2 are 1 m and 0.5 m.

  • In order to simulate the robotic arm it’s necessary to vary theta1 and theta 2 to obtain a desired animation and it cannot be possible if we manually enter the respective data every time. So we have create a row vector from 0-90 digree with 10 evenly spaced joints between then.

  • The coordinates of base, I.e. is assumed to be at origin(0,0).

  • The coordinates of end point of link1 (L1) can be found by using trigonometry as,

    x1 = l1.cos(θ1) and y1 = l1.sin(θ1)

  • Similarly, the or ordinates of end point of link 2 (L2) are

    x2 = x1+l2.cos(θ2) and y2 = y1+l2.sin(θ2)

Code -

% Forward kinematic of robotic arm theta1 & theta2 have multiple values
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);
    % coordinate
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1+l2*cosd(THETA2);
y2 = y1+l2*sind(THETA2);

% plotting

hold on
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-1 1 0 1.5])
pause(0.1)
M(ct) = getframe(gcf);
ct = ct+1;
    end
end
movie(M)
videofile = VideoWriter('forward_kinematic_of_robotic_arm_theta_multiple_values.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

Results - The following plot obtained as 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.