Simple invert pendulum by using feedback linearization

I

Thread Starter

IETR

I am trying to simulate an exercise of an online course, http://www.mece.panam.edu/~jakypuros/VirtualLab/CCLI/Pendulum.html, by using feedback linearization.

But I don't know how I can design the desired output for the simulation. The desired output in the simulation is represented by yd.

Here is my code in which the parameters and initial values were specified. Could anyone gives me help?
Really appreciate it.<pre>
clear all
clc;

m = 0.250;
L = 1;
g = 9.8;

t0 = 0;
tf = 5;
tspan = 0.01;

% inital values
x1 = 0; % state variable, angle
x2 = 0; % state variable, velocity
tau = 0; % torque
theta0 = 60*pi/180; % initial angle

K1 = 15; % P
K2 = 15; % D

n = 1; % for saving result

for i = 1:1000
% desired output
yd = theta0*pi/180+; % inital position
dyd = 0; %
ddyd = 0; % this part is incorrect at all.

% state equation
dx1 = x2;
dx2 = g/L*sin(x1) + 1/(m*L^2)*tau;

% states and output
x1 = x1 + dx1*tspan;
x2 = x2 + dx2*tspan;
y = x1;

% inputs
v = ddyd + K1*(dyd-dx1) + K2*(yd-y);
u = v - g/L*sin(x1)*(m*L^2);
tau = u;

% saving result
y_store:),n) = [y; yd];
x1_store(n) = x1;
x2_store(n) = x2;
tau_store(n) = u;
t0 = t0+tspan;
n = n+1;
end</pre>
 
Top