fr_gtm.init
本页由
fr-docs-dev gen-api从源码 docstring 生成,请勿手工编辑;重新生成执行just api。
从物理初值构造 GTM 向量、外部噪声与可读观测。
公开成员
| 名称 | 类型 | 定义位置 |
|---|---|---|
init | 函数 | 本页 |
Initializer | 类 | 本页 |
build_input | 函数 | 本页 |
sample_disturbance | 函数 | 本页 |
sample_sensor_noise | 函数 | 本页 |
read_observation | 函数 | 本页 |
Observation | 类 | 本页 |
Uncertainty | 类 | 本页 |
定义
init
python
def init(model: RuntimeInstance[T], cfg: GTMConfig, *, position: Vector = (0.0, 0.0, -1000.0), airdata: Vector = (0.0, 0.0, 100.0), euler: Vector = (0.0, 0.0, 0.0), command: Vector = (0.0, 0.0, 0.0, 40.0), wind: Vector = (0.0, 0.0, 0.0), uncertainty: Uncertainty | None = None, rates: Vector = (0.0, 0.0, 0.0), paths: GTMPaths = ROOT_PATHS) -> tuple[T, T, T, T]把位置、气流、姿态、命令和参数直接转换为 x、xd、u、p。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model | RuntimeInstance[T] | — | 与 cfg 对应的编译模型,返回值保留该后端的数组类型。 |
cfg | GTMConfig | — | 生产模型配置,决定发动机滞后状态的阶数和配平映射。 |
position | Vector | (0.0, 0.0, -1000.0) | NED (x,y,z),m,高度为 -z。 |
airdata | Vector | (0.0, 0.0, 100.0) | (alpha_deg,beta_deg,VTAS_mps),TAS 不小于零。 |
euler | Vector | (0.0, 0.0, 0.0) | (phi,theta,psi),deg。 |
command | Vector | (0.0, 0.0, 0.0, 40.0) | 三个实际舵面初值和命令(deg),以及油门初值和命令(%)。 |
wind | Vector | (0.0, 0.0, 0.0) | (参考风速m/s,风来自方向deg,湍流等级),风向转为参数中的 rad。 |
uncertainty | Uncertainty | None | None | 运行时相对增量,省略的项使用模型参数默认值。 |
rates | Vector | (0.0, 0.0, 0.0) | 初始机体系 (p,q,r),deg/s。 |
paths | GTMPaths | ROOT_PATHS | 默认 Root,也可指向嵌套实例。 |
返回
| 类型 | 说明 |
|---|---|
tuple[T, T, T, T] | (x,xd,u,p),噪声和 Dryden 状态为零。初始化不是飞行配平。 |
异常
| 类型 | 说明 |
|---|---|
ValueError | 初值形状不匹配、包含非有限值或 TAS 为负。 |
NOTE
v_air=VTAS*[cos(alpha)cos(beta),sin(beta),sin(alpha)cos(beta)]。给定姿态/高度/参数后,读取现有 Wind effects 的稳态风,再令v_body=v_air+wind_body,不复制风切变公式。零速气流角沿用模型正则化约定。其他子系统状态使用 model.x 的默认值;不裁剪调用方提供的命令。
实现位置:models/fr_gtm/src/fr_gtm/init.py:281
Initializer
python
class Initializer(model: RuntimeInstance[T], cfg: GTMConfig, *, paths: GTMPaths = ROOT_PATHS)预编译的后端原生初值构造器;可在外部套 JAX jit/vmap/jacfwd。
NOTE
在 JAX 变换外构造一次,调用时不转 NumPy、不抽取 Python float、不生成随机数。输入须有限且 TAS 非负;该原生路径只做静态形状/参数名称检查。需要数值校验的普通脚本使用 init。
运算符
| 运算符 | 方法 | 说明 |
|---|---|---|
() | __call__ | 从原生数组或普通数值序列构造 x/xd/u/p。 |
__init__
python
def __init__(model: RuntimeInstance[T], cfg: GTMConfig, *, paths: GTMPaths = ROOT_PATHS) -> None绑定生产模型与配置并编译共享运动学图。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model | RuntimeInstance[T] | — | 生产模型,输入输出保持其后端类型。 |
cfg | GTMConfig | — | 与生产模型一致的配置。 |
paths | GTMPaths | ROOT_PATHS | 生产实例路径目录。 |
异常
| 类型 | 说明 |
|---|---|
ValueError | 模型不是支持的 NumPy、CasADi 或 JAX 后端。 |
实现位置:models/fr_gtm/src/fr_gtm/init.py:155
实现位置:models/fr_gtm/src/fr_gtm/init.py:146
build_input
python
def build_input(model: RuntimeInstance[T], command: Vector | T, *, d: Vector | T | None = None, n: Vector | T | None = None, paths: GTMPaths = ROOT_PATHS) -> T按路径打包命令、Dryden 激励和传感器噪声;省略的噪声置零。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model | RuntimeInstance[T] | — | 目标后端的编译模型。 |
command | Vector | T | — | [升降舵deg,副翼deg,方向舵deg,油门%]。 |
d | Vector | T | None | None | 四路风激励,默认零。 |
n | Vector | T | None | None | 17 路标准化传感器噪声,默认零。 |
paths | GTMPaths | ROOT_PATHS | 模型实例前缀。 |
返回
| 类型 | 说明 |
|---|---|
T | 目标后端的完整 u 向量,不生成随机数或裁剪命令。 |
NOTE
JAX 输入保留原生数组,支持 jit/vmap,调用方保证数值有限;其他后端执行主机数值校验。
实现位置:models/fr_gtm/src/fr_gtm/init.py:77
sample_disturbance
python
def sample_disturbance(rng: np.random.Generator) -> NumpyArray生成四路均值 0、标准差 π 的 Dryden 激励,匹配 gtm_ad.create_disturbance。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
rng | np.random.Generator | — | 调用方持有的随机数发生器,不修改全局随机状态。 |
返回
| 类型 | 说明 |
|---|---|
NumpyArray | 形状 (4,);不额外按 dt 缩放,外部每次更新后在整个积分步内保持。 |
实现位置:models/fr_gtm/src/fr_gtm/init.py:53
sample_sensor_noise
python
def sample_sensor_noise(rng: np.random.Generator) -> NumpyArray生成 17 路标准正态传感器噪声,通道标准差由 Sensor 内部施加。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
rng | np.random.Generator | — | 调用方持有的随机数发生器。 |
返回
| 类型 | 说明 |
|---|---|
NumpyArray | 形状 (17,);与 gtm_ad.create_sensor_noise 分布一致,去掉旧命令通道。 |
实现位置:models/fr_gtm/src/fr_gtm/init.py:65
read_observation
python
def read_observation(model: RuntimeInstance[T], packed_y: T | NumpyArray, *, measured: bool = False, paths: GTMPaths = ROOT_PATHS) -> Observation解析打包输出为带单位的物理观测;默认 clean_y,可选择带误差的 y。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model | RuntimeInstance[T] | — | 输出所属的编译模型。 |
packed_y | T | NumpyArray | — | continuous_fn/discrete_fn 返回的完整 y 向量。 |
measured | bool | False | True 读取 y,False 读取 clean_y。 |
paths | GTMPaths | ROOT_PATHS | 模型实例前缀。 |
返回
| 类型 | 说明 |
|---|---|
Observation | 主机标量/元组组成的 Observation,不重复解析状态或 effects。 |
实现位置:models/fr_gtm/src/fr_gtm/init.py:387
Observation
python
class Observation(gamma_deg: float, alpha_deg: float, beta_deg: float, tas_mps: float, altitude_m: float, euler_deg: tuple[float, float, float], body_rates_deg_s: tuple[float, float, float], nz: float, qbar_pa: float, surfaces_deg: tuple[float, float, float], throttle_percent: float)17 个物理观测的主机数值表示,所有角度/角速率使用 deg、deg/s。
属性
| 名称 | 类型 | 说明 |
|---|---|---|
gamma_deg | float | 正爬升航迹角。 |
alpha_deg | float | 迎角。 |
beta_deg | float | 侧滑角。 |
tas_mps | float | 真空速,m/s。 |
altitude_m | float | 正向上高度,m。 |
euler_deg | tuple[float, float, float] | (phi,theta,psi)。 |
body_rates_deg_s | tuple[float, float, float] | (p,q,r)。 |
nz | float | 向上为正的法向过载。 |
qbar_pa | float | 动压,Pa。 |
surfaces_deg | tuple[float, float, float] | (elevator,aileron,rudder) 实际位置。 |
throttle_percent | float | 实际有效油门,%。 |
gamma_deg
python
gamma_deg: float实现位置:models/fr_gtm/src/fr_gtm/init.py:374
alpha_deg
python
alpha_deg: float实现位置:models/fr_gtm/src/fr_gtm/init.py:375
beta_deg
python
beta_deg: float实现位置:models/fr_gtm/src/fr_gtm/init.py:376
tas_mps
python
tas_mps: float实现位置:models/fr_gtm/src/fr_gtm/init.py:377
altitude_m
python
altitude_m: float实现位置:models/fr_gtm/src/fr_gtm/init.py:378
euler_deg
python
euler_deg: tuple[float, float, float]实现位置:models/fr_gtm/src/fr_gtm/init.py:379
body_rates_deg_s
python
body_rates_deg_s: tuple[float, float, float]实现位置:models/fr_gtm/src/fr_gtm/init.py:380
nz
python
nz: float实现位置:models/fr_gtm/src/fr_gtm/init.py:381
qbar_pa
python
qbar_pa: float实现位置:models/fr_gtm/src/fr_gtm/init.py:382
surfaces_deg
python
surfaces_deg: tuple[float, float, float]实现位置:models/fr_gtm/src/fr_gtm/init.py:383
throttle_percent
python
throttle_percent: float实现位置:models/fr_gtm/src/fr_gtm/init.py:384
__init__
python
def __init__(gamma_deg: float, alpha_deg: float, beta_deg: float, tas_mps: float, altitude_m: float, euler_deg: tuple[float, float, float], body_rates_deg_s: tuple[float, float, float], nz: float, qbar_pa: float, surfaces_deg: tuple[float, float, float], throttle_percent: float) -> None实现位置:models/fr_gtm/src/fr_gtm/init.py
实现位置:models/fr_gtm/src/fr_gtm/init.py:356
Uncertainty
python
class Uncertainty(TypedDict)相对扰动;省略的组使用编译模型的参数默认值。
属性
| 名称 | 类型 | 说明 |
|---|---|---|
weight | float | 重量相对增量,例如 0.03 表示增加 3%。 |
inertia | Vector | 六元 [Ixx,Iyy,Izz,Ixz,Iyz,Ixy] 相对增量。 |
c_static | Vector | 六元 [CX,CY,CZ,Cl,Cm,Cn] 静态系数相对增量。 |
c_e | Vector | 三元 [CX,CZ,Cm] 升降舵系数相对增量。 |
c_a | Vector | 六元副翼系数相对增量。 |
c_r | Vector | 六元方向舵系数相对增量。 |
weight
python
weight: float实现位置:models/fr_gtm/src/fr_gtm/init.py:38
inertia
python
inertia: Vector实现位置:models/fr_gtm/src/fr_gtm/init.py:39
c_static
python
c_static: Vector实现位置:models/fr_gtm/src/fr_gtm/init.py:40
c_e
python
c_e: Vector实现位置:models/fr_gtm/src/fr_gtm/init.py:41
c_a
python
c_a: Vector实现位置:models/fr_gtm/src/fr_gtm/init.py:42
c_r
python
c_r: Vector实现位置:models/fr_gtm/src/fr_gtm/init.py:43
实现位置:models/fr_gtm/src/fr_gtm/init.py:26