Challenge

Week 2- 2R Robotic Arm Challenge

Aim: To write a program and calculate the final position of the robot arms/manipulator l1 and l2 given their Matlab to simulate the arm angles θ¹ and θ²

Method: Using for loop for θ¹ and θ² and capture video frames of the robot manipulator's position from rest. When at rest the arms are horizontal to the Xaxis i.e θ¹ and θ² are zero. In the program the final θ¹ and θ² are 60 and 75degrees resp.

PROGRAM

clear all
clc

%Robot is postioned at (x=0,y=0.1)
x0=0;
y0=0.15;
axis ([-1 4 0 4])

% l1 and l2 are length (m) of first and second link respectively
l1=1.75;
l2=1;

%theta1 and theta2 are angles of the arms w.r.t the horizonatal plane or x-axis

theta1= linspace(0,60,15);
theta2= linspace(0,75,15);


ct=1;
for i=1:length(theta1)
Theta1=theta1(i);

for j=1:length(theta2)
Theta2=theta2(j);

%fix axis

axis ([-1 4 0 4])


%Coordinates of robot arm joint with l1 and l2:
x1=l1*cosd(Theta1);
y1=l1*sind(Theta1);

%Coordinates of robot arm manipulator tip
x2=x1+l2*cosd(Theta2);
y2=y1+l2*sind(Theta2);

%Plotting the robot arms and manipulator:
figure (ct)
%plot arm1
hold on

%Robot has a half circle base for aesthetic pupose
r = .3;
semicrc = r.*[cos(0:0.1:pi); sin(0:0.1:pi)];
area(semicrc(1,:), semicrc(2,:), 'FaceColor','b')

%plot arm1
plot([x0,x1],[y0,y1],'linewidth',15,'color', 'b');


%plot arm2
plot([x1,x2],[y1,y2],'linewidth',7,'color', 'r');
axis ([-1 4 0 4])


%Arm joint
plot(x1,y1, '.b', 'MarkerSize',69);

%frame speed

pause(.03)

%video capturing

M(ct)= getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile = VideoWriter('Robot_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

OUTPUT:

Output: (Youtube link: https://youtu.be/xnU6WmUpZdo)

Conclusion: Using for loop, simulation of robot manipulator helps in extrapolating the coordinates the arms x0y0, x1,y2 corresponding to the arm angles theta1 and theta 2.

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.