Challenge

Week 2- 2R Robotic Arm Challenge

clear all
close all
clc

% Inputs 

l1= 1;
l2= 0.5;

theta1= linspace(0,90,20);
theta2= linspace(0,90,20);
mm= 1;

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

% Coordinates
x0= 0;
y0= 0;

x1= l1*cosd(THETA1);
y1= l1*sind(THETA1);

x2= x1+l2*cosd(THETA2);
y2= y1+l2*sind(THETA2);

% Plotting
plot([x0 x1],[y0 y1],'m','LineWidth',3)
hold on
plot([x1 x2],[y1 y2],'k','linewidth',2)
axis([-0.2 1.5 0 1.5])
pause(0.1)
hold off
S(mm)= getframe(gcf);
mm= mm+1;
end
end
movie(S)
videofile= VideoWriter('forward_kinematics_2r.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,S)
close(videofile)
  • The main objective of the challenge is to simulate forward kinematics of a 2R robitic arm manipulator.
  • The google drive video link for the plot : https://drive.google.com/file/d/1FXXj5RUpTyAKwnzBlrX5E7ze8VHdRbFb/view?usp=sharing
  1. I have given the following inputs [length of links (l1),(l2) and Angle of robotic arms(theta1,theta2)].
  2. In this program 'for loops' are used to change the angle and coordinates of the robotic arms.
  3. Ploted the the coordinates of two robotic arms using "hold on", "hold off", and "pause" commands to create the animated plot.

plot([x0 x1],[y0 y1],'m','LineWidth',3)
hold on
plot([x1 x2],[y1 y2],'k','linewidth',2)
axis([-0.2 1.5 0 1.5])
pause(0.1)
hold off

4.We can see the angle and coordinate changes of the two arm robotic manipulator in the form of animation in a output plot.

5.The animation of robotic arm is saved in a movie format with the help of following commands.

movie(S)
videofile= VideoWriter('forward_kinematics_2r.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,S)
close(videofile)

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.