You are on page 1of 2

Roll Number : 20BEC110

Name : Shah Amee Amar

Experiment No. : 7
Dynamics of Robotic Manipulator

Exercise :
1. Develop equations of motion for 2 degrees of freedom RR planer robotic
arm using Lagrange Mechanics. Assume the suitable data and mention it.
Code :
% Define the constants and parameters of the system
m1 = 1; % mass of link 1
m2 = 1; % mass of link 2
l1 = 1; % length of link 1
l2 = 1; % length of link 2
I1 = m1*l1^2/12; % moment of inertia of link 1
I2 = m2*l2^2/12; % moment of inertia of link 2
g = 9.81; % acceleration due to gravity
% Define the time interval and initial conditions
tspan = [0 10]; % simulation time interval
theta0 = [pi/4, -pi/4]; % initial angles of the links
dtheta0 = [0, 0]; % initial angular velocities of the links
% Define the torque inputs as constant functions
tau1 = @(t) 0; % torque applied to link 1
tau2 = @(t) 0; % torque applied to link 2
% Define the equations of motion
eom = @(t, theta) [theta(2); % dtheta1/dt
(l2/I2)*(tau2(t)-m2*g*l2*sin(theta(2))-m2*l1*l2*sin(theta(1)-
theta(2))*theta(1)^2-(m1+m2)*g*l1*sin(theta(1))-m2*l1*l2*sin(theta(1)-
theta(2))*theta(2)^2)/(m1*l1^2*c1-m2*l1*l2^2*cos(theta(1)-theta(2))^2);
theta(4); % dtheta2/dt
(l1/I1)*(tau1(t)+(m1+m2)*g*l1*sin(theta(1))+m2*l1*l2*sin(theta(1)-
theta(2))*theta(1)^2 +m2*g*l2*sin(theta(2))*cos(theta(1)-theta(2))-
m2*l1*l2*sin(theta(1)-theta(2))*theta(2)^2)/(m2*l2^2*c1-m2*l1*l2*cos(theta(1)-
theta(2))^2)];
options = odeset('RelTol', 1e-6, 'AbsTol', 1e-6);
[t, theta] = ode45(eom, tspan, [theta0, dtheta0], options);
theta1 = theta(:,1);
theta2 = theta(:,2);
figure
plot(t, theta1, t, theta2);
xlabel('Time (s)'); ylabel('Angle (rad)');
title('Angle vs. Time');
legend('Link 1', 'Link 2');
Results :

You might also like