参考及致谢
一阶倒立摆的PID控制和LQR控制
由拉普拉斯变换到传递函数
函数f(t)二阶导数的拉普拉斯变换是什么?
[1]翟龙余.一级倒立摆仿真模型的建立[J].大众科技,2011(8):268-270.
模型建立
对小车的水平受力分析
M x ¨ = F − b x ˙ − N M\ddot{x}=F-b\dot{x}-N Mx¨=F−bx˙−N
- x ¨ \ddot{x} x¨代表对运动距离的二阶微分,即小车在外力作用下的加速度。
- F F F是外部施加给系统的外力。
- x ˙ \dot{x} x˙代表小车当前的运动速度,小车所受到的摩擦力为摩擦系数与小车运动速度之积,即 f = b x ˙ f=b\dot{x} f=bx˙。
- N N N为倒单摆作用给小车水平方向的力。
对倒单摆的水平受力分析
摆杆做平面运动,其质心在外力作用下,在一段时间内的水平位移为
s
=
x
−
l
×
s
i
n
ψ
s= x-l×sin\psi
s=x−l×sinψ (因为倒立摆的倒向与外力
F
F
F的方向相反,所以中间用负号),其加速度可以表示成
s
¨
=
d
2
s
d
t
2
=
d
2
(
x
−
l
×
s
i
n
ψ
)
d
t
2
=
x
¨
−
l
(
d
2
s
i
n
ψ
d
t
2
)
\ddot{s}=\frac {d^2s}{dt^2}=\frac{d^2( x-l×sin\psi)}{dt^2}=\ddot{x}-l(\frac{d^2sin\psi}{dt^2})
s¨=dt2d2s=dt2d2(x−l×sinψ)=x¨−l(dt2d2sinψ)
=
x
¨
−
l
c
o
s
ψ
d
ψ
d
t
d
t
=
x
¨
−
l
[
−
s
i
n
ψ
(
d
ψ
d
t
)
2
+
c
o
s
ψ
d
2
ψ
d
t
2
]
=\ddot{x}-l\frac{cos\psi\frac{d\psi}{dt}}{dt}=\ddot{x}-l[-sin\psi(\frac{d\psi}{dt})^2+cos\psi \frac{d^2\psi}{dt^2}]
=x¨−ldtcosψdtdψ=x¨−l[−sinψ(dtdψ)2+cosψdt2d2ψ]
更换符号后即可得到:
s
¨
=
x
¨
+
l
s
i
n
ψ
(
ψ
˙
)
2
−
l
c
o
s
ψ
(
ψ
¨
)
\ddot{s}=\ddot{x}+lsin\psi(\dot{\psi})^2-lcos\psi(\ddot{\psi})
s¨=x¨+lsinψ(ψ˙)2−lcosψ(ψ¨)
根据牛顿第二定律,此时摆质心的受力与加速度的关系为:
N
=
m
x
¨
−
(
m
l
ψ
¨
)
c
o
s
ψ
+
m
l
ψ
2
˙
s
i
n
ψ
N=m\ddot{x}-(ml\ddot{\psi})cos\psi+ml\dot{\psi ^2}sin\psi
N=mx¨−(mlψ¨)cosψ+mlψ2˙sinψ
联立关于倒立摆与小车的受力分析,替换掉相互作用力
N
N
N,得到:
(
M
+
m
)
x
¨
+
b
x
˙
−
m
l
ψ
¨
c
o
s
ψ
+
m
l
ψ
˙
2
s
i
n
ψ
=
F
(M+m)\ddot{x}+b\dot{x}-ml\ddot{\psi}cos\psi+ml\dot{\psi}^2sin\psi=F
(M+m)x¨+bx˙−mlψ¨cosψ+mlψ˙2sinψ=F
对倒单摆的垂直受力分析
倒单摆的质心在一段时间内垂直方向上移动的距离可以表示成:
h
=
l
c
o
s
ψ
h=lcos\psi
h=lcosψ
式中
ψ
\psi
ψ为单摆绕轴心转动的角度。
摆的质心在垂直方向的加速度可以表示为(注意,此时加速度方向与重力方向一致):
h
¨
=
d
2
(
l
c
o
s
ψ
)
d
t
2
=
l
d
(
−
s
i
n
ψ
d
ψ
d
t
)
d
t
=
−
l
c
o
s
ψ
(
d
ψ
d
t
)
2
−
l
s
i
n
ψ
(
d
2
ψ
d
t
2
)
\ddot{h}=\frac{d^2(lcos\psi)}{dt^2}=l\frac{d(-sin\psi\frac{d\psi}{dt})}{dt}=-lcos\psi(\frac{d\psi}{dt})^2-lsin\psi(\frac{d^2\psi}{dt^2})
h¨=dt2d2(lcosψ)=ldtd(−sinψdtdψ)=−lcosψ(dtdψ)2−lsinψ(dt2d2ψ)
垂直方向有重力
m
g
mg
mg和小车对摆的支持力
P
P
P,另外单摆会有一个与重力方向一致的加速度。
垂
直
向
上
的
分
量
=
垂
直
向
下
的
分
量
垂直向上的分量=垂直向下的分量
垂直向上的分量=垂直向下的分量
P
=
m
g
+
m
h
¨
P=mg+m\ddot{h}
P=mg+mh¨
P
=
m
g
−
m
l
c
o
s
ψ
(
d
ψ
d
t
)
2
−
m
l
s
i
n
ψ
(
d
2
ψ
d
t
2
)
P=mg-mlcos\psi(\frac{d\psi}{dt})^2-mlsin\psi(\frac{d^2\psi}{dt^2})
P=mg−mlcosψ(dtdψ)2−mlsinψ(dt2d2ψ)
替换符号之后可以得到:
P
=
m
g
−
m
l
(
c
o
s
ψ
)
ψ
˙
2
−
m
l
(
s
i
n
ψ
)
ψ
¨
P=mg-ml(cos\psi)\dot{\psi}^2-ml(sin\psi)\ddot{\psi}
P=mg−ml(cosψ)ψ˙2−ml(sinψ)ψ¨
假设摆受力不平衡,会有以铰链为圆心的角加速度,将
P
P
P和
N
N
N分别在转动方向上投影,根据倒单摆平衡时的力矩方程方程得到:
I
ψ
¨
=
P
l
s
i
n
ψ
+
N
l
c
o
s
ψ
I\ddot{\psi}=Plsin\psi+Nlcos\psi
Iψ¨=Plsinψ+Nlcosψ
观察上面的式子,你可能会发现里面少了一个分量,这个分量就是重力在垂直于摆方向的分力
m
g
s
i
n
ψ
mgsin\psi
mgsinψ,很多博客和论文上也是直接这么写,没有解释原因。只有以质心为参考点时,重力不产生力矩,上式成立,但这显然是背离事实的,个人理解,这里在小角度时为了方便分析做了近似。
其中
I
I
I为摆的转动惯量。将
P
P
P和
N
N
N的表达式与力矩平衡方程联立,消去中间变量
P
P
P、
N
N
N,得到:
(
I
+
m
l
2
)
ψ
¨
−
m
g
l
s
i
n
ψ
=
m
l
x
¨
c
o
s
ψ
(I+ml^2)\ddot{\psi}-mglsin\psi=ml\ddot{x}cos\psi
(I+ml2)ψ¨−mglsinψ=mlx¨cosψ
线性化
至此,我们通过受力分析得到了两个非常重要的式子:
(
M
+
m
)
x
¨
+
b
x
˙
−
m
l
ψ
¨
c
o
s
ψ
+
m
l
ψ
˙
2
s
i
n
ψ
=
F
(M+m)\ddot{x}+b\dot{x}-ml\ddot{\psi}cos\psi+ml\dot{\psi}^2sin\psi=F
(M+m)x¨+bx˙−mlψ¨cosψ+mlψ˙2sinψ=F
(
I
+
m
l
2
)
ψ
¨
−
m
g
l
s
i
n
ψ
=
m
l
x
¨
c
o
s
ψ
(I+ml^2)\ddot{\psi}-mglsin\psi=ml\ddot{x}cos\psi
(I+ml2)ψ¨−mglsinψ=mlx¨cosψ
考虑到倒单摆在实际工作时,偏转角
ψ
\psi
ψ通常比较小,于是有:
{
c
o
s
ψ
=
1
s
i
n
ψ
=
ψ
ψ
˙
=
0
\left\{ \begin{aligned} cos\psi & = & 1\\ sin \psi & = &\psi \\ \dot{\psi} & = & 0 \end{aligned} \right.
⎩⎪⎨⎪⎧cosψsinψψ˙===1ψ0
用
u
u
u来代表作用于受控对象的外力
F
F
F,结合上述近似结果,有:
{
(
M
+
m
)
x
¨
+
b
x
˙
−
m
l
ψ
¨
=
u
(
I
+
m
l
2
)
ψ
¨
−
m
g
l
ψ
=
m
l
x
¨
\left\{ \begin{aligned} (M+m)\ddot{x}+b\dot{x}-ml\ddot{\psi}&=& u \\ (I+ml^2)\ddot{\psi}-mgl\psi &=& ml\ddot{x} \end{aligned} \right.
{(M+m)x¨+bx˙−mlψ¨(I+ml2)ψ¨−mglψ==umlx¨
求系统传递函数
由上一节,我们最终得到了一个关于系统状态的微分方程组。而拉普拉斯变换可以将微分方程转化为代数方程进行运算,使求解大为简化。
(
M
+
m
)
x
¨
+
b
x
˙
−
m
l
ψ
¨
=
u
→
(
M
+
m
)
X
(
s
)
s
2
+
b
X
(
s
)
s
−
m
l
Ψ
(
s
)
s
2
=
U
(
s
)
(M+m)\ddot{x}+b\dot{x}-ml\ddot{\psi}= u \rightarrow(M+m)X(s)s^2+bX(s)s-ml\Psi(s)s^2=U(s)
(M+m)x¨+bx˙−mlψ¨=u→(M+m)X(s)s2+bX(s)s−mlΨ(s)s2=U(s)
(
I
+
m
l
2
)
ψ
¨
−
m
g
l
ψ
=
m
l
x
¨
→
(
I
+
m
l
2
)
Ψ
(
s
)
s
2
−
m
g
l
Ψ
(
s
)
=
m
l
X
(
s
)
s
2
(I+ml^2)\ddot{\psi}-mgl\psi = ml\ddot{x}\rightarrow(I+ml^2)\Psi(s)s^2-mgl\Psi(s)=mlX(s)s^2
(I+ml2)ψ¨−mglψ=mlx¨→(I+ml2)Ψ(s)s2−mglΨ(s)=mlX(s)s2
现在我们系统的输入变量是
U
(
s
)
U(s)
U(s),而我们关心的是小车当前的位置
X
(
s
)
X(s)
X(s)以及倒单摆的角度
Ψ
(
s
)
\Psi(s)
Ψ(s)
经过整理,可以得到下面的系统传递函数。
摆角度的传递函数:
P
p
e
n
d
(
s
)
=
ψ
(
s
)
U
(
s
)
=
m
l
s
q
s
3
+
b
(
I
+
m
l
2
)
s
2
−
(
m
+
M
)
m
g
l
s
−
b
m
g
l
P_{pend}(s)=\frac{\psi(s)}{U(s)}=\frac{mls}{qs^3+b(I+ml^2)s^2-(m+M)mgls-bmgl}
Ppend(s)=U(s)ψ(s)=qs3+b(I+ml2)s2−(m+M)mgls−bmglmls
小车位置的传递函数:
P
c
a
r
t
(
s
)
=
X
(
s
)
U
(
s
)
=
(
I
+
m
l
2
)
s
2
−
m
g
l
q
s
4
+
b
(
I
+
m
l
2
)
s
3
−
(
m
+
M
)
m
g
l
s
2
−
b
m
g
l
s
P_{cart}(s)=\frac{X(s)}{U(s)}=\frac{(I+ml^2)s^2-mgl}{qs^4+b(I+ml^2)s^3-(m+M)mgls^2-bmgls}
Pcart(s)=U(s)X(s)=qs4+b(I+ml2)s3−(m+M)mgls2−bmgls(I+ml2)s2−mgl
上面两式中
q
q
q为公因数项:
q
=
(
m
+
M
)
(
I
+
m
l
2
)
−
m
2
l
2
q=(m+M)(I+ml^2)-m^2l^2
q=(m+M)(I+ml2)−m2l2