Project

Robotic arm animation using Octave

Introduction:

Mechanical robots are essentially open ended linkages where the input torque or force to one of the link will drive motion through a linkage. A bucket or a hand attached at the end of the linkage is used to achieve various tasks such as picking simple objects and placing them in some other coordinates defined in the code.

In order to achieve this, forward kinematics which is determining the target coordinates based on input parameters such as angle of rotation, input link length is essential and the most basic step in coding the working of a simple robotic arm.

In the code, robotic arm consists of two links. Length of link is measured and specified in the code, angle of rotation is fed as an array to vary in both the links with reference to grounded link. A nested for loop is constructed to determine the end coordinates (x2,y2) with reference to the origin based on the input parameters. The results are plotted and each frame is saved as a image file to generate the animated video out of it.

Octave code:

%This is coded by Sweekar, contact [email protected]
%Finding the location in space is the most basic step in programming te mechanical robots
%This is the program to simulate forward kinematics motion of robotic arm
%It consists of two links and moves over the range of degrees
%clean up
close all
clear all
clc

%inputs
l1 = 1; % length of link 1
l2 = 0.5; %length of link 2
theta1 =linspace(0,90,6);
theta2 =linspace(0,360,16);

%base frame coordiantes
x0 = 0;
y0 = 0;

%Loop to capture the motion of the robotic arm
ct=1;
for i=1:length(theta1)
  THETA1 = theta1(i);
  for j=1:length(theta2)
    THETA2 = theta2(j);
    x1 = l1*cosd(THETA1); %coordinates at point x1
    y1 = l1*sind(THETA1); %coordinates at point y1
    x2 = x1+l2*cosd(THETA2); %coordinates at end locator x2
    y2 = y1+l2*sind(THETA2); % coordinates at end locator y2

 %plotting the coordiantes
    plot(0,0,'.','markersize',30,'color','black',[x0,x1],[y0,y1],'linewidth',3,'color','r',[x1,x2],[y1,y2],'linewidth',3,'color','b',x2,y2,'p','linewidth',20,'color','g')
    axis([-2 2 -2 2])
    title('Forward kinematics of Robotic arm')
    xlabel('Coordinates for movement in horizontal direction')
    ylabel('Coordinates for movement in vertical direction')
    grid on
    pause(0.0003)
    %M(ct) = saveas(1,Text) %for coding in matlab
    Anime = sprintf("Robotarm%d.png",ct)
    saveas(1,Anime)
    ct=ct+1;
   end
end
%For coding in Matlab
%Movie(M);
%videofile = VideoWriter('forward_kin.avi');
%open(videofile);
%writeVideo(videofile,M)
%close(videofile);

%For octave video has to be made from .png files outside Octave

Results:

Animated video Link: https://youtu.be/uu3GMPn_6qM

Discussion on Results and report

1) The link to animated video can be found in the following location https://youtu.be/uu3GMPn_6qM

2) Array of angle and length of link could be effectively varied to produce relatively different motions to achieve various objectives

3) Locating the end effector coordinates is the most basic step required to achieve the robotic arm movement.

4) Many applications such as Pick and Place, Assembly robots could be built based on this logic

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.