2R Robotic Arm
Aim:-Program in Octave to simulate the forward kinematics of a 2R Robotic Arm.
Objective:- To illustrate workspace of robotic arm by forward kinematics of 2R robotic arm and create an animation.
Explaination of program:-
% forward kinematics of 2R robotic arm manipulator and its animation
clear all
close all
clc
% Input
l1=1;
l2=0.5;
theta1=linspace(0,90,10)% take 10 values of theta1 from 0 to 90 degree
theta2=linspace(0,90,10)% take 10 values of theta2 from 0 to 90 degree
%co-ordinates
f=1 % frame counter
%Running for loop for various values of theta2 for corresponding various values of theta1 and plotting graph for making frames for gif
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
%origin point
x0=0;
y0=0;
% coordinate point for end of link1
x1=l1*cosd(THETA1)
y1=l1*sind(THETA1)
% coordinate point for end of link2
x2=x1+l2*cosd(THETA2)
y2=y1+l2*sind(THETA2)
%ploting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
title('forward kinematics of 2R robotic arm manipulator')
axis([-0.2 2 0 2])
pause(0.02)
text=sprintf('output%d.png',f)
saveas(gca,text)
f=f+1
end
end
The given program uses different codes which are elaborated in subsequent lines.
In 2R robotic arm there are 2 links such as l1 and l2 which has length of 1m and 0.5m respectively.theta1 and theta2 are angle of link1 and 2 respectively.
for taking values of theta1 and theta2 I have used linspace command that obtain 10 equally space values from the given range(0 to 90degree). f is frame counter.
For generating graph I used for loop that first take first value of theta1 and stored it in THETA1 and then take corresponding value of theta2 that is stored in THETA2 then it proceed further.In following stage it take coordinate by the trigonometric formulas.
In subsequent step,plot command is used for generating graph of link 1 and 2 with line width value 3 and given title of forward kinematics of 2R robotic arm manipulator to the graph.
I got error in axis command because I forgotten to close the bracket but after seen that error I realise my error and make it correct in the given program.
Then, pause command is used for giving a pause to the link at particular point.sprintf is used to generate graph with the name output and stored it as image file and ending the program with ending loop.
Link of an animated video(output):-https://youtu.be/V937iEgce9Y
Output:-
Conclusion:-
From these I have generated graph and animation of workspace of 2R Robotic arm with help of Octave software.