0% found this document useful (0 votes)
3 views

Assignment 6

Uploaded by

www.nuthang
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment 6

Uploaded by

www.nuthang
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment-6

Name
: Nuthan venkata sai gandikota

ID : 2021A4PS3065H

% Define the end-effector path

x_start = 1; y_start = 1;

x_end = 2; y_end = 2;

t = 0:0.01:1;

% Segment 1: Constant acceleration (t ∈ [0,0.1])

x1 = x_start + 10*(t(1:10)).^3;

y1 = y_start + 10*(t(1:10)).^3;

% Segment 2: Constant velocity (t ∈ [0.1,0.9])

x2 = x1(end) + 0.9*(t(11:90)-0.1);

y2 = y1(end) + 0.9*(t(11:90)-0.1);

% Segment 3: Constant deceleration (t ∈ [0.9,1])

x3 = x2(end) + 10*(1-t(91:end)).^3;

y3 = y2(end) + 10*(1-t(91:end)).^3;

% Combine segments

x = [x1 x2 x3];

y = [y1 y2 y3];

% Inverse kinematics for initial joint angles


l1 = 1; l2 = 1;

theta1 = atan2(y_start, x_start);

theta2 = acos((x_start^2 + y_start^2 - l1^2 - l2^2) / (2*l1*l2));

initial_angles = [theta1 theta2];

% Inverse Jacobian to find Δθs

J_inv = [1/(l1+l2*cos(theta2)), -sin(theta2)/(l1+l2*cos(theta2));

sin(theta2)/(l1+l2*cos(theta2)), 1/(l1+l2*cos(theta2))];

dx = x(2:end) - x(1:end-1);

dy = y(2:end) - y(1:end-1);

dtheta = J_inv \ [dx; dy];

% Store Δθs in an array/matrix

dtheta_array = zeros(2, length(t)-1);

dtheta_array(1,:) = dtheta(1,:);

dtheta_array(2,:) = dtheta(2,:);

% Initial configuration of the manipulator

figure;

l1 = 1; l2 = 1;

theta1 = atan2(y_start, x_start);

theta2 = acos((x_start^2 + y_start^2 - l1^2 - l2^2) / (2*l1*l2));

x1 = l1*cos(theta1);

y1 = l1*sin(theta1);

x2 = x1 + l2*cos(theta1+theta2);

y2 = y1 + l2*sin(theta1+theta2);

plot([0 x1 x2], [0 y1 y2], 'k-');


axis equal;

pause(1);

% Animate the robot movement

for i = 1:size(dtheta_array,2)

theta1 = theta1 + dtheta_array(1,i);

theta2 = theta2 + dtheta_array(2,i);

x1 = l1*cos(theta1);

y1 = l1*sin(theta1);

x2 = x1 + l2*cos(theta1+theta2);

y2 = y1 + l2*sin(theta1+theta2);

cla;

plot([0 x1 x2], [0 y1 y2], 'k-');

axis equal;

pause(0.01);

end

You might also like