I'm reading this pdf. The dynamic equation of one arm is provided which is
$$ l \ddot{\theta} + d \dot{\theta} + mgL sin(\theta) = \tau $$
where
$\theta$ : joint variable.
$\tau$ : joint torque
$m$ : mass
$L$ : distance between centre mass and joint.
$d$ : viscous friction coefficient
$l$ : inertia seen at the rotation axis.
I would like to use P (proportional) controller for now.
$$ \tau = -K_{p} (\theta - \theta_{d}) $$
My Matlab code is
clear all
clc
t = 0:0.1:5;
x0 = [0; 0];
[t, x] = ode45('ODESolver', t, x0);
e = x(:,1) - (pi/2); % Error theta1
plot(t, e);
title('Error of \theta');
xlabel('time');
ylabel('\theta(t)');
grid on
For solving the differential equation
function dx = ODESolver(t, x)
dx = zeros(2,1);
%Parameters:
m = 2;
d = 0.001;
L = 1;
I = 0.0023;
g = 9.81;
T = x(1) - (pi/2);
dx(1) = x(2);
q2dot = 1/I*T - 1/I*d*x(2) - 1/I*m*g*L*sin(x(1));
dx(2) = q2dot;
The error is
My question is why the error is not approaching zero as time goes? The problem is a regulation track, so the error must approach zero.