状态空间与稳定性State Space & Stability
PID 一次只看一个误差信号;状态空间把机器人的全部"记忆"写成一个向量 \(\mathbf x\),把动力学写成 \(\dot{\mathbf x}=A\mathbf x+B\mathbf u\)。这一节在一个摆上走完整条链路:在平衡点处线性化,用特征值判断稳定性,用能量当作李雅普诺夫证书,用可控性判断"推得动推不动",用极点配置把倒立摆立起来,再看把控制器放进计算机(离散化)和只测到一部分状态(观测器)时会发生什么。 PID looks at one error signal at a time; the state-space view writes everything a robot "remembers" as one vector \(\mathbf x\) and its dynamics as \(\dot{\mathbf x}=A\mathbf x+B\mathbf u\). This lesson runs the whole chain on a pendulum: linearize at an equilibrium, judge stability from eigenvalues, use energy as a Lyapunov certificate, test controllability ("can the input push every direction?"), balance the inverted pendulum with pole placement, and see what happens when the controller runs on a computer (discretization) and only part of the state is measured (observers).
1为什么机器人需要它Why robots need this
13.1 节的 PID 把一个关节当成"误差进、力矩出"的黑盒,调三个旋钮。它在单个关节上很好用,可是一旦遇到下面这些问题,就需要一个更完整的描述:
- 多个量互相牵连:倒立摆、平衡车、四旋翼的姿态和位置互相耦合,推一下小车,摆杆也跟着动。单独给每个量调 PID,常常调不出来。
- 平衡点不止一个:同一个摆,挂着是稳定的,倒立是不稳定的。同一个模型在不同工作点表现完全不同,控制器要知道自己在哪个点附近工作。
- 想要证明而不只是"试一试":控制器会不会在某些初始状态下发散?能离平衡点多远而不失控?这需要一个不用把方程解出来也能判断稳定性的工具。
- 控制器跑在计算机上,传感器只测到一部分:编码器测角度不测角速度,IMU 测角速度不测位置;控制周期是 1 ms 还是 50 ms 也会改变稳定性。
状态空间给这些问题一个统一的语言:把系统此刻的全部"记忆"写成状态向量 \(\mathbf x\),把动力学写成一阶方程组 \(\dot{\mathbf x}=\mathbf f(\mathbf x,\mathbf u)\)(2.5 节的标准形式)。在平衡点附近把它线性化,就得到全书控制部分的出发点:
The PID of Lesson 13.1 treats a joint as an "error in, torque out" black box with three knobs. It works well for a single joint, but the following problems call for a fuller description:
- Quantities that drag each other along: the angle and position of an inverted pendulum, a self-balancing robot or a quadrotor are coupled; push the cart and the pole moves too. A separate PID per quantity often cannot be tuned to work.
- More than one equilibrium: the same pendulum is stable hanging and unstable upright. One model behaves completely differently at different operating points, and a controller must know which one it is working near.
- Proof, not just "try it": will the controller diverge from some initial states? How far from the equilibrium can the robot be before it is lost? We need a way to judge stability without solving the equations.
- The controller runs on a computer and sensors see only part of the state: encoders measure angle but not angular velocity, an IMU measures angular rate but not position, and whether the loop runs every 1 ms or every 50 ms changes stability.
The state space gives all of these one language: write everything the system "remembers" right now as a state vector \(\mathbf x\), and the dynamics as a first-order system \(\dot{\mathbf x}=\mathbf f(\mathbf x,\mathbf u)\) (the standard form of Lesson 2.5). Linearize it near an equilibrium and you get the starting point of every control lesson that follows:
四个问题依次是:它自己稳不稳(\(A\) 的特征值,李雅普诺夫函数),输入能不能推动每个方向(可控性,\(A\) 和 \(B\)),怎样用反馈 \(\mathbf u=-K\mathbf x\) 把它变成我们想要的样子(极点配置),以及测量 \(\mathbf y\) 够不够还原整个 \(\mathbf x\)(可观性与观测器,\(A\) 和 \(C\))。13.3 节的 LQR 和 13.4 节的 MPC 都建立在这四个问题的答案上。全篇用同一个摆:质量 \(m=1\) kg 的质点挂在长 \(l=1\) m 的轻杆上(转动惯量 \(ml^2=1\) kg·m²),关节粘性阻尼 \(b\),电机力矩 \(u\),角度 \(\theta\) 从竖直向下量起。
Four questions follow in turn: is it stable by itself (eigenvalues of \(A\), Lyapunov functions), can the input push every direction (controllability, from \(A\) and \(B\)), how do we reshape it with feedback \(\mathbf u=-K\mathbf x\) (pole placement), and is the measurement \(\mathbf y\) enough to reconstruct all of \(\mathbf x\) (observability and observers, from \(A\) and \(C\)). The LQR of Lesson 13.3 and the MPC of Lesson 13.4 both build on these answers. One pendulum runs through the page: a point mass \(m=1\) kg on a light rod of length \(l=1\) m (inertia \(ml^2=1\) kg·m²), viscous joint damping \(b\), motor torque \(u\), and the angle \(\theta\) measured from straight down.
2直觉:状态是一个点,动力学是一片箭头Intuition: the state is a point, the dynamics a field of arrows
要预测摆下一刻往哪走,只知道角度不够:同一个角度,可能正往上甩,也可能正往下落。角度 \(\theta\) 加上角速度 \(\omega=\dot\theta\) 才够,这两个数就是状态 \(\mathbf x=(\theta,\omega)\)。牛顿定律 \(ml^2\ddot\theta=-mgl\sin\theta-b\dot\theta+u\) 写成状态形式:
To predict where the pendulum goes next, its angle is not enough: at the same angle it may be swinging up or falling down. The angle \(\theta\) plus the angular velocity \(\omega=\dot\theta\) is enough, and these two numbers are the state \(\mathbf x=(\theta,\omega)\). Newton's law \(ml^2\ddot\theta=-mgl\sin\theta-b\dot\theta+u\) in state form reads:
\(\mathbf f\) 在 \((\theta,\omega)\) 平面(相平面)的每一点放一支箭头,这正是 3.6 节的向量场:状态顺着箭头流动。箭头为零的点叫平衡点:\(\mathbf f(\mathbf x^*,u^*)=\mathbf 0\),即 \(\omega^*=0\) 且 \(mgl\sin\theta^*=u^*\)。不加力矩(\(u^*=0\))时有两个:挂着的 \(\theta^*=0\) 和倒立的 \(\theta^*=\pi\)。
平衡点附近,向量场长什么样?3.3 节说过,放大到足够近,光滑的映射都像它的雅可比。令 \(\delta\mathbf x=\mathbf x-\mathbf x^*\),\(\delta u=u-u^*\),一阶泰勒展开给出
\(\mathbf f\) attaches an arrow to every point of the \((\theta,\omega)\) plane (the phase plane): this is exactly the vector field of Lesson 3.6, and the state flows along the arrows. Points where the arrow vanishes are equilibria: \(\mathbf f(\mathbf x^*,u^*)=\mathbf 0\), i.e. \(\omega^*=0\) and \(mgl\sin\theta^*=u^*\). With no torque (\(u^*=0\)) there are two: hanging, \(\theta^*=0\), and upright, \(\theta^*=\pi\).
What does the field look like near an equilibrium? Lesson 3.3 showed that, zoomed in far enough, a smooth map looks like its Jacobian. With \(\delta\mathbf x=\mathbf x-\mathbf x^*\) and \(\delta u=u-u^*\), a first-order Taylor expansion gives
只有 \(\cos\theta^*\) 一项随平衡点变化,但它决定了一切。挂着时 \(\cos\theta^*=1\),重力像一根把摆拉回去的弹簧;倒立时 \(\cos\theta^*=-1\),同一个重力变成了把摆推开的"负弹簧"。代入本课的数值(\(g/l=9.81\ \text{s}^{-2}\),\(b=0.5\)):
Only the \(\cos\theta^*\) entry changes between equilibria, but it decides everything. Hanging, \(\cos\theta^*=1\) and gravity acts like a spring pulling the pendulum back; upright, \(\cos\theta^*=-1\) and the same gravity becomes a "negative spring" that pushes it away. With this lesson's numbers (\(g/l=9.81\ \text{s}^{-2}\), \(b=0.5\)):
1.11 节和 2.5 节已经告诉我们怎么读特征值:线性系统的解是 \(\sum_ic_ie^{\lambda_it}\mathbf v_i\),实部全为负就衰减。挂着的点是一个稳定螺旋(实部 \(-0.25\),每秒振 \(3.12/2\pi\approx0.5\) 圈);倒立点有一个正特征值 \(2.89\),沿它的特征向量,偏差每秒放大 \(e^{2.89}\approx18\) 倍,这就是鞍点。3.6 节用迹–行列式图把二维线性系统分了类;这里关心的是另一件事:线性化在多大范围内可信,以及平衡点怎样随输入移动。
Lesson 1.11 and Lesson 2.5 already taught how to read eigenvalues: the linear solution is \(\sum_ic_ie^{\lambda_it}\mathbf v_i\), which decays when every real part is negative. The hanging point is a stable spiral (real part \(-0.25\), oscillating at \(3.12/2\pi\approx0.5\) turns per second); the upright point has a positive eigenvalue \(2.89\), and along its eigenvector a deviation grows by \(e^{2.89}\approx18\times\) every second: a saddle. Lesson 3.6 classified 2D linear systems with the trace–determinant diagram; here we care about something else: how far from the equilibrium the linearization can be trusted, and how equilibria move with the input.
3动手玩:摆的相平面与它的线性化Play: the pendulum's phase plane and its linearization
在左边的相平面上点一下,就从那个状态放开摆(横轴是角度,纵轴是角速度)。琥珀色实线是真实的非线性运动,紫色虚线是在最近的平衡点处线性化后的预测 \(\delta\mathbf x(t)=e^{At}\delta\mathbf x_0\)。下方的曲线把两者对时间画出来,右上角的小图是摆本身。拖动"恒定力矩 \(u_0\)":平衡点会移动,\(A\) 跟着变。
Click anywhere in the phase plane on the left to release the pendulum from that state (horizontal axis angle, vertical axis angular velocity). The solid amber curve is the true nonlinear motion; the dashed purple curve is the prediction of the linearization at the nearest equilibrium, \(\delta\mathbf x(t)=e^{At}\delta\mathbf x_0\). The plot below shows both against time, and the small panel at the top right shows the pendulum itself. Drag "constant torque \(u_0\)": the equilibria move, and \(A\) moves with them.
- 在挂着的平衡点附近放开两次:一次幅值小于 20°(0.35 rad),线性化误差低于 2%;一次幅值超过 60°(1.05 rad),误差超过 15%。线性化在多大范围内"够用"?Release twice near the hanging equilibrium: once with an amplitude under 20° (0.35 rad), where the linearization error stays below 2%, and once with an amplitude over 60° (1.05 rad), where it exceeds 15%. Over what range is the linearization "good enough"?
- 加大阻尼 \(b\),直到稳定平衡点的两个特征值变成实数(螺旋变成结点,出现两条青色方向)。在 \(u_0=0\) 时这个阈值是 \(b=2\sqrt{g/l}\approx6.26\);加上力矩 \(u_0\) 后阈值变低还是变高?Increase the damping \(b\) until the stable equilibrium's eigenvalues become real (the spiral turns into a node and two cyan directions appear). At \(u_0=0\) the threshold is \(b=2\sqrt{g/l}\approx6.26\); with a torque \(u_0\) applied, does it go down or up?
再把 \(u_0\) 推过 \(mgl=9.81\) N·m:两个平衡点相互靠近、合并、然后消失("鞍结分岔"),摆从此一圈圈地转下去。平衡点不是系统固有的,它是"状态 + 输入"的一对 \((\mathbf x^*,u^*)\),线性化也要在这一对上做。
Now push \(u_0\) past \(mgl=9.81\) N·m: the two equilibria approach, merge and vanish (a "saddle–node bifurcation"), and the pendulum spins round and round. Equilibria are not a property of the system alone: they are pairs \((\mathbf x^*,u^*)\) of state and input, and the linearization is taken at such a pair.
线性化是一张局部地图:在平衡点附近它几乎完美(20° 以内误差不到 2%),离远了就会出错,而且它完全看不见全局结构:分界线、第二个平衡点、翻过顶点的旋转。"\(A\) 的特征值实部都为负"只说明平衡点局部稳定(李雅普诺夫间接法),要回答"多远都能回来",需要下一节的工具。
A linearization is a local map: near the equilibrium it is nearly perfect (under 2% error within 20°), further away it goes wrong, and it is blind to the global structure: separatrices, the other equilibrium, rotations over the top. "All eigenvalues of \(A\) have negative real part" proves only local stability (Lyapunov's indirect method); to answer "from how far does it come back?" we need the tool of the next section.
4第二视角:不解方程也能判断稳定(李雅普诺夫)Second view: stability without solving (Lyapunov)
有阻尼的摆最后一定会停在下面,为什么这么肯定?因为它的能量只减不增:
Why are we so sure a damped pendulum ends up hanging still? Because its energy can only go down:
李雅普诺夫(1892)把这个论证抽象出来:找一个函数 \(V(\mathbf x)\),它在平衡点为零、别处为正(像一只碗),而且沿着系统的运动不增加,\(\dot V=\nabla V\cdot\mathbf f\le0\)。那么状态就只能留在碗里,平衡点是稳定的;如果 \(\dot V<0\) 处处成立(平衡点除外),状态会一路滑到碗底,平衡点是渐近稳定的。关键在于 \(\dot V=\nabla V\cdot\mathbf f\) 只用到向量场本身,不需要解微分方程。
但 \(V\) 要自己去找,而且找错了不说明任何问题。下图给出三个候选:能量 \(E\);一个"看起来很自然"的 \(\tfrac12(\theta^2+\omega^2)\);以及解李雅普诺夫方程 \(A^\top P+PA=-I\) 得到的二次型 \(\mathbf x^\top P\mathbf x\)(第 6 节推导)。红色区域是 \(\dot V>0\) 的地方,在那里状态会往碗外爬;绿色区域是这个 \(V\) 能担保的吸引域:最大的、内部没有红色的碗。
Lyapunov (1892) abstracted this argument: find a function \(V(\mathbf x)\) that is zero at the equilibrium and positive elsewhere (a bowl), and does not increase along the motion, \(\dot V=\nabla V\cdot\mathbf f\le0\). Then the state cannot leave the bowl and the equilibrium is stable; if \(\dot V<0\) everywhere except the equilibrium, the state slides all the way to the bottom and the equilibrium is asymptotically stable. The key point: \(\dot V=\nabla V\cdot\mathbf f\) uses only the vector field itself, no differential equation is solved.
But you have to find \(V\) yourself, and a candidate that fails proves nothing. The figure offers three candidates: the energy \(E\); a "natural-looking" \(\tfrac12(\theta^2+\omega^2)\); and the quadratic form \(\mathbf x^\top P\mathbf x\) from solving the Lyapunov equation \(A^\top P+PA=-I\) (derived in Section 6). The red region is where \(\dot V>0\): there the state climbs out of the bowl. The green region is the region of attraction this \(V\) can certify: the largest bowl with no red inside.
- 选"朴素二次型" \(\tfrac12(\theta^2+\omega^2)\),放开一条轨迹,让 \(V(t)\) 在途中比起点高出 20% 以上。摆明明在稳定地停下来,这个 \(V\) 却在上升:它什么也证明不了。Pick the "naive quadratic" \(\tfrac12(\theta^2+\omega^2)\) and release a path along which \(V(t)\) rises more than 20% above its starting value. The pendulum is plainly settling, yet this \(V\) goes up: it proves nothing.
- 选"李雅普诺夫方程"(\(b>0\)),从绿色区域外面(\(V(\mathbf x_0)>1.05\,c^*\))放开一条不翻过顶点、最终停在下面的轨迹。证书是充分条件:它没担保的地方,系统照样可以稳定。Pick "Lyapunov equation" (\(b>0\)) and release, from outside the green region (\(V(\mathbf x_0)>1.05\,c^*\)), a path that never goes over the top and comes to rest hanging down. A certificate is sufficient: where it promises nothing, the system may still be stable.
能量是这个摆最好的证书:它担保的是整个 \(E<2mgl\) 的"眼睛"(无阻尼摆的分界线所围的区域,有阻尼时真实的吸引域还要更大),因为它来自物理。由线性化解出的二次型只在 \(|\theta|\lesssim44^\circ\) 的小椭圆里有效(\(b=0.5\) 时),它对非线性一无所知。机器人里的稳定性证明大多是这种思路:8.3 节证明"重力补偿 + PD"稳定,用的就是"动能 + 弹簧势能"这个 \(V\)。
Energy is the best certificate for this pendulum: it certifies the whole "eye" \(E<2mgl\) (the region inside the undamped pendulum's separatrix; with damping the true region of attraction is larger still), because it comes from physics. The quadratic form solved from the linearization works only in a small ellipse, \(|\theta|\lesssim44^\circ\) (at \(b=0.5\)); it knows nothing about the nonlinearity. Most stability proofs in robotics follow this pattern: Lesson 8.3 proves "gravity compensation + PD" stable with exactly the \(V\) "kinetic energy + spring potential".
5第三视角:输入推得动哪些方向?然后把极点放到想要的位置Third view: which directions can the input push? Then put the poles where you want
可控性Controllability
只有一个输入,却要控制两个(或更多)状态,这可能吗?对小车来说可以:力改变速度,速度再改变位置,输入通过动力学传到了位置上。\(B\) 是输入直接推的方向,\(AB\) 是"推了之后,动力学把它带向"的方向,\(A^2B\) 是再下一步……只要 \(B, AB, \dots, A^{n-1}B\) 张成整个空间,输入就能到达每个方向。这就是卡尔曼(1960)的秩判据:\((A,B)\) 可控,当且仅当下面这个可控性矩阵的秩等于 \(n\)。
One input, two (or more) states to control: is that possible? For a cart, yes: the force changes the velocity, and the velocity changes the position, so the input reaches the position through the dynamics. \(B\) is the direction the input pushes directly, \(AB\) is where the dynamics carries that push next, \(A^2B\) the step after, and so on. If \(B, AB, \dots, A^{n-1}B\) span the whole space, the input reaches every direction. That is Kalman's (1960) rank test: \((A,B)\) is controllable exactly when the controllability matrix below has rank \(n\).
秩判据只回答"能不能",不回答"费多大劲"。可控性格拉姆矩阵 \(W_T\)(第 6 节)回答后者:从原点出发、在 \(T\) 秒内、用输入能量 \(\int_0^Tu^2dt\le1\) 能到达的状态,恰好组成椭圆 \(\{\mathbf x:\mathbf x^\top W_T^{-1}\mathbf x\le1\}\)。椭圆越扁,那个方向越"难推";扁成一条线,就不可控了。下图拖动 \(B\)(琥珀色箭头)和目标点(红色十字)。
The rank test answers "can it?", not "at what cost?". The controllability Gramian \(W_T\) (Section 6) answers the latter: the states reachable from the origin in \(T\) seconds with input energy \(\int_0^Tu^2dt\le1\) form exactly the ellipse \(\{\mathbf x:\mathbf x^\top W_T^{-1}\mathbf x\le1\}\). The flatter the ellipse, the "harder to push" that direction; flattened into a line, the system is uncontrollable. In the figure drag \(B\) (the amber arrow) and the target (the red cross).
- 选"两个一阶模态"(\(A=\operatorname{diag}(-1,-3)\)),把 \(B\) 拖到一条青色特征方向上:椭圆塌成一条线,\(\det\mathcal C=0\)。这时哪个模态完全不受输入影响?Pick "two first-order modes" (\(A=\operatorname{diag}(-1,-3)\)) and drag \(B\) onto a cyan eigen-direction: the ellipse collapses to a line and \(\det\mathcal C=0\). Which mode is now completely untouched by the input?
- 选"小车",目标保持在"静止于 1 m 外"附近(位置 \(\ge0.8\),速度绝对值 \(\le0.2\)),把 \(T\) 从 2 s 减到 1 s 或更短:所需能量从 1.5 涨到 12 以上。为什么时间减半、能量涨 8 倍?Pick "cart", keep the target near "at rest 1 m away" (position \(\ge0.8\), absolute velocity \(\le0.2\)), and cut \(T\) from 2 s to 1 s or less: the energy needed rises from 1.5 to 12 or more. Why does halving the time cost 8× the energy?
再试试"两个相同模态"(\(A=-2I\)):无论 \(B\) 指向哪里,椭圆都是一条线。一个输入没法分别控制两个一模一样、互不相干的系统,因为它对两者的作用永远成同一比例。
Also try "two identical modes" (\(A=-2I\)): wherever \(B\) points, the ellipse is a line. One input cannot steer two identical, decoupled systems separately, because it always acts on them in the same proportion.
极点配置:把倒立摆立起来Pole placement: balancing the inverted pendulum
倒立点不稳定(\(\lambda=+3.03\),这里取 \(b=0.2\)),但系统可控。用状态反馈 \(u=-K\mathbf x=-k_1\delta\theta-k_2\omega\),闭环变成 \(\dot{\mathbf x}=(A-BK)\mathbf x\)。对本例,闭环特征多项式是
The upright point is unstable (\(\lambda=+3.03\), with \(b=0.2\) here), but the system is controllable. With state feedback \(u=-K\mathbf x=-k_1\delta\theta-k_2\omega\) the closed loop is \(\dot{\mathbf x}=(A-BK)\mathbf x\). For this example its characteristic polynomial is
两个增益正好对应两个系数,所以任意想要的极点(复数要成对)都能配出来:这就是极点配置定理,可控是它的充要条件。在下图左侧的 \(s\) 平面上拖动闭环极点,右侧的摆会用对应的 \(K\) 从初始偏角站起来。仿真是非线性的摆,电机力矩有上限,紫色虚线是线性模型的预测。
Two gains match exactly two coefficients, so any desired poles (complex ones in conjugate pairs) can be achieved: that is the pole-placement theorem, and controllability is exactly the condition for it. Drag the closed-loop poles in the \(s\)-plane on the left, and the pendulum on the right stands up from its initial tilt with the matching \(K\). The simulation is the nonlinear pendulum with a motor torque limit; the dashed purple curve is the linear model's prediction.
- 初始偏角 \(\ge20^\circ\)、力矩上限 \(\le20\) N·m,配出一组极点:调节时间 < 0.8 s,超调 < 5%,而且全程不饱和。提示:一对重极点 \(-6\) 需要 0.97 s;试试略带虚部的一对复极点。With an initial tilt \(\ge20^\circ\) and a torque limit \(\le20\) N·m, place poles that settle in under 0.8 s with under 5% overshoot and never saturate. Hint: a double pole at \(-6\) takes 0.97 s; try a complex pair with a modest imaginary part.
- 保持两个闭环极点都在左半平面,把初始偏角调到 40°,再降低力矩上限,直到摆摔倒。线性分析说"稳定",为什么它还是倒了?在 40° 处,最少要多大力矩才可能托住它?Keep both closed-loop poles in the left half-plane, set the initial tilt to 40°, then lower the torque limit until the pendulum falls. The linear analysis says "stable", so why does it fall? At 40°, what is the least torque that could possibly hold it?
可控时,极点"想放哪就放哪",但代价写在增益里:重极点 \(-p\) 需要 \(k_1=g/l+p^2\),从 20° 起步的初始力矩随 \(p^2\) 增长(\(p=6\) 时 16.0 N·m,\(p=7\) 时 20.5 N·m)。极点放得越快,力矩越大、越先撞上饱和,对噪声和采样延迟也越敏感。饱和以后系统不再是线性的,极点承诺的东西就不再成立。13.3 节的 LQR 用代价函数把"快"和"省力"放在同一把秤上,自动选出极点。
When the system is controllable the poles go "wherever you like", but the bill is in the gains: a double pole at \(-p\) needs \(k_1=g/l+p^2\), and the initial torque from a 20° tilt grows like \(p^2\) (16.0 N·m at \(p=6\), 20.5 N·m at \(p=7\)). Faster poles mean larger torques, earlier saturation, and more sensitivity to noise and sampling delay. Once saturated the system is no longer linear, and the poles' promises no longer hold. The LQR of Lesson 13.3 weighs "fast" against "gentle" in one cost function and picks the poles for you.
6再看数学The math
提示:把鼠标悬停在公式中带底色的符号上,对应的图元素会被高亮:\(A\) 加粗 FIG 1 的特征方向,\(V\) 与 \(\dot V\) 加粗 FIG 2 的等值线与红色区域,\(\mathcal C\) 与 \(W_T\) 加粗 FIG 3 的 \(B\)、\(AB\) 箭头与椭圆,\(K\) 放大 FIG 4 的闭环极点,\(A_d\) 与 \(I+AT\) 放大 FIG 5 的琥珀色与紫色极点,\(L\) 加粗 FIG 6 的估计曲线。Tip: hover the highlighted symbols in the formulas and the matching figure element lights up: \(A\) thickens FIG 1's eigen-directions, \(V\) and \(\dot V\) thicken FIG 2's level sets and red region, \(\mathcal C\) and \(W_T\) thicken FIG 3's \(B\), \(AB\) arrows and ellipse, \(K\) enlarges FIG 4's closed-loop poles, \(A_d\) and \(I+AT\) enlarge FIG 5's amber and purple poles, and \(L\) thickens FIG 6's estimate curves.
状态空间模型与它的解The state-space model and its solution
线性时不变(LTI)系统 \(\dot{\mathbf x}=A\mathbf x+B\mathbf u\),\(\mathbf y=C\mathbf x+D\mathbf u\)(机器人里 \(D\) 几乎总是 0)。对 \(e^{-At}\mathbf x\) 求导,得 \(\tfrac{d}{dt}(e^{-At}\mathbf x)=e^{-At}B\mathbf u\),两边积分即得"常数变易"公式:第一项是自由响应,第二项是输入引起的强迫响应。
A linear time-invariant (LTI) system is \(\dot{\mathbf x}=A\mathbf x+B\mathbf u\), \(\mathbf y=C\mathbf x+D\mathbf u\) (in robotics \(D\) is almost always 0). Differentiating \(e^{-At}\mathbf x\) gives \(\tfrac{d}{dt}(e^{-At}\mathbf x)=e^{-At}B\mathbf u\); integrating both sides yields the "variation of constants" formula, a free response plus a forced response:
第一项是系统"自己"怎么走(3.6 节的线性流),第二项是输入的贡献:每一时刻的输入 \(B\mathbf u(\tau)\) 被系统的自由运动 \(e^{A(t-\tau)}\) 一路带到时刻 \(t\)。状态的选法不唯一:换坐标 \(\mathbf x=T\mathbf z\) 得到 \((T^{-1}AT,\,T^{-1}B,\,CT)\),特征值不变,可控性、可观性也不变,所以这些都是系统本身的性质,而不是坐标的。
The first term is how the system moves "on its own" (the linear flow of Lesson 3.6); the second is the input's contribution: each instant's push \(B\mathbf u(\tau)\) is carried to time \(t\) by the free motion \(e^{A(t-\tau)}\). The choice of state is not unique: the change of coordinates \(\mathbf x=T\mathbf z\) gives \((T^{-1}AT,\,T^{-1}B,\,CT)\) with the same eigenvalues, controllability and observability, so these are properties of the system, not of the coordinates.
线性化与特征值稳定性Linearization and eigenvalue stability
对非线性系统 \(\dot{\mathbf x}=\mathbf f(\mathbf x,\mathbf u)\),在平衡对 \((\mathbf x^*,\mathbf u^*)\)(\(\mathbf f(\mathbf x^*,\mathbf u^*)=0\))处取 \(A=\partial\mathbf f/\partial\mathbf x\)、\(B=\partial\mathbf f/\partial\mathbf u\),误差项是 \(O(\|\delta\mathbf x\|^2+\|\delta\mathbf u\|^2)\)(2.4 节)。LTI 系统 \(\dot{\mathbf x}=A\mathbf x\) 的稳定性完全由特征值决定:
For a nonlinear system \(\dot{\mathbf x}=\mathbf f(\mathbf x,\mathbf u)\), take \(A=\partial\mathbf f/\partial\mathbf x\) and \(B=\partial\mathbf f/\partial\mathbf u\) at an equilibrium pair \((\mathbf x^*,\mathbf u^*)\) with \(\mathbf f(\mathbf x^*,\mathbf u^*)=0\); the remainder is \(O(\|\delta\mathbf x\|^2+\|\delta\mathbf u\|^2)\) (Lesson 2.4). The stability of the LTI system \(\dot{\mathbf x}=A\mathbf x\) is decided entirely by the eigenvalues:
- 所有 \(\operatorname{Re}\lambda_i<0\)(\(A\) 是 Hurwitz 的)\(\iff\) 渐近稳定,而且是指数稳定:\(\|\mathbf x(t)\|\le c\,e^{-\alpha t}\|\mathbf x_0\|\)。
- All \(\operatorname{Re}\lambda_i<0\) (\(A\) is Hurwitz) \(\iff\) asymptotically, in fact exponentially, stable: \(\|\mathbf x(t)\|\le c\,e^{-\alpha t}\|\mathbf x_0\|\).
- 某个 \(\operatorname{Re}\lambda_i>0\) \(\Rightarrow\) 不稳定。
- Some \(\operatorname{Re}\lambda_i>0\) \(\Rightarrow\) unstable.
- 实部为零的特征值是临界情况:它们若是单重的(或每个都有足够多的特征向量),解有界但不衰减(无阻尼的摆,"中心");若是重根而特征向量不够(约当块),解会按 \(t^k\) 增长。双积分器 \(\ddot q=0\) 的两个特征值都是 0,可 \(q(t)=q_0+\dot q_0t\) 一直跑远:不稳定。
- Eigenvalues with zero real part are the borderline: if simple (or with a full set of eigenvectors) the solution stays bounded but does not decay (the undamped pendulum, a "center"); if repeated without enough eigenvectors (a Jordan block), it grows like \(t^k\). The double integrator \(\ddot q=0\) has both eigenvalues at 0, yet \(q(t)=q_0+\dot q_0t\) runs away: unstable.
李雅普诺夫间接法把这些结论带回非线性系统:若线性化 \(A\) 是 Hurwitz 的,平衡点局部指数稳定;若 \(A\) 有正实部特征值,平衡点不稳定;若有实部为零的特征值,线性化无法判断,要看高阶项(3.6 节提到的 Hartman–Grobman 定理只覆盖双曲平衡点)。无阻尼摆(\(b=0\))的下平衡点正是这种情况:线性化是中心,判断要靠下面的能量论证。
Lyapunov's indirect method carries these verdicts back to the nonlinear system: if the linearization \(A\) is Hurwitz, the equilibrium is locally exponentially stable; if \(A\) has an eigenvalue with positive real part, it is unstable; if some eigenvalue has zero real part, the linearization cannot tell and higher-order terms decide (the Hartman–Grobman theorem mentioned in Lesson 3.6 covers only hyperbolic equilibria). The hanging point of the undamped pendulum (\(b=0\)) is exactly such a case: the linearization is a center, and the verdict needs the energy argument below.
李雅普诺夫直接法与 LaSalle 不变原理Lyapunov's direct method and LaSalle's invariance principle
平衡点 \(\mathbf x^*=0\) 稳定:对任意 \(\varepsilon>0\) 存在 \(\delta>0\),使 \(\|\mathbf x_0\|<\delta\) 的解永远满足 \(\|\mathbf x(t)\|<\varepsilon\);渐近稳定:稳定且附近的解趋于 0。定理(李雅普诺夫,1892):设在包含原点的区域 \(D\) 上有连续可微的 \(V\),满足
The equilibrium \(\mathbf x^*=0\) is stable if for every \(\varepsilon>0\) there is \(\delta>0\) such that solutions with \(\|\mathbf x_0\|<\delta\) stay within \(\|\mathbf x(t)\|<\varepsilon\) forever, and asymptotically stable if it is stable and nearby solutions tend to 0. Theorem (Lyapunov, 1892): suppose a continuously differentiable \(V\) on a region \(D\) containing the origin satisfies
则原点稳定;若 \(\dot V<0\)(\(\mathbf x\ne0\)),则渐近稳定;若再有 \(D=\R^n\) 且 \(\|\mathbf x\|\to\infty\) 时 \(V\to\infty\)(径向无界),则全局渐近稳定。直觉:\(V\) 的下水平集 \(\Omega_c=\{V\le c\}\) 是一只只嵌套的碗,\(\dot V\le0\) 说明状态不会爬出任何一只碗。
Then the origin is stable; if \(\dot V<0\) for \(\mathbf x\ne0\), it is asymptotically stable; if moreover \(D=\R^n\) and \(V\to\infty\) as \(\|\mathbf x\|\to\infty\) (radially unbounded), it is globally asymptotically stable. The picture: the sublevel sets \(\Omega_c=\{V\le c\}\) are nested bowls, and \(\dot V\le0\) means the state never climbs out of any of them.
摆的能量只给出 \(\dot E=-b\omega^2\le0\),在整条 \(\omega=0\) 线上都等于零,不满足严格不等式。LaSalle 不变原理(1960)补上了这一步:若 \(\Omega\) 是有界的正不变集且其中 \(\dot V\le0\),则从 \(\Omega\) 出发的解趋于 \(\{\dot V=0\}\) 中最大的不变集。在 \(\omega=0\) 线上能"待住"的解必须一直 \(\omega\equiv0\),于是 \(\dot\omega=-(g/l)\sin\theta=0\),只剩平衡点。取 \(\Omega=\{E<2mgl,\ |\theta|<\pi\}\)(能量低于翻过顶点所需的值),其中只有 \(\theta=0\) 这一个平衡点,所以里面的每条轨迹都回到挂着的位置:这正是 FIG 2 中能量候选的绿色"眼睛"。
The pendulum's energy only gives \(\dot E=-b\omega^2\le0\), which vanishes on the whole line \(\omega=0\): not strict. LaSalle's invariance principle (1960) closes the gap: if \(\Omega\) is a bounded positively invariant set on which \(\dot V\le0\), solutions starting in \(\Omega\) approach the largest invariant set inside \(\{\dot V=0\}\). A solution that "stays" on the line \(\omega=0\) must have \(\omega\equiv0\), hence \(\dot\omega=-(g/l)\sin\theta=0\): only equilibria remain. Take \(\Omega=\{E<2mgl,\ |\theta|<\pi\}\) (less energy than it takes to go over the top); its only equilibrium is \(\theta=0\), so every path inside returns to hanging: this is the green "eye" of the energy candidate in FIG 2.
线性系统的二次型证书。取 \(V=\mathbf x^\top P\mathbf x\),则 \(\dot V=\mathbf x^\top(A^\top P+PA)\mathbf x\)。定理:\(A\) 是 Hurwitz 的,当且仅当对任意 \(Q\succ0\),李雅普诺夫方程
Quadratic certificates for linear systems. With \(V=\mathbf x^\top P\mathbf x\), \(\dot V=\mathbf x^\top(A^\top P+PA)\mathbf x\). Theorem: \(A\) is Hurwitz if and only if, for any \(Q\succ0\), the Lyapunov equation
有唯一解且 \(P\succ0\)(此时 \(P=\int_0^\infty e^{A^\top t}Qe^{At}dt\))。它是 \(n(n+1)/2\) 个未知数的线性方程组。对挂着的摆,\(A=\begin{bmatrix}0&1\\-a&-b\end{bmatrix}\)(\(a=g/l\)),\(Q=I\),逐项解出 \(p_{12}=\tfrac1{2a}\),\(p_{22}=\tfrac{1+2p_{12}}{2b}\),\(p_{11}=a\,p_{22}+b\,p_{12}\)。\(b=0.5\) 时 \(P=\begin{bmatrix}10.83&0.051\\0.051&1.10\end{bmatrix}\)。把它用到非线性摆上,\(\dot V\) 等于 \(-\mathbf x^\top\mathbf x\) 加上高阶项,只在原点附近为负;FIG 2 搜出的 \(c^*=6.49\) 对应的椭圆在 \(\theta\) 方向只伸到 0.77 rad(约 44°)。这就是"用线性化证明"的典型代价:可靠,但保守。
has a unique solution with \(P\succ0\) (namely \(P=\int_0^\infty e^{A^\top t}Qe^{At}dt\)). It is a linear system in \(n(n+1)/2\) unknowns. For the hanging pendulum, \(A=\begin{bmatrix}0&1\\-a&-b\end{bmatrix}\) (\(a=g/l\)) and \(Q=I\) give, entry by entry, \(p_{12}=\tfrac1{2a}\), \(p_{22}=\tfrac{1+2p_{12}}{2b}\), \(p_{11}=a\,p_{22}+b\,p_{12}\). At \(b=0.5\), \(P=\begin{bmatrix}10.83&0.051\\0.051&1.10\end{bmatrix}\). Applied to the nonlinear pendulum, \(\dot V\) equals \(-\mathbf x^\top\mathbf x\) plus higher-order terms, negative only near the origin; the \(c^*=6.49\) found in FIG 2 gives an ellipse that reaches only 0.77 rad (about 44°) in \(\theta\). That is the typical price of "proving with the linearization": sound, but conservative.
可控性:秩判据、格拉姆矩阵与 PBH 判据Controllability: rank test, Gramian and PBH test
从 \(\mathbf x_0=0\) 出发,\(\mathbf x(T)=\int_0^Te^{A(T-\tau)}B\mathbf u(\tau)d\tau\)。由凯莱–哈密顿定理,\(A^n\) 是 \(I,A,\dots,A^{n-1}\) 的线性组合,所以 \(e^{At}B\) 永远落在 \(\operatorname{span}\{B,AB,\dots,A^{n-1}B\}\) 里:能到达的状态不会超出 \(\mathcal C\) 的列空间。反过来,若 \(\mathcal C\) 满秩,下面的格拉姆矩阵可逆,就能显式构造出到达任意目标的输入:
Starting at \(\mathbf x_0=0\), \(\mathbf x(T)=\int_0^Te^{A(T-\tau)}B\mathbf u(\tau)d\tau\). By the Cayley–Hamilton theorem \(A^n\) is a combination of \(I,A,\dots,A^{n-1}\), so \(e^{At}B\) always lies in \(\operatorname{span}\{B,AB,\dots,A^{n-1}B\}\): reachable states never leave the column space of \(\mathcal C\). Conversely, if \(\mathcal C\) has full rank, the Gramian below is invertible and an input reaching any target can be written down explicitly:
\(\mathbf u^*\) 是所有到达 \(\mathbf x_T\) 的输入中能量最小的一个(它是一个最小范数最小二乘解,参见 1.13 节的思路)。能量公式说明单位能量能到达的集合就是椭圆 \(\mathbf x^\top W_T^{-1}\mathbf x\le1\),半轴是 \(W_T\) 特征值的平方根。例:小车(双积分器)\(A=\begin{bmatrix}0&1\\0&0\end{bmatrix}\),\(B=\begin{bmatrix}0\\1\end{bmatrix}\),\(e^{A\tau}B=(\tau,1)\),得 \(W_T=\begin{bmatrix}T^3/3&T^2/2\\T^2/2&T\end{bmatrix}\)。从静止移动距离 \(d\) 再停下(\(\mathbf x_T=(d,0)\)),所需能量 \(12d^2/T^3\):\(T=2\) s 时 1.5,\(T=1\) s 时 12(FIG 3 的任务)。时间减半,最高速度要翻倍,而且要在一半的时间里达到,所以力要变成 4 倍;能量 \(\int u^2dt\) 于是变成 \(16\times\tfrac12=8\) 倍,即 \(1/T^3\)。
\(\mathbf u^*\) is the least-energy input among all that reach \(\mathbf x_T\) (a minimum-norm least-squares solution, in the spirit of Lesson 1.13). The energy formula says the set reachable with unit energy is the ellipse \(\mathbf x^\top W_T^{-1}\mathbf x\le1\), with semi-axes the square roots of the eigenvalues of \(W_T\). Example: the cart (double integrator) \(A=\begin{bmatrix}0&1\\0&0\end{bmatrix}\), \(B=\begin{bmatrix}0\\1\end{bmatrix}\) has \(e^{A\tau}B=(\tau,1)\) and \(W_T=\begin{bmatrix}T^3/3&T^2/2\\T^2/2&T\end{bmatrix}\). Moving a distance \(d\) from rest to rest (\(\mathbf x_T=(d,0)\)) costs \(12d^2/T^3\): 1.5 at \(T=2\) s and 12 at \(T=1\) s (FIG 3's task). Half the time needs twice the top speed, reached in half the time, so four times the force; the energy \(\int u^2dt\) then grows by \(16\times\tfrac12=8\): hence \(1/T^3\).
PBH 判据(Popov–Belevitch–Hautus)给出几何意义:\((A,B)\) 不可控,当且仅当存在 \(A\) 的左特征向量 \(\mathbf w^\top A=\lambda\mathbf w^\top\) 满足 \(\mathbf w^\top B=0\)。也就是说,有一个模态 \(\mathbf w^\top\mathbf x\) 按 \(\dot{(\mathbf w^\top\mathbf x)}=\lambda\,\mathbf w^\top\mathbf x\) 自己演化,输入完全碰不到它。FIG 3 的 \(A=\operatorname{diag}(-1,-3)\):\(\det\mathcal C=\det[B,\ AB]=-2b_1b_2\),\(B\) 落在某根坐标轴上时,另一个坐标就是碰不到的模态。若不可控的模态本身是稳定的(如这里),系统仍可镇定(stabilizable),这对 LQR 已经够用。
The PBH test (Popov–Belevitch–Hautus) gives the geometry: \((A,B)\) is uncontrollable if and only if some left eigenvector of \(A\), \(\mathbf w^\top A=\lambda\mathbf w^\top\), has \(\mathbf w^\top B=0\). Then the mode \(\mathbf w^\top\mathbf x\) evolves on its own, \(\dot{(\mathbf w^\top\mathbf x)}=\lambda\,\mathbf w^\top\mathbf x\), untouched by the input. For FIG 3's \(A=\operatorname{diag}(-1,-3)\), \(\det\mathcal C=\det[B,\ AB]=-2b_1b_2\): when \(B\) lies on one coordinate axis, the other coordinate is the untouchable mode. If the uncontrollable modes are themselves stable (as here) the system is still stabilizable, which is all LQR needs.
注意线性化不可控不等于非线性系统不可控。独轮车在静止处的线性化 \(\dot{\mathbf q}=B(\theta)\mathbf u\) 只有两列,秩为 2 < 3,可 9.1 节用李括号证明了它可控:侧移要靠"前进–转向–后退–转回"这种二阶效应,线性化看不见。
Note that an uncontrollable linearization does not mean an uncontrollable nonlinear system. The unicycle linearized at rest, \(\dot{\mathbf q}=B(\theta)\mathbf u\), has two columns and rank 2 < 3, yet Lesson 9.1 proved it controllable with Lie brackets: sideways motion comes from the second-order effect of "drive, turn, reverse, turn back", which the linearization cannot see.
极点配置与 Ackermann 公式Pole placement and Ackermann's formula
定理:单输入系统 \((A,B)\) 可控,则对任意 \(n\) 次实系数首一多项式 \(\varphi(s)\),存在唯一的 \(K\) 使 \(\det(sI-(A-BK))=\varphi(s)\);不可控时,不可控模态的特征值无论 \(K\) 取什么都不会动。构造性的写法是 Ackermann 公式:
Theorem: if the single-input system \((A,B)\) is controllable, then for every monic real polynomial \(\varphi(s)\) of degree \(n\) there is a unique \(K\) with \(\det(sI-(A-BK))=\varphi(s)\); if it is not controllable, the eigenvalues of the uncontrollable modes stay put whatever \(K\) is. A constructive form is Ackermann's formula:
对 \(B=(0,\dots,0,1)^\top\) 形式的"可控标准形",\(A-BK\) 的最后一行恰好就是特征多项式的系数,于是每个增益直接对应一个系数,这正是第 5 节两行推导的来源。一个熟悉的特例:8.3 节的计算力矩把每个关节变成双积分器 \(\ddot e=a\),PD 律 \(a=-K_pe-K_d\dot e\) 就是 \(K=[K_p,K_d]\),把两个极点放在 \(s^2+K_ds+K_p=s^2+2\zeta\omega_ns+\omega_n^2\) 的根上。多输入时满足要求的 \(K\) 有无穷多个,多出来的自由度可以用来改善鲁棒性,或交给 LQR 去选。选极点的经验:欠阻尼极点对 \(\sigma\pm j\omega_d\) 的 2% 调节时间大约是 \(4/|\sigma|\);极点越靠左,增益越大(FIG 4 中 \(k_1=g/l+p_1p_2\))。
In the "controllable canonical form" with \(B=(0,\dots,0,1)^\top\), the last row of \(A-BK\) holds exactly the characteristic-polynomial coefficients, so each gain matches one coefficient: that is the two-line derivation of Section 5. A familiar special case: the computed torque of Lesson 8.3 turns each joint into a double integrator \(\ddot e=a\), and the PD law \(a=-K_pe-K_d\dot e\) is \(K=[K_p,K_d]\), placing the two poles at the roots of \(s^2+K_ds+K_p=s^2+2\zeta\omega_ns+\omega_n^2\). With several inputs infinitely many \(K\) achieve the same poles; the extra freedom can buy robustness, or be left to LQR. A rule of thumb for choosing poles: an underdamped pair \(\sigma\pm j\omega_d\) settles to 2% in roughly \(4/|\sigma|\); the further left the poles, the larger the gains (in FIG 4, \(k_1=g/l+p_1p_2\)).
离散化:零阶保持与欧拉法Discretization: zero-order hold versus Euler
数字控制器每隔 \(T\) 秒读一次传感器、算一次 \(u_k\),然后在整个周期里保持这个值(零阶保持,ZOH)。在一个周期内 \(\mathbf u\) 是常数,把常数变易公式从 \(kT\) 积到 \((k+1)T\),得到精确的离散模型:
A digital controller reads the sensors every \(T\) seconds, computes \(u_k\), and holds it for the whole period (zero-order hold, ZOH). With \(\mathbf u\) constant over a period, integrating the variation-of-constants formula from \(kT\) to \((k+1)T\) gives an exact discrete model:
右边的分块指数是实际计算时的技巧(FIG 5 就用它)。\(A_d\) 的特征值是 \(z=e^{\lambda T}\):左半平面整个映到单位圆内,与 1.11 节"离散时间 \(|\lambda|<1\)"的判据完全对上。前向欧拉法把导数换成差分 \(\dot{\mathbf x}\approx(\mathbf x_{k+1}-\mathbf x_k)/T\):
The block exponential on the right is how it is computed in practice (FIG 5 uses it). The eigenvalues of \(A_d\) are \(z=e^{\lambda T}\): the whole left half-plane maps inside the unit circle, matching the "\(|\lambda|<1\) in discrete time" criterion of Lesson 1.11. Forward Euler replaces the derivative by a difference, \(\dot{\mathbf x}\approx(\mathbf x_{k+1}-\mathbf x_k)/T\):
欧拉法只是 \(e^{\lambda T}\) 的一阶近似,它的稳定区只是左半平面里一个圆心在 \(-1/T\)、半径 \(1/T\) 的圆盘。弱阻尼极点 \(-\zeta\omega_n\pm j\omega_n\sqrt{1-\zeta^2}\) 给出 \(|z|^2=1-2\zeta\omega_nT+\omega_n^2T^2\),所以只要 \(T>2\zeta/\omega_n\),欧拉模型就会把一个稳定的振子预测成发散的;快速实极点 \(\lambda\) 则要求 \(T<2/|\lambda|\),这就是 2.5 节讲过的显式欧拉步长限制。其它常用的映射还有双线性(Tustin)变换 \(z=\tfrac{1+\lambda T/2}{1-\lambda T/2}\),它把整个左半平面映进单位圆,常用于把连续设计的控制器转成离散的。
Euler is only the first-order approximation of \(e^{\lambda T}\), and its stability region is just the disk of radius \(1/T\) centred at \(-1/T\) inside the left half-plane. A lightly damped pole \(-\zeta\omega_n\pm j\omega_n\sqrt{1-\zeta^2}\) gives \(|z|^2=1-2\zeta\omega_nT+\omega_n^2T^2\), so for any \(T>2\zeta/\omega_n\) the Euler model predicts that a stable oscillator diverges; a fast real pole \(\lambda\) requires \(T<2/|\lambda|\), the explicit-Euler step limit of Lesson 2.5. Another common map is the bilinear (Tustin) transform \(z=\tfrac{1+\lambda T/2}{1-\lambda T/2}\), which takes the whole left half-plane into the unit disk and is often used to turn a continuous controller design into a discrete one.
采样控制回路:被控对象是连续的,控制器 \(u_k=-K\mathbf x_k\) 每个周期更新一次,真实的闭环是 \(\mathbf x_{k+1}=(A_d-B_dK)\mathbf x_k\)。保持器让控制总是"慢半拍",大致相当于 \(T/2\) 的延迟,所以按连续时间设计的 \(K\) 在 \(T\) 变大时会失稳,而且比欧拉模型预测的早。
The sampled-data loop: the plant is continuous, the controller \(u_k=-K\mathbf x_k\) updates once per period, and the true closed loop is \(\mathbf x_{k+1}=(A_d-B_dK)\mathbf x_k\). The hold makes the control always "half a step late", roughly a delay of \(T/2\), so a \(K\) designed in continuous time loses stability as \(T\) grows, and earlier than the Euler model predicts.
可观性与龙伯格观测器Observability and the Luenberger observer
状态反馈要用到整个 \(\mathbf x\),可传感器只给出 \(\mathbf y=C\mathbf x\)。能不能从 \(\mathbf y(t)\) 和已知的 \(\mathbf u(t)\) 还原出 \(\mathbf x\)?把 \(\mathbf y,\dot{\mathbf y},\ddot{\mathbf y},\dots\) 写出来(\(\mathbf u=0\) 时 \(\mathbf y^{(k)}=CA^k\mathbf x\)),答案是
State feedback needs all of \(\mathbf x\), but the sensors give only \(\mathbf y=C\mathbf x\). Can \(\mathbf x\) be recovered from \(\mathbf y(t)\) and the known \(\mathbf u(t)\)? Write out \(\mathbf y,\dot{\mathbf y},\ddot{\mathbf y},\dots\) (with \(\mathbf u=0\), \(\mathbf y^{(k)}=CA^k\mathbf x\)) and the answer is
\((A,C)\) 可观,当且仅当 \(\mathcal O\) 的秩为 \(n\);这与"\((A^\top,C^\top)\) 可控"完全等价(对偶性)。龙伯格观测器(1964)是一个并行运行的模型,用"测量减预测"的差把它往正确的方向拉。估计误差 \(\mathbf e=\mathbf x-\hat{\mathbf x}\) 的动态与输入无关,只由 \(A-LC\) 决定;按对偶性,可观时 \(A-LC\) 的特征值可以任意配置,配置方法就是对 \((A^\top,C^\top)\) 做极点配置。摆的两种传感器:
\((A,C)\) is observable if and only if \(\mathcal O\) has rank \(n\), which is exactly equivalent to "\((A^\top,C^\top)\) is controllable" (duality). The Luenberger observer (1964) is a model running in parallel, pulled toward the truth by the gap "measurement minus prediction". The estimation error \(\mathbf e=\mathbf x-\hat{\mathbf x}\) evolves independently of the input, governed by \(A-LC\) alone, and by duality its eigenvalues can be placed anywhere when the system is observable: pole placement on \((A^\top,C^\top)\). The pendulum's two sensors:
- 编码器 \(C=[1\ \ 0]\):\(\mathcal O=I\),总是可观。把两个观测器极点都放在 \(-p\):\(L_1=2p-b\),\(L_2=p^2-a-bL_1\)(\(a=\tfrac gl\cos\theta^*\))。
- Encoder \(C=[1\ \ 0]\): \(\mathcal O=I\), always observable. Both observer poles at \(-p\): \(L_1=2p-b\), \(L_2=p^2-a-bL_1\) (with \(a=\tfrac gl\cos\theta^*\)).
- 陀螺仪(只测角速度)\(C=[0\ \ 1]\):\(\mathcal O=\begin{bmatrix}0&1\\-a&-b\end{bmatrix}\),\(\det\mathcal O=a\)。有重力作用在角度上(\(a\ne0\))时可观:角度改变重力力矩,重力力矩又改变角速度,所以角速度里"藏着"角度。关节在水平面里转动时 \(a=0\),不可观:给角度加任何常数偏移,陀螺仪读数都不变。这正是 IMU 只靠陀螺仪无法知道航向(偏航角)的原因(15.1 节)。
- Gyro (angular rate only) \(C=[0\ \ 1]\): \(\mathcal O=\begin{bmatrix}0&1\\-a&-b\end{bmatrix}\), \(\det\mathcal O=a\). With gravity acting on the angle (\(a\ne0\)) it is observable: the angle changes the gravity torque, which changes the rate, so the rate "hides" the angle. For a joint turning in a horizontal plane \(a=0\) and it is unobservable: add any constant offset to the angle and the gyro reads exactly the same. This is why an IMU's gyros alone cannot tell its heading (yaw) (Lesson 15.1).
观测器极点越快,估计收敛越快,但 \(L\) 越大,测量噪声也被放大得越多。4.8 节的卡尔曼滤波正是按噪声的统计量来选 \(L\) 的观测器。把观测器和状态反馈 \(\mathbf u=-K\hat{\mathbf x}\) 接在一起,闭环特征值恰好是 \(A-BK\) 与 \(A-LC\) 两组的并集(分离原理),可以分别设计;13.3 节的 LQG 会再回到这一点。
Faster observer poles converge faster, but a larger \(L\) also amplifies measurement noise more. The Kalman filter of Lesson 4.8 is precisely the observer that chooses \(L\) from the noise statistics. Connect the observer to state feedback \(\mathbf u=-K\hat{\mathbf x}\) and the closed-loop eigenvalues are exactly the union of those of \(A-BK\) and \(A-LC\) (the separation principle), so the two can be designed separately; the LQG of Lesson 13.3 returns to this.
7机器人中的它:控制器跑在计算机上,传感器只看到一部分In robotics: the controller runs on a computer, the sensors see only part
离散化:同一个系统,两种离散模型Discretization: one system, two discrete models
机器人的控制器以固定周期运行:力控机械臂常见 1 kHz,移动底盘的速度环可能只有几十 Hz,视觉伺服受相机帧率限制。模型预测控制(13.4 节)和 LQR 的离散版本都需要一个离散模型 \(\mathbf x_{k+1}=A_d\mathbf x_k+B_d\mathbf u_k\)。下图比较两种得到它的方法:精确的零阶保持(琥珀色)和"把导数换成差分"的欧拉法(紫色)。线是真实系统,点是两个离散模型每隔 \(T\) 秒的预测。
Robot controllers run at a fixed period: torque-controlled arms commonly at 1 kHz, a mobile base's velocity loop perhaps at a few tens of Hz, and visual servoing is limited by the camera frame rate. Model predictive control (Lesson 13.4) and discrete-time LQR both need a discrete model \(\mathbf x_{k+1}=A_d\mathbf x_k+B_d\mathbf u_k\). The figure compares two ways of getting it: the exact zero-order hold (amber) and Euler's "replace the derivative by a difference" (purple). The line is the true system; the dots are the two discrete models' predictions every \(T\) seconds.
- "柔性关节"(\(\omega_n=6\) rad/s,\(\zeta=0.1\)):加大 \(T\),直到欧拉模型的极点跑出单位圆(\(T>2\zeta/\omega_n\approx0.033\) s),而零阶保持模型和真实系统都依然稳定。"Flexible joint" (\(\omega_n=6\) rad/s, \(\zeta=0.1\)): increase \(T\) until the Euler model's poles leave the unit circle (\(T>2\zeta/\omega_n\approx0.033\) s) while the ZOH model and the true system stay stable.
- "数字控制":加大控制周期 \(T\),直到真实的采样回路失稳(琥珀色极点出圆,约 \(T\ge0.211\) s),而欧拉模型还说"稳定"(它要到 \(T=0.4\) s 才失稳)。"Digital control": increase the control period \(T\) until the true sampled-data loop goes unstable (amber poles leave the circle, at about \(T\ge0.211\) s) while the Euler model still says "stable" (it only goes unstable at \(T=0.4\) s).
"刚性系统"预设里,快模态 \(\lambda=-40\)(比如电机电流)让欧拉模型在 \(T>0.025\) s 时开始正负交替地振荡,\(T>0.05\) s 时发散,而它对应的真实运动在几十毫秒内就衰减完了。所以:用于预测和优化的模型,用精确离散化(MPC 求解器通常用 RK4 或隐式积分器,不用一步欧拉);控制周期要比闭环的时间常数短得多。FIG 5 的设计是 \(-5\) 重根(时间常数 0.2 s),采样周期 \(T\) 到 0.211 s,也就是大约一个闭环时间常数时,回路就失稳了。
In the "stiff system" preset the fast mode \(\lambda=-40\) (a motor current, say) makes the Euler model oscillate with alternating sign for \(T>0.025\) s and diverge for \(T>0.05\) s, while the true fast motion has died out within tens of milliseconds. Hence: use exact discretization for models used in prediction and optimization (MPC solvers usually integrate with RK4 or implicit integrators, not one Euler step), and keep the control period much shorter than the closed-loop time constants. FIG 5's design, a double pole at \(-5\) (time constant 0.2 s), goes unstable once the sampling period reaches \(T=0.211\) s, i.e. about one closed-loop time constant.
观测器:从编码器还原角速度Observers: recovering the angular velocity from an encoder
编码器只给角度。直接对角度做差分得到的速度噪声很大(噪声除以一个很小的 \(T\))。观测器换个思路:让一个模型和摆一起跑,用测量去修正它。下图中摆受已知的力矩 \(u(t)=2\sin(1.3t)\) N·m 驱动,真实初始角 0.4 rad,观测器从 0 开始猜。选传感器和安装方式,调观测器极点和测量噪声。
An encoder gives only the angle. Differencing the angle gives a very noisy velocity (noise divided by a small \(T\)). An observer takes another route: run a model alongside the pendulum and correct it with the measurement. In the figure the pendulum is driven by a known torque \(u(t)=2\sin(1.3t)\) N·m, starts at a true angle of 0.4 rad, and the observer starts by guessing 0. Pick the sensor and the mounting, and tune the observer poles and the measurement noise.
- 选"陀螺仪 ω"和"水平面内",让观测器跑满 5 s:无论 \(p\) 多大,角度误差都还停在初始值的 90% 以上。换成"挂着",同样的陀螺仪为什么又能估出角度了?Pick "gyro ω" and "horizontal" and let the observer run 5 s: whatever \(p\) is, the angle error is still above 90% of its initial value. Switch to "hanging": why can the same gyro now recover the angle?
- 用编码器,把测量噪声调到 \(\sigma\ge0.02\) rad,再把观测器极点推到 \(p\ge25\):ω 估计的 RMS 超过 0.03 rad/s。和 \(p=5\) 比一比,快的观测器付出了什么?With the encoder, set the measurement noise to \(\sigma\ge0.02\) rad and push the observer poles to \(p\ge25\): the RMS of the ω estimate exceeds 0.03 rad/s. Compare with \(p=5\): what did the faster observer pay?
在平衡点附近线性化是几乎所有经典机器人控制器的第一步:四旋翼在悬停点线性化后,小倾角下水平加速度约等于 \(g\) 乘倾角,位置与姿态成为一串积分器,于是有了 13.1 节里的级联结构;平衡车和小车倒立摆在竖直点线性化后用状态反馈或 LQR(8.1 节的自动平衡);9.2 节的线性倒立摆 \(\ddot x=\tfrac{g}{z_c}(x-p)\) 是一个鞍点,特征值 \(\pm\omega\)(\(\omega=\sqrt{g/z_c}\)),"捕获点" \(x+\dot x/\omega\) 正是它不稳定模态的坐标。机械臂经计算力矩变成双积分器后,\(K_p=\omega_n^2,K_d=2\zeta\omega_n\) 就是极点配置(8.3 节)。工具:python-control(ss、ctrb、obsv、place、lyap、sample_system),SciPy(signal.place_poles、signal.cont2discrete 的 'zoh' 和 'euler' 方法、linalg.solve_continuous_lyapunov、linalg.expm),MATLAB 的 ss、ctrb、place、lyap、c2d;Drake 的 Linearize 给出系统在平衡点的 \((A,B,C,D)\),MuJoCo 的 mjd_transitionFD 用有限差分直接给出离散时间的 \(A,B\)。李雅普诺夫证书的自动化:平方和(SOS)规划可以搜索多项式 \(V\),LQR-Trees(Tedrake 等,2010)用它验证每个 LQR 控制器的吸引域并拼成覆盖整个状态空间的"漏斗";也有用神经网络学 \(V\) 并验证的工作(Chang 等,2019)。观测器:许多伺服驱动器用观测器而不是差分来估计速度;卡尔曼滤波(4.8 节)是按噪声统计最优的观测器,视觉惯性里程计里全局位置和航向不可观(15.1 节)。
Linearizing at an equilibrium is the first step of almost every classical robot controller: a quadrotor linearized at hover has horizontal acceleration roughly \(g\) times the tilt for small tilts, so position and attitude become a chain of integrators, which is where the cascade of Lesson 13.1 comes from; self-balancing robots and the cart-pole are linearized upright and stabilized with state feedback or LQR (the auto-balance of Lesson 8.1); the linear inverted pendulum \(\ddot x=\tfrac{g}{z_c}(x-p)\) of Lesson 9.2 is a saddle with eigenvalues \(\pm\omega\) (\(\omega=\sqrt{g/z_c}\)), and the "capture point" \(x+\dot x/\omega\) is exactly the coordinate of its unstable mode. Once computed torque turns an arm into double integrators, \(K_p=\omega_n^2,K_d=2\zeta\omega_n\) is pole placement (Lesson 8.3). Tools: python-control (ss, ctrb, obsv, place, lyap, sample_system), SciPy (signal.place_poles, signal.cont2discrete with its 'zoh' and 'euler' methods, linalg.solve_continuous_lyapunov, linalg.expm), MATLAB's ss, ctrb, place, lyap, c2d; Drake's Linearize returns a system's \((A,B,C,D)\) at an equilibrium, and MuJoCo's mjd_transitionFD returns discrete-time \(A,B\) directly by finite differences. Automating Lyapunov certificates: sums-of-squares (SOS) programming searches over polynomial \(V\); LQR-Trees (Tedrake et al., 2010) uses it to verify the region of attraction of each LQR controller and stitch them into "funnels" covering the state space; other work learns \(V\) with a neural network and then verifies it (Chang et al., 2019). Observers: many servo drives estimate velocity with an observer rather than by differencing; the Kalman filter (Lesson 4.8) is the observer that is optimal for given noise statistics, and in visual-inertial odometry global position and heading are unobservable (Lesson 15.1).
8常见误区Common pitfalls
特征值只担保局部稳定。FIG 1 里离开平衡点 60° 线性化误差已超过 15%;FIG 2 里线性化导出的证书只覆盖约 44°;FIG 4 里闭环极点都在左半平面,力矩一受限,摆照样摔倒。设计完线性控制器,一定要在非线性模型上(带饱和、带延迟)仿真,并想清楚它要在多大的范围内工作。
Eigenvalues guarantee only local stability. In FIG 1 the linearization error passes 15% by 60° from the equilibrium; in FIG 2 the certificate derived from the linearization covers only about 44°; in FIG 4 the closed-loop poles are all in the left half-plane, yet with limited torque the pendulum still falls. After designing a linear controller, always simulate it on the nonlinear model (with saturation and delay) and be clear about the range it must work over.
对固定的 \(A\),特征值决定最终是否衰减,却不管中途。\(A=\begin{bmatrix}-1&20\\0&-2\end{bmatrix}\) 的特征值是 \(-1,-2\),可 \(\|e^{At}\|\) 在 \(t\approx0.69\) s 时达到约 5.0:状态先放大 5 倍再衰减(非正规矩阵的"瞬态增长"),足以撞上饱和或关节限位。对时变系统更糟:Markus–Yamabe(1960)的例子里 \(A(t)\) 在每一时刻的特征值都是 \(-0.25\pm0.66j\),解却按 \(e^{t/2}\) 增长(10 s 后放大约 148 倍)。"冻结时间看特征值"对时变或非线性系统不是证明。
For a fixed \(A\) the eigenvalues decide whether the state eventually decays, not what happens on the way. \(A=\begin{bmatrix}-1&20\\0&-2\end{bmatrix}\) has eigenvalues \(-1,-2\), yet \(\|e^{At}\|\) peaks at about 5.0 around \(t\approx0.69\) s: the state is amplified 5× before it decays (the "transient growth" of non-normal matrices), enough to hit saturation or a joint limit. For time-varying systems it is worse: in the Markus–Yamabe (1960) example \(A(t)\) has eigenvalues \(-0.25\pm0.66j\) at every instant, yet solutions grow like \(e^{t/2}\) (about 148× after 10 s). "Freeze time and look at the eigenvalues" is not a proof for time-varying or nonlinear systems.
李雅普诺夫定理是充分条件。FIG 2 的朴素二次型在稳定的摆上也会上升,那只说明这个 \(V\) 选错了,什么也没证明。反过来,\(\dot V\le0\) 只给出"稳定",要得到"渐近稳定"还需要严格不等式或 LaSalle 原理;摆的能量在 \(b=0\) 时 \(\dot V\equiv0\),摆就永远摆下去,这时它稳定但不渐近稳定。要证明不稳定,需要另外的定理(如 Chetaev 定理)或一个正实部的线性化特征值。
Lyapunov's theorem is a sufficient condition. FIG 2's naive quadratic rises even on a stable pendulum; that only says this \(V\) was a bad choice and proves nothing. Conversely, \(\dot V\le0\) gives only "stable"; "asymptotically stable" needs a strict inequality or LaSalle's principle. At \(b=0\) the pendulum's energy has \(\dot V\equiv0\) and it swings forever: stable, but not asymptotically. To prove instability you need a different theorem (such as Chetaev's) or a linearized eigenvalue with positive real part.
秩判据是非黑即白的,可控程度却是连续的。FIG 3 的"两个一阶模态"里,默认的 \(B\)(45°)到达默认目标需要能量 0.81;\(B\) 离特征方向只差 10° 时涨到约 14.4,差 5.1°(刚好在吸附范围外)时约 70。极点也一样:能放不代表该放,重极点 \(-p\) 的增益按 \(p^2\) 增长,很快撞上力矩上限、放大传感器噪声,并让采样延迟变得致命(FIG 4、FIG 5)。看 \(W_T\) 的最小特征值或 \(\mathcal C\) 的条件数,而不只看秩。
The rank test is black and white; how controllable a system is, is not. In FIG 3's "two first-order modes", the default \(B\) (at 45°) reaches the default target with energy 0.81; with \(B\) only 10° off an eigen-direction that rises to about 14.4, and at 5.1° (just outside the snapping zone) to about 70. Poles are the same: being able to place them does not mean you should; a double pole at \(-p\) needs gains growing like \(p^2\), which quickly hit the torque limit, amplify sensor noise and make sampling delay fatal (FIG 4, FIG 5). Look at the smallest eigenvalue of \(W_T\) or the condition number of \(\mathcal C\), not just the rank.
\(A_d=I+AT\) 写起来最省事,但它会把稳定的弱阻尼振子预测成发散(FIG 5 中 \(T>0.033\) s),把快模态预测成正负跳动;放进 MPC 里,优化器会认真地"利用"这些假动态。另一方面,即使模型精确,真实的数字回路也比连续设计更不稳定,因为保持器带来约 \(T/2\) 的延迟:FIG 5 的控制器在 \(T=0.211\) s 失稳,而欧拉模型说能撑到 0.4 s。离散化用 expm 或 cont2discrete(..., method='zoh'),并在真实的采样周期下检查 \(A_d-B_dK\) 的特征值。
\(A_d=I+AT\) is the easiest to write, but it predicts that a stable, lightly damped oscillator diverges (in FIG 5 for \(T>0.033\) s) and that fast modes flip sign; put it inside MPC and the optimizer will dutifully "exploit" those fake dynamics. On the other hand, even with an exact model the real digital loop is less stable than the continuous design, because the hold adds a delay of about \(T/2\): FIG 5's controller goes unstable at \(T=0.211\) s, while the Euler model claims it holds until 0.4 s. Discretize with expm or cont2discrete(..., method='zoh'), and check the eigenvalues of \(A_d-B_dK\) at the real sampling period.
9小练习Check yourself
10延伸阅读Further reading
- K. J. Åström & R. M. Murray, Feedback Systems: An Introduction for Scientists and Engineers, Princeton University Press, 2008 (2nd ed. 2021) — 动态行为、线性系统、状态反馈与输出反馈的几章是本节最好的入门读物(在线免费)The chapters on dynamic behaviour, linear systems, state feedback and output feedback are the best companion to this lesson (free online)
- H. K. Khalil, Nonlinear Systems, 3rd ed., Prentice Hall, 2002, Ch. 4 — 李雅普诺夫稳定性、LaSalle 原理、线性化与吸引域估计Lyapunov stability, LaSalle's principle, linearization and region-of-attraction estimates
- J.-J. E. Slotine & W. Li, Applied Nonlinear Control, Prentice Hall, 1991 — 相平面分析与李雅普诺夫方法,面向工程师Phase-plane analysis and Lyapunov methods, written for engineers
- G. F. Franklin, J. D. Powell & M. L. Workman, Digital Control of Dynamic Systems, 3rd ed., Addison-Wesley, 1998 — 零阶保持离散化、采样率选择与数字控制器设计Zero-order-hold discretization, choosing the sample rate, and digital controller design
- R. Tedrake, Underactuated Robotics, MIT course notes — 摆、小车倒立摆、李雅普诺夫分析与平方和验证的机器人视角(在线免费)The pendulum, the cart-pole, Lyapunov analysis and sums-of-squares verification from a robotics viewpoint (free online)
- A. M. Lyapunov, The General Problem of the Stability of Motion, 1892; English translation by A. T. Fuller, Int. J. Control 55(3), 1992 — 直接法与间接法的出处The origin of the direct and indirect methods
- R. E. Kalman, On the General Theory of Control Systems, Proc. 1st IFAC Congress, Moscow, 1960 — 可控性与可观性的概念及对偶性The concepts of controllability and observability, and their duality
- D. G. Luenberger, Observing the State of a Linear System, IEEE Trans. Military Electronics 8(2), 1964 — 龙伯格观测器The Luenberger observer
- R. Tedrake, I. R. Manchester, M. Tobenkin & J. W. Roberts, LQR-Trees: Feedback Motion Planning via Sums-of-Squares Verification, Int. J. Robotics Research 29(8), 2010 — 用 SOS 验证的吸引域把局部线性控制器拼成全局控制器Stitching local linear controllers into a global one with SOS-verified regions of attraction