Simulation of Robotic Arm using Octave
AIM: Write a program in Octave to simulate the forward kinematics of a 2R Robotic Arm Manipulator
OBJECTIVES:
- To simulate 2R Robotic Arm manipulator
- To understand different variation of second arm of manipulator with respect to first arm
- To make Animation of 2R Robotic Arm
THEORETICAL BACKGROUND:
A robotic arm is a type of mechanical arm, usually programmable, with similar functions to a human arm; the arm may be the sum total of the mechanism or may be part of a more complex robot. The links of such a manipulator are connected by joints allowing either rotational motion (such as in an articulated robot) or translational (linear) displacement. The links of the manipulator can be considered to form a kinematic chain. The terminus of the kinematic chain of the manipulator is called the end effector and it is analogous to the human hand.
Applications of robotic arm:
- We can used it to do welding operation.
- It is also used in material handling.
- It is used for thermal spraying
- It is used for painting purpose
- It is also used for some hazardous operation for worker like drilling where hot chips can injure worker.
PROBLEM:
Length of link_1 (L1) = 1 meters
Length of link_ 2 (L2) = 0.5 meters
Theta_1 (ϴ1) = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 }
Theta_2 (ϴ2) = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 }
Coordinates of link_1:
[ X0 , Y0 ] = [ 0, 0 ]
[ X1 , Y1 ] = [ L1*COSϴ1, L1*SINϴ1 ]
Coordinates of link_2:
[ X1 , Y1 ] = [ L1*COSϴ1, L1*SINϴ1 ]
[ X2 , Y2 ] = [ L1*COSϴ1 + L2*COSϴ2 , L1*SINϴ1 + L2*SINϴ2 ]
Main program:
Programming language used: High level Programming Language using Octave software
close all
clear all
clc
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);
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],'linewidth',3,'color','g',[x1 x2],[y1 y2],'linewidth',3,'color','r')
axis([-0.1 1.5 0 1.5])
pause(0.03)
text=sprintf("forward_kin_for%05d.png",ct);
saveas(1,text)
ct=ct+1;
end
end
Explanation:
- First, I have closed all file, clear all workspace
- After that I have defined length of link 1 and link 2
- After that I have defined different value of theta by using command linspace.
- Once I defined all constant and variables now, I am going to start my counter form 1 that’s why I defined ct =1.
- Now I want variation of second link with respect to first link position so we want variation ϴ2 with respect to ϴ1 so to do that we need to use nested for loop for that purpose.
- First for loop is going to run 10 times because length of theta1 is 10 and each time value is assigned to THETA1
- Second for loop is also going to run 10 times because length of theta2 is 10 and each time value is assigned to THETA2
- In second loop I have defined coordinates of link1 and link2
- After that I have plotted the link1 and link2 by using plot command
- Then I set my axis according to purpose or how we want it to vary
- As this code is going to run 100 times so we need to pause it to see variation of each combination of links so we have given a pause of 0.03
- Now I am going to give name to each figure window, as counter will change figure windows name is also going to change, and we need to print that name by using sprint command and I assigned it to text
- I have saved all figure window by using save as command ,to save each image, I have done increment in counter at end of loop.
COMMAND FOR ANIMATION:
EXPLANATION FOR ANIMATION IN OCTAVE:
- Run main program we will get 100 png files .
- Open command prompt, you will see working directory.
- To change directory use cd followed by directory of all png files.
- Once your directory changed, try checking files in that location by using dir and hit enter.
- Now use magick “*.png output.gif” command to get animation.
OUTPUT:
https://drive.google.com/open?id=1EIk9x5Jd4fjlJD8hiNhpzy13KADoOc7V
CONCLUSION:
We have understood different variation of Arm of 2R Robotic Arm manipulator and created code for this task where in we can see variation by varying value of ϴ1 and ϴ2 .
RESULT:
Simulation of kinematics of 2R Robotic Arm manipulator has been done successfully.