Challenge

Week 2- 2R Robotic Arm Challenge

In this program 2 arms of different lengths are plotted and they are allowed to have angles between 0 to 90 degrees.Here the zero to 90 degrees are divided into 14 equal parts using linspace command, so both arms having 14 different angles each between 1 to 90 degrees make a combination of 196 figures.

First for loop is used to give theta values to first arm and second for loop for second arm. So after giving first theta value to first arm, 14 theta values are given to second arm and after finishing that cycle seconf theta value is given to first arm, similiarly the cycle continues.

Axis is also specified for the x and y acis using 'axis' command.

Using the 'getframe(gcf)' command and using term ct as a incrementing function by 1 each time we have stitched the images together to create an animation video suing movie, VideoWriter and writeVideo command we have successfull created the animation.

The code for program is

clear all
close all
clc
theta1=linspace(0,90,14);
theta2=linspace(0,90,14);
l1=1;
l2=.7;
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=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
figure(ct)
hold on
plot([x0 x1],[y0,y1],[x1 x2],[y1 y2],'LineWidth',4)
axis([-1 2 0 2])
V(ct)= getframe(gcf);
ct=ct+1;
pause(0.3)
end
end
movie(V)
videofile = VideoWriter('Forward_kinematics1.avi');
open(videofile)
writeVideo(videofile,V)
close(videofile)
Some issues faced during creating the program was error in spacing while using the two for loops simultaneously.
Some other errors due to mispelling and misplacing commands such as VideoWriter & writeVideo were also caused during programming.
After solving all the errors,196 figures of 2 rbobotic arms are obtained and an animation video is obtained.
Please find the attached youtube video link of animation.
https://youtu.be/DjtyUcLUxO4
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.