Challenge

Week 2- 2R Robotic Arm Challenge

Animation Link on Youtube is as follows:https://youtu.be/8oERVR5BSHo

Errors generated while coding:

Error-1:

While plotting using line command i did not put comma in between the x-coordinate array and y-coordinate array, and this threw an error.

Image of the same is attached as follows:

Error-1 coding image & error-1 error image.

Error-2:

when defining THETA-2 in the second for loop, i had used i instead of j which resulted in second arm not moving.

Image and animation file of the same is attached as below:

Error 2 coding image & error -2 animation file:https://youtu.be/qEOFhBd5Nfc

clear all
close all
clc

% Inputs of robots arm length and no. of arms
l1=1;
l2= 0.5;

% Each arm can move an angle of 0-90deg divided into 10 equal intervals.
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
ct=1

for i=1:length(theta1);
    THETA1=theta1(i);

% for each angle of rot of arm-1 simulate the movement of arm-2 from 0-90deg.

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

    x0=0
    y0=0

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

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

    plot([x0 x1],[y0 y1],[x1 x2], [y1 y2],'linewidth',3);
    axis([-0.1 1.5 0 1.5])
    pause(0.1);
    M(ct)=getframe(gcf);
    ct=ct+1;


    end

end
% steps to generate an animation video file
movie(M)
videofile=VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
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.