Project

FORWARD KINEMATICS OF A ROBOTIC ARM

Aim of the project: To simulate the forward kinematics of a 2R Robotic Arm

Description : Assuming a Robot having a joint with two links and the motion of the two links is coded in matlab and animated as shown in the link below.

Initially, when i is given a value, for the same value j has 10 values which conveys the meaning of first and second arm respectively.

Code:

%Forward kinematics of a 2R Robotic manipulator
%Initializing angle Parameters
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);

%Assigning values for the lenths of the both arms
l1 = 1; %length of the first arm
l2 = 0.5; %length of the second arm
ct = 1;

for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);

x0 = 0; %Initial coordinates
y0 = 0;

x1 = l1*cosd(THETA1); %Final coordinates of first arm
y1 = l1*sind(THETA1);

x2 = x1 + l2*cosd(THETA2); %Final coordinates of second arm
y2 = y1 + l2*sind(THETA2);


plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3) %Plot between both the arms with the assumed coordiinates
axis([-0.1 1.5 0 1.5]) %axis assumed from minimum to maximum
pause(0.3)
M(ct) = getframe(gcf);
ct = ct + 1;
end
end

movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI'); %opened a videofile in the required format
open(videofile) %opening videofile for animation
writeVideo(videofile,M) %writing the video to the output into this
close(videofile) %closing videofile

video link: https://youtu.be/mCwBpXLKtLA

Errors faced during the code:

*M in Movie is case-sensitive

*for loop format is wrong

Screenshots of my errors:

Overcoming the errors:

As per the error shown in the command window, With the line number and the sense of the error I could find the error easily and could rectify it. I appreciate matlab for this versatilt design and making easy and conforttable for the users.

Results:

In the first for loop, for every angle of i, there will be different variations from 10 to 90 in second angle.

The written code and the arm movement is recorded as animation and attached above.

Pause time can be varied to speed up and down the animation.

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.