Challenge

Week 2- 2R Robotic Arm Challenge

Aim: Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm.

Objectives :

  • Create an animation file of the plot.
    • provide the google drive link.

Program :

close all
clear all
clc

%input parameters
l_1=1;
l_2=0.5;

%equation for theta_1 & theta_2
theta_1=linspace(0,90,20);
theta_2=linspace(0,90,20);
ct=1;

%for loop
for i=1:length(theta_1)
    theta1=theta_1(i);
    for j=1:length(theta_2)
        theta2=theta_2(j);
    x_0=0;
    y_0=0;
    x_1=l_1*cosd(theta1);
    y_1=l_1*sind(theta1);
    x_2=x_1+l_2*cosd(theta2);
    y_2=y_1+l_2*sind(theta2);
    
    %plotting
    plot([x_0 x_1],[y_0 y_1], [x_1 x_2], [y_1 y_2],'linewidth',3)
    axis([-0.2 3 0 3])
    pause(0.1)
    M(ct)=getframe(gcf);
    ct=ct+1;
    
    end
end

%Recording the video
movie(M)
videofile=VideoWriter('Robotic_arm.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

Results:

https://drive.google.com/file/d/1y5S34KvAQVdVQc0Hbjnr9T2xQ5ZvWVkk/view?usp=sharing

The movement of a robotic arm is programmed with help of matlab codes and the result is displayed as a video, whose link is shared above.

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.