Skip to content

比较不同增益的轨迹 ​

如果只改变方程中的增益,响应是整体放大,还是到达稳态的速度也变了?用同一个一阶模型运行三次,再按时间对齐比较所有采样点。

保存三组响应 ​

使用首课保存的 first_order.py,在脚本目录执行;在源码工作区也可以用 packages/fly_ruler/examples/mainline/first_order.py 代替脚本名。

bash
python first_order.py --gain 1 2 3 --output results

三次运行都从零初态出发,输入、步长和后端不变。程序只替换参数向量,不重新编译。文件 results/first_order.csv 按时间、增益 1、增益 2、增益 3 的顺序写入四列。

检查整条曲线 ​

python
import numpy as np

time, one, two, three = np.loadtxt("results/first_order.csv", delimiter=",").T
np.testing.assert_allclose(two, 2 * one)
np.testing.assert_allclose(three, 3 * one)
print(len(time), time[-1], three[-1])

共 51 个样本,包括初态和随后 50 步。5 s 末增益 3 的响应约为 2.984539;两次逐点比较均成立,说明变的是幅度。要在浏览器里查看同一组结果,重跑命令并加 --show。