Challenge

Week 2- 2R Robotic Arm Challenge

Aim - To write a program in matlab to simulate the forward kinematics of a 2R Robotic arm

Objective -

  • To write a program to simulate forward kinematics of a 2R robotic arm.
  • to create a animation /movie from the plots obtained from the programing.

CODE Explanation-

  1. starting the program using the comments.
  2. providing the input variable like, length /value of the robotic arm ,l1 & l2 .
  3. providing the value for theta 1& theta 2 using linspace command fir theta (0 to 90)for 10 values.
  4. providing the (ct) counter value.
  5. providing the coordinate x1,y1,x2,y2, of both robotic arms.providing the axis.
  6. using the pause command to make plot realistic.
  7. all figure assigned to a varible M
  8. using the movie command all the figure saved in the M file make an animation /movie.
  9. save the movie in the AVI format.


MATLAB PROGRAM CODE-

clear all 
close all
clc 
%inputs 
%length of first arm(m)
l1 = 1;
%length of second arm(m)
l2 = 0.5;
% angle of the first arm
theta1 = linspace(0,90,10);
% angle of the second arm
theta2 = linspace(0,90,10);

%initiate the counter value
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 = l2*sind(THETA1);

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

%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.06)
M(ct) = getframe(gcf);
ct=ct+1;
    end
end
%inserting frames in the animation to make movie

movie(M)
Videofile=VideoWriter('Robotic_arm.avi','Uncompressed AVI');
open(Videofile)
writeVideo(Videofile,M)
close(Videofile)

ERRORS -

unrecognized function of variable 'videowriter'

resolve this error again write the program coreect the 'VideoWriter'.


complete program screenshot-


RESULT - 2R robotic arm by using the matlab programing created a movie / animation from the plots obtained from program.

https://1drv.ms/u/s!Ao7kj2qrB8wAfmzhPWVG61qoxqI?e=O98wkY

https://1drv.ms/u/s!Ao7kj2qrB8wAfmzhPWVG61qoxqI?e=Kd2wfz
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.