Challenge

Week 2- 2R Robotic Arm Challenge

https://drive.google.com/file/d/14yklbXFfAhmL8I2wKj4G6wY2dmapajSS/view?usp=sharing

% A program code for robotic arm forward kinematics- Determing the position
% in space where one is positioned from origin and other with respect to
% first one. Varitaion of angle is taken from 0 to 90 in both the arms.

%Initializing with to clear all the memory, close all files, figures and
%clear the common window screen.
clear all
close all
clc
%Input-- Length of arms in m
l1=1;
l2=0.5;
%Input-- Angle variation from 0 to 90 with 20 steps in between
theta1=linspace(0,90,20);
theta2=linspace(0,90,20);
% Intializing the counter within for loop
ct=1;
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
x0=0;
y0=0;
% X1 Y1 X2 Y2 coordinate in graph values
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%figure(ct) to have differen plots
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
xlabel('X coordinate-->')
ylabel('Y coordinate-->')
title('Movement of robotic arm in space (0-90 degree)')
pause(0.03) %to see slow plotting
% M array to store the frames of graph shown in figure each time.
% gcf is used to capture interior of fiure window, excluding menu and
% toolbar
M(ct)=getframe(gcf);
% Increasing the position in array using counter ct to store second,
% third upto n frames till the for loop is designed for.
ct=ct+1;
end
end
% Movie M command to convert the array of frames to video
movie(M)
%Naming the videofile and creating it in particular format
videofile=VideoWriter('forward_kinematics.avi','Uncompressed AVI');
% Openig the file called using temporary variable
open(videofile)
% Writing to the file using M array
writeVideo(videofile,M)
% Finally closing the same.
close(videofile)

Difficulty----

In octave coding was different, but I saw that it was already explained in a separate window. So, no problem I was able to do that also.

Thanks

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.