Challenge

Week 2- 2R Robotic Arm Challenge

Here iam attaching the codes of forward kinematics of a robotic arm

% forward kinematics of a 2 link robot arm 
clear all
close all
clc

% inputs
l1 = 1;
l2 = 0.5;

theta1 =linspace(0,90,10);
theta2 =linspace(0,90,10);


%for loop
for i=1:length(theta1)
    THETA1 = theta1(i);
    for j=1:length(theta2)
    THETA2 = theta2(j);

%coordinates
    x0 = 0;
    y0 = 0;
    ct = 1;
    %counter


    x1 = l1*cosd(THETA1);
    y1 = l1*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.03)
    M(ct) = getframe(gcf);
    ct=ct+1;
    end
end
%movie
movie(M)
videofile = VideoWriter('Forward_kinematics_arm.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

Here iam attaching the simulated video link of the robotic arm using mat lab

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

EXPLAINATIONS OF THE CODES

1. Main title was entered.

2. clear all the command to clear all the commands in the editor window.

3. cloce all the command to close all the commands in the editor window.

4. clc is the command is to clear the commands in command window.

5.

6. Title was named as inputs

7. l1 the length of the first arm is entered.

8. l2 the length of the second arm is entered.

9.

10. theta1 is the angle of first arm or it is an angle for l1 with the linspace command used to get hteta values from 0 - 90deg.

11. theta1 is the angle of second arm or short arm it is an angle for l2 with the linspace command used to get hteta values from 0 - 90deg.

12.

13.

14. for loop head line

15. for loop starts i=1:theta times length

16. THETA1=theta1(i)

17. second for loop starts j=1:thetta times length

18. THETA2=theta2 times j

19.

20. coordinates title

21. x0=0

22. y0=0

23. ct=1

24. counter title

25.

26.

27. formula for x1

28. formula for y1

29.

30. formula for x2

31. formula for y2

32.

33. tittle for ploting

34. plotting the l1 and l2 in the desired places and the line width is to specify the width of the line while plotting

35. axis is to be fixed by using the axis command

36. pause command is to fix the pause time interval of the simulatated lines

37. M is the command to make as movie by the simulated fig and get farme is the command used to make a video.

38. this command is to specify the incremantal value of the counter.

39. end of the second for loop.

40. end of the first for loop.

41. movie title

42. it is to specify the movie command M

43. here the command is for naming the video file and the format name.\

44. this command is to open the video file.

45. This is to write the videofile.

46. This command is to close the 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.