Placement 2025 Scholarship: Your Future Starts Here | 6 Guaranteed Job Interviews | Limited to 100 seats. Apply Now

00D 00H 00M 00S

Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Placements

Student Reviews


For Business


More

Academic Training

Informative Articles

Find Jobs

We are Hiring!


All Courses

Choose a category

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

All Courses

All Courses

logo

CHOOSE A CATEGORY

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

Top Job Leading Courses

Automotive

CFD

FEA

Design

MBD

Med Tech

Courses by Software

Design

Solver

Automation

Vehicle Dynamics

CFD Solver

Preprocessor

Courses by Semester

First Year

Second Year

Third Year

Fourth Year

Courses by Domain

Automotive

CFD

Design

FEA

Tool-focused Courses

Design

Solver

Automation

Preprocessor

CFD Solver

Vehicle Dynamics

Machine learning

Machine Learning and AI

POPULAR COURSES

coursePost Graduate Program in Hybrid Electric Vehicle Design and Analysis
coursePost Graduate Program in Computational Fluid Dynamics
coursePost Graduate Program in CAD
coursePost Graduate Program in CAE
coursePost Graduate Program in Manufacturing Design
coursePost Graduate Program in Computational Design and Pre-processing
coursePost Graduate Program in Complete Passenger Car Design & Product Development
Executive Programs
Workshops
For Business

Success Stories

Placements

Student Reviews

More

Projects

Blogs

Academic Training

Find Jobs

Informative Articles

We're Hiring!

phone+91 9342691281Log in
  1. Home/
  2. Shaik Faraz/
  3. Week 2- 2R Robotic Arm Challenge

Week 2- 2R Robotic Arm Challenge

Aim: Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm, as shown in the video.  Create an animation file of the plot. What is forward kinematics ? Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end-effector from specified…

    • Shaik Faraz

      updated on 14 Apr 2022

    Aim:

    Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm, as shown in the video. 

    • Create an animation file of the plot.

    What is forward kinematics ?

    Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end-effector from specified values for the joint parameters.

    The kinematics equations of the robot are used in robotics, computer games and animation. The reverse process that computes the joint parameters that achieve a specified position of the end-effector is known as inverse kinematics.

    Here we have to create a program to simulate the forward kinematics of a 2R Robotic Arm, where 2R refers to 2 rotating links.

    Theory:

                                      forward kinematics of a 2R Robotic Arm

    Here a schematic representation of robotic arm with 2 links of length l1 and l2 is given

    And the angles of both links l1 and l2 are known theta1 and theta 2 respectively

    There two steps to find the position of links

    Step 1

    Two end points

    1. one at the base   ==> (x0,y0)
    2. one joining the link2    ==> (x1,y1)

    Coordinates

    1. (x0,y0) = (0,0)
    2. (x1,y1) = (l1*cos(theta1), l1*sin(theta1))

    Step 2

    Two end points

    1. one joining the link2   ==> (x1,y1)
    2. one joining the manipulator    ==> (x2,y2)

    Coordinates

    1. (x1,y1) = (l1*cos(theta1), l1*sin(theta1))
    2. (x2,y2) = (x1+l2*cos(theta2), y1+l2*sin(theta2))

    Now we have all 3 Co-ordinates

    (x0,y0) (x1,y1) (x2,y2)

     

                                 ##   Code for simulating the Forward Kinematics of a 2R Robotic Arm   ##

     

    % Code for the Forward Kynamatics of a Robotic Arm Animation
    clear all
    close all
    clc
    
    % Inputs
     
    % Let the length of the link arms be 
    l1 =3;
    l2 =2;
    
    % Both link arms rotate upto 90 degree hence the angle of the links are 0 to 90 degree
    theta1 = linspace(0,90,10);
    theta2 = linspace(0,90,10);​
     
    Forward Kinematics of a 2R Robotic Arm code1
     
    % Adding the counter (ct) for the for loop so thet we can get all the frames of plot
    ct = 1;
     
    % give the range of angles for link 1
    % give the range of angles for link 2
    for i = 1:length(theta1)
    THETA1 = theta1(i);
    for j = 1:length(theta2)
    THETA2 = theta2(j);​
     
    % Give the coordinates for node (x0,y0)
    % Give the coordinates for node (x1,y1)
    % Give the coordinates for node (x2,y2)
    x0 = 0;
    y0 = 0;
    x1 = l1*cosd(THETA1);
    y1 = l1*sind(THETA1);
    x2 = x1 + l2*cosd(THETA2);
    y2 = y1 + l2*sind(THETA2);​
     
    % Graph
    % plot graph with the coordinates
    % specify axis length
    % use pause to get a smooth animation
    % use getframe to store the plot frames in a variable (M)
    % make the counter ct to advance in for loop
    plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],LineWidth=3,Marker="o")
    axis([-1 6 -1 6])
    pause(0.002)
    M(ct) = getframe(gcf);
    ct = ct+1;​
     
    % End the loop
    end
    end
    
    Forward Kinematics of a 2R Robotic Arm code2
     
    % Make a animated moveiof the frames inside of M using movie
    % Use VideoWriter to creat a video file in avi formate
    % open videofile
    % write/insert the frames of M in videofile
    % close videofile
    movie(M)
    videofile_robtic_arm = VideoWriter('videofile_robotic_arm.avi','Uncompressed AVI');
    open(videofile_robtic_arm)
    writeVideo(videofile_robtic_arm,M)
    close(videofile_robtic_arm)​
     
    Forward Kinematics of a 2R Robotic Arm code3
     
     
    Result:
     
    We get an smooth animated video of simulation the Forward Kinematics of a 2R Robotic Arm
    youtube link is given below for the video
    https://youtu.be/JdzZzEK61FE
     
    Errors faced:
     
    1. For theta the cos and sin are calculated in radian by defaut. So, we should use cosd(theta) for code so that we can get values in degrees
     
    2. VideoWriter, writeVideo, etc commands are all case sensitive. Use the correct syntax and letters
     
    Errors in code
     
    Youtube link for the video :https://youtu.be/JdzZzEK61FE
     

    Leave a comment

    Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.

    Please  login to add a comment

    Other comments...

    No comments yet!
    Be the first to add a comment

    Read more Projects by Shaik Faraz (27)

    Project 1 : CFD Meshing for Tesla Cyber Truck

    Objective:

    Aim: Performing topological cleanup and surface mesh on tesla cyber truck and on a wind tunnel based on selected target length values of its different components using element type as Tria, as well as appropriate selection of the volume that contains the vehicle and its surroundings with the wind tunnel for volumetric…

    calendar

    15 Nov 2022 04:17 AM IST

    • ANSA
    • CFD
    Read more

    Week 5 Challenge : Surface wrap on Automotive Assembly

    Objective:

    Aim: Perforform Topo cleanup and delete unwanted surfaces for Surface wrap. After Topo cleanup, Merge all 3 models and perform surface wrap. Target length for Wrap = 3 mm   1. Engine:    2. Gear box:   3. Transmission:   Procedure: 1. Topo Cleanup : (Engine, Transmission & Gear Box)…

    calendar

    10 Nov 2022 08:22 AM IST

      Read more

      Week 4 Challenge : CFD Meshing for BMW car

      Objective:

      Aim: To perform topological clean-up, and carry out the surface meshing of a BMW M6 car model and create a wind tunnel surrounding the same. Objectives: For the given model, check and solve all geometrical errors on half portion and Assign appropriate PIDs. Perform meshing with the given Target length and element Quality…

      calendar

      07 Nov 2022 11:33 AM IST

        Read more

        Week 3 Challenge : CFD meshing on Turbocharger

        Objective:

        Aim: Performing CFD meshing on Turbocharger using ANSA Objective: For the given model, check for the geometrical errors to make appropriate volumes. Create and assign PIDs as shown in the video. Perform surface mesh with the given target lengths as per PIDs. Blade stage-1 = 1 mm Blade stage-2 = 1 mm Impeller = 2 mm…

        calendar

        03 Nov 2022 08:06 AM IST

        • ANSA
        • CFD
        Read more

        Schedule a counselling session

        Please enter your name
        Please enter a valid email
        Please enter a valid number

        Related Courses

        coursecard

        Design loads considered on bridges

        Recently launched

        10 Hours of Content

        coursecard

        Design of Steel Superstructure in Bridges

        Recently launched

        16 Hours of Content

        coursecard

        Design for Manufacturability (DFM)

        Recently launched

        11 Hours of Content

        coursecard

        CATIA for Medical Product Design

        Recently launched

        5 Hours of Content

        coursecardcoursetype

        Accelerated Career Program in Embedded Systems (On-Campus) Courseware Partner: IT-ITes SSC nasscom

        Recently launched

        0 Hours of Content

        Schedule a counselling session

        Please enter your name
        Please enter a valid email
        Please enter a valid number

        logo

        Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.

        https://d27yxarlh48w6q.cloudfront.net/web/v1/images/facebook.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/insta.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/twitter.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/youtube.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/linkedin.svg

        Our Company

        News & EventsBlogCareersGrievance RedressalSkill-Lync ReviewsTermsPrivacy PolicyBecome an Affiliate
        map
        EpowerX Learning Technologies Pvt Ltd.
        4th Floor, BLOCK-B, Velachery - Tambaram Main Rd, Ram Nagar South, Madipakkam, Chennai, Tamil Nadu 600042.
        mail
        info@skill-lync.com
        mail
        ITgrievance@skill-lync.com

        Top Individual Courses

        Computational Combustion Using Python and CanteraIntroduction to Physical Modeling using SimscapeIntroduction to Structural Analysis using ANSYS WorkbenchIntroduction to Structural Analysis using ANSYS Workbench

        Top PG Programs

        Post Graduate Program in Hybrid Electric Vehicle Design and AnalysisPost Graduate Program in Computational Fluid DynamicsPost Graduate Program in CADPost Graduate Program in Electric Vehicle Design & Development

        Skill-Lync Plus

        Executive Program in Electric Vehicle Embedded SoftwareExecutive Program in Electric Vehicle DesignExecutive Program in Cybersecurity

        Trending Blogs

        Heat Transfer Principles in Energy-Efficient Refrigerators and Air Conditioners Advanced Modeling and Result Visualization in Simscape Exploring Simulink and Library Browser in Simscape Advanced Simulink Tools and Libraries in SimscapeExploring Simulink Basics in Simscape

        © 2025 Skill-Lync Inc. All Rights Reserved.

                    Do You Want To Showcase Your Technical Skills?
                    Sign-Up for our projects.