Question: this is detail robot moving: % Main script for Delta Robot Kinematics and Visualization with Animation close all; clc; clear; % Delta robot constants R

this is detail robot moving:
% Main script for Delta Robot Kinematics and Visualization with Animation
close all;
clc;
clear;
% Delta robot constants
R =116; % Radius of the fixed base
r =50; % Radius of the moving platform
L1=100; % Length of the upper arm
L2=150; % Length of the lower arm
% Parameters
numPoints =100; % Number of points to define the circles
zOffset =-150; % Distance between the two circles along the Z-axis
% Define first circle points in the XY plane
theta = linspace(0,2* pi, numPoints); % Angle for the circle
x1= R * cos(theta); % X-axis points for the first circle
y1= R * sin(theta); % Y-axis points for the first circle
z1= zeros(1, numPoints); % Z-axis points for the first circle
% Define second circle points in the XY plane
x2= r * cos(theta); % X-axis points for the second circle
y2= r * sin(theta); % Y-axis points for the second circle
z2= zOffset * ones(1, numPoints); % Z-axis points for the second circle
% Setup input joint angles for animation
x_vals = linspace(-50,50,50); % Change in X
y_vals = linspace(-50,50,50); % Change in Y
z_vals = linspace(-200,-100,50); % Change in Z
% Infinite loop for continuous motion
while true
% Move up and down
for z = z_vals
move_robot(0,0, z, R, L1, L2, r);
end
for z = flip(z_vals)
move_robot(0,0, z, R, L1, L2, r);
end
% Move right and left
for x = x_vals
move_robot(x,0, z_vals(1), R, L1, L2, r);
end
for x = flip(x_vals)
move_robot(x,0, z_vals(1), R, L1, L2, r);
end
% Move forward and backward
for y = y_vals
move_robot(0, y, z_vals(1), R, L1, L2, r);
end
for y = flip(y_vals)
move_robot(0, y, z_vals(1), R, L1, L2, r);
end
% Move in circular path in XY plane
for i =1:length(theta)
move_robot(25* cos(theta(i)),25* sin(theta(i)), z_vals(1), R, L1, L2, r);
end
end
function move_robot(X, Y, Z, R, L1, L2, r)
% Define points A1, A2, A3 at 0,120, and 240 degrees on the fixed base
A1=[R * cos(0), R * sin(0),0];
A2=[R * cos(2* pi /3), R * sin(2* pi /3),0];
A3=[R * cos(4* pi /3), R * sin(4* pi /3),0];
A =[A1; A2; A3];
% Prepare figure for animation
figure(1);
clf;
hold on;
grid on;
axis equal;
xlim([-300300]);
ylim([-300300]);
zlim([-300300]);
xlabel('X (mm)');
ylabel('Y (mm)');
zlabel('Z (mm)');
title('3D Representation of the Mechanism');
view(3);
% Define first circle points in the XY plane
theta = linspace(0,2* pi,100); % Angle for the circle
x1= R * cos(theta); % X-axis points for the first circle
y1= R * sin(theta); % Y-axis points for the first circle
z1= zeros(1,100); % Z-axis points for the first circle
% Define second circle points in the XY plane
x2= r * cos(theta); % X-axis points for the second circle
y2= r * sin(theta); % Y-axis points for the second circle
z2=-150* ones(1,100); % Z-axis points for the second circle
% Plot the first circle in 3D
plot3(x1, y1, z1, 'LineWidth', 2);
% Plot the second circle in 3D
plot3(x2, y2, z2, 'LineWidth', 2);
% Plot the center of the circles
plot3(0,0,0,'o', 'MarkerSize', 10);
plot3(0,0,-150,'o', 'MarkerSize', 10);
try
% Calculate joint angles using inverse kinematics
[th1, th2, th3, fl]= FKinem(X, Y, Z);
if fl ==0
% Calculate the positions of the joints and plot the arms
th =[th1, th2, th3];
for j =1:3
C =[X, Y, Z];
B = A(j, :) +[L1* cos(pi - th(j)), L1* sin(pi - th(j)),0];
% Plot arms
plot3([A(j,1) B(1)],[A(j,2) B(2)],[A(j,3) B(3)], 'LineWidth', 2);
plot3([B(1) C(1)],[B(2) C(2)],[B(3) C(3)], 'LineWidth', 2);
% Plot joints
plot3(A(j,1), A(j,2), A(j,3),'o', 'MarkerSize', 5);
plot3(B(1), B(2), B(3),'o', 'MarkerSize', 5);
plot3(C(1), C(2), C(3),'o', 'MarkerSize', 5);
end
% Plot the end effector at point P
plot3(X, Y, Z,'ro', 'MarkerSize', 10, 'MarkerFaceColor', 'r');
end
catch ME
% Display the error message for debugging purposes
disp(['No valid solution found for position: X=', num2str(X),...
', Y=', num2str(Y),', Z=', num2str(Z)]);
disp(ME.message);
end
pause(0.05); % Adjust the pause to control the speed of the animation
end
this is IKinem.m:
function [theta1, theta2, theta3, fl]= IKinem(X, Y, Z)
x0= X;
y0= Y;
z0= Z;
theta1= IKinemTh(x0,y0,z0);
%........................................

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!