Project

2D ROBOTIC ARM SIMULATION - MATLAB

A Robotic arm of a 2 link member in a 2 dimensional manner is simulated to generate the positions of the 2 links at different positons in a graph(2D)

here in the simulation we could able to observe the different position of the robotic arm at different time levels and all its possible movements.A animation is created via.MATLAB for the movement analysis of arm. In this description the MATLAB code and the animation link of the robotic arm is attached.Further any changes can also be made to acquire more accurate movements or even another link can be added.

animation link:https://youtu.be/dGhpIghVMQA

clear all
close all
clc

%inputs
%length_is_in_metres
l1=1;
l2=0.8;

%angle_of_arms
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);

%temp
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));
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2]);
        axis([-0.1 2 0 2])
        pause(0.01);
        M(ct)=getframe(gcf)
        ct=ct+1;
    end
end

%movie_creating_file

movie(M);
videofile=VideoWriter('robotic_car_own.avi','uncompressed AVI');
open(videofile);
writeVideo(videofile,M);
close(videofile);

%enjoy_your_animation

ROBOTIC ARM ANIMATION:

clear all

close all

clc

  • To clear the previous code statements, so that to prevent the execution of these old statement in the present codes.

%inputs

%length_is_in_metres

l1=1;

l2=0.8;

%angle_of_arms

theta1=linspace(0,90,10);

theta2=linspace(0,90,10);

  • These are the inputs for the coding. L1 & L2 are the length of the two members which forms the arm. Theta 1 & Theta 2 are the angles of each member.

%temp

ct=1

  • This is a temporary variable. This is use in the looping system.

for i=1:length(theta1)

THETA1= theta1(i);

  • This is the main loop in which the first member changes its position.

for j=1:length(theta2)

THETA2=theta2(j);

  • This is the sub loop in which the second member changes its position for each change in position of the first member.

x0=0;

y0=0;

  • Initial conditions of the robotic arm.

x1 = l1.*cosd(THETA1);

y1 = l1.*sind(THETA1);

x2 = x1 + (l2.*cosd(THETA2));

y2 = y1 + (l2.*sind(THETA2));

  • These equations determine the position of the arm at each different angles.

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2]);

axis([-0.1 2 0 2])

  • A graph is plotted with the given axis.

pause(0.01);

  • Each graph skips at a rate 0.01 seconds.

M(ct)=getframe(gcf)

  • Gets every current frame(graph) and stores it in the ‘M’.

ct=ct+1;

end

end

%movie_creating_file

movie(M);

videofile=VideoWriter('robotic_car_own.avi','uncompressed AVI');

open(videofile);

writeVideo(videofile,M);

close(videofile);

  • Creates a movie file with the extension .avi and it is a uncompressed avi and opens the videofile and writes the videofile and closes it.

%enjoy_your_animation

  • The file is stored in the directory where the code is stored. click on the animation and enjoy.

ERRORS:

  • The one important error that appeared was the typographical errors , that was later identified and corrected from the video.

A screenshot representing the program execution.

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.