球杆系统-观测器设计
观测器的设计其实就是设计A-LC这个矩阵的特征根。 我的系统是离散系统, 因此该特征根在极坐标下应该是在单位圆内的, 这才能保证观测器的收敛。 我经验的选取L使得特征根为[-1.5500 + 1.9171i , -1.5500 – 1.9171i]。 将观测器的形式与反馈L带入到观测模型中, 使用如下脚本:
close all
clear all
sep_sig;
A = [0 1;0.06279 -1.1];
B = [-2.521; -33.86];
C = [1 0];
sys = ss(A,B,C,0);
sysd = c2d(sys,0.05);
a = sysd.a;
b = sysd.b;
c = sysd.c;
x1 = [distance(1)];
%x1_temp;
%x1_new;
x2 = [-380];
%x2_temp;
%x2_new;
tes = zeros(901);
tes(2:4)=1;
L = [1;4];
eig(a-L*c)
for i = 1:length(distance)-1
x1_temp = x1(i);
x2_temp = x2(i);
new = (a-L*c)*[x1_temp;x2_temp]+b*0+L*distance(i);
x1 = [x1, new(1)];
x2 = [x2, new(2)];
end
plot(t,x1);
hold on
plot(t,distance);
figure(2);
plot(t,0.08*x2);
hold on
plot(t(1:length(t)-1),diff(distance));
% L = [1;5];
% eig(a-L*c)
得到观测数据:
figure 3.6 观测结果
可以看到, 观测所得位移跟踪性能良好, 观测所得速度也比较平滑, 且没有漂移误差, 基本可以判定为该参数可用。 接下来就可以将观测模型移植到arduino代码中测试。
在线运行观测器代码如下:
运行效果
figure 3.7 左边是距离观测 右边是速度观测
可见观测结果跟踪性能良好, 有效滤去了微分带来的噪声。我们可以用观测器得到的速度做为速度反馈。
辨识得到的矩阵A与建模的矩阵A为何不同,如何调整的A矩阵系数?