Challenge

Forward Kinematics of Robotic Arms

Forward Kinematics of Robotic Arms

1. Objective:

To write a program in MATLAB that solves forward kinematics of a 2R robotic arm. And, also to simulate the behavior of the arm at different angles.

2.Steps followed while coding :

  • The length of the two arms is 1 and 0.5 respectively.
  • Two arms will be simulated at different angles.
  • Creating a loop that will calculate the number of angle arm-1.
  • Creating a loop that will calculate the number angle position possible for arm-2.
  • Calculating the different positions of two arms in respect to a given angle.
  • Plot the two arms in a figure for different angles.
  • Creating animation for two arms with respect to different angles and positions.

3.Errors while coding:

There was an error when I’m trying to run the program, then later I found out Matlab use a case-sensitive programming language. Then changing "videowriter" to "VideoWriter" have solved the problem.

4.Result:

The resulting animation shows that arm-1 will be fixed at one end and another end that is connected to arm-2 will have a motion with the given angle value at a different position. And the arm-2 will be moving at a different position with the given angle with respect to arm-1.

Video Link- https://drive.google.com/file/d/1avYetF5S6L1zclrydxTFxeu79STI920U/view?usp=sharing

5.MATLAB Code:

close all
clear all
clc

l1=1;
l2=.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);

   % Starting Postition of Arm1

    x0=0;
    y0=0;

    % End position of Arm1
    x1= l1*cosd(Theta1);
    y1=l1*sind(Theta1);

    % Starting position of arm2

    x2= l1+cosd(Theta2);
    y2=l1+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

movie(M)
videofile=VideoWriter('forward_kinematics.avi','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.