Challenge

Week 2- 2R Robotic Arm Challenge

AIM:

To simulate the forward kinematics of a 2R Robotic arm using MATLAB Program.

Introduction:

In the robotic field of kinematics, the robot is an essential part by which we can program & simulate how a robot will move. by simulation, we can figure out the workspace of the robot for design.

In Industries like automobiles, aviation the manufacturing layout are designed with automation for doing matching, assembly & painting. so using MATLAB Software we can calibrate the work space & robotic arm movements etc.

GOVERNING EQUATION:

The equation for calculating coordinates of link starting & ending points.

As per the image we are considering l1 = 100mm & l2 = 50mm length arm with respect to horizontal axis respectively.

coordinates of Link1:

starting point = [X0,Y0] = [0,0]

Ending point = [X1,Y1] = [`l1cosd theta_1,l1sind theta_1`]

coordinates of link2:

starting point = [X1,Y1] = [`l1cosd theta_1,l1sind theta_1`]

Ending point = [X2,Y2] = [`l2cosd theta_2,l2sind theta_2`]

Objective:

We will take multiple values of θ1 range of 0 to 120 degree & θ2 range of 0 to 90 degree the value of the arm movement is plotted. noting the values of the coordinates.

By the end examining the animation we are able to study the workspace motion involved in the cycle of the robotic arm.

Program:

clear all
close all
clc

% input
l1 = 100;
l2 = 30;
theta1 = linspace(0,120,10);
theta2 = linspace(0,90,6);

loop_counter = 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 = l2*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([-65 130 0 130])

    title('Kinematics of 2R Robotic arm')
    
    xlabel('arm movement in x-axis');
    
    ylabel('arm movement in y-axis');
    grid on
    pause(0.7)

    m(loop_counter) = getframe(gcf)
    loop_counter = loop_counter+1
  
end
end

movie(m)
videofile = VideoWriter('arm_movement.mp4','Uncompressed AVI');
open(videofile)
writeVideo(videofile,m)
close(videofile)

l1 is the length of link 1

l2 is the length of link 2

theta 1 represents the 10 values ranging from 0 to 120 degree using linspace command

theta 2 represents the 6 values ranging from 0 to 90 degree using linspace command

; is used to avoid printing the values in command window.

ct = 1indicates the loop execution.

for i = 1:length(theta1)
The for loop i represents the counter from 1 to 10 numbers in the range of 0 to 120 degree.
THETA1 = theta1(i)

THETA1 is a variable (contains one variable) but theta1(i) is an array (contains 10 values). i represents the loop count

for j = 1:length(theta2)
The for loop j represents the counter from 1 to 4 numbers in the range of 0 to 90 degrees.
THETA2 = theta2(i)
THETA2 is a variable (contains one variable) but theta2(j) is an array (contains 4 values). j represents the loop count.
we used two-loop because theta1 has 10 counts depending on 'i' but theta2 has 6 counts depending on 'j'.
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l2*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);
Then we used the point equation to find the points of (X1,Y1) & (X2,Y2).
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
By this command, we can plot the point in the graph
axis([-65 130 0 130])
By this command, we can focus the graph in the particular area.
title('Kinematics of 2R Robotic arm')
xlabel('arm movement in x-axis');
ylabel('arm movement in y-axis');
This command is used to specify the title , x-axis , Y-axis name in the chart.
grid on
pause(0.7)
pause the frame of figure for 0.7 seconds.
m(loop_counter) = getframe(gcf)
loop_counter = loop_counter+1
Increment for loop execution.
Errors:
Program 1:
I forgot to add the length in the end limit. so the program doesn't know the end limit values
Program 2
In 40 line I used small letter 'm'. But 45 line I used Capital letter 'M'.
Output:
After generating the animation file I uploaded the video to youtube.
Conclusion:
  • After generating animation by examining closely we can understand the workspace of the Robotic arm.
  • By changing the length & angle of the robotic arm we can exactly know the position at a different angle.
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.