%Everything done properly but i didnt get the result, I dont know why
% Define the arm length
L1 = 1; % Length of first link
L2 = 0.75; % Length of second link
% Define the joint angles
theta1 = linspace(0,pi/2,50); % Joint angle 1 in degrees
theta2 = linspace(0,pi/2,50); % Joint angle 2 in degrees
% Initialize the figure
fig = figure;
set(gcf,'Position',[0 0 800 600])
set(gca,'nextplot','replacechildren');
v = VideoWriter('2R_robotic_arm.avi');
v.Quality = 100;
v.FrameRate = 10;
open(v)
% Loop through each set of joint angles and calculate the position of the end effector
for i = 1:length(theta1)
% Convert angles to radians
t1 = theta1(i);
t2 = theta2(i);
% Calculate the position of the end effector
x = L1*cos(t1) + L2*cos(t1+t2);
y = L1*sin(t1) + L2*sin(t1+t2);
% Plot the arm
plot([0 L1*cos(t1)],[0 L1*sin(t1)],'LineWidth',2,'Color','b')
plot([L1*cos(t1) x],[L1*sin(t1) y],'LineWidth',2,'Color','r')
plot(x,y,'.','MarkerSize',20,'Color','k')
axis equal
% Capture the frame and add it to the video file
frame = getframe(fig);
writeVideo(v,frame);
% Clear the plot
clf
end
% Close the video file
close(v)
video_title = "2R Robotic Arm Simulation";
video_description = "This video shows a simulation of a 2R robotic arm using forward kinematics in Matlab.";
video_tags = "2R robotic arm, forward kinematics, simulation, Matlab";
video_file_name = "2R_robotic_arm.avi";