fly_ruler_std.libs.coordinates
本页由
fr-docs-dev gen-api从源码 docstring 生成,请勿手工编辑;重新生成执行just api。
Signal 优先的坐标与导航工具。
函数构造 FlyRuler Signal 表达式,供 @fr.block 声明使用。对外单位约定为 SI:速度用 m/s、角度用 rad;地理坐标字段 [lat, lon, alt] 中经纬度为度、高度为 m。
公开成员
定义
body_vel_to_aero
python
def body_vel_to_aero(uvw: Signal) -> tuple[Signal, Signal, Signal]把机体系速度转换为气动角 (真空速、攻角、侧滑角)。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
uvw | Signal | — | 机体系速度向量 (3,) [u, v, w] (m/s)。 |
返回
| 类型 | 说明 |
|---|---|
(v_tas, alpha, beta) | 真空速 (m/s)、攻角 (rad)、侧滑角 (rad)。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import body_vel_to_aero
@fr.block
def AirData():
uvw = fr.input("uvw", (3,), unit="m/s")
v_tas, alpha, beta = body_vel_to_aero(uvw)
fr.output("alpha", alpha, dim=(1,), unit="rad")实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:31
body_vel_to_aero_regularized
python
def body_vel_to_aero_regularized(uvw: Signal, *, speed_epsilon: float = 0.001) -> tuple[Signal, Signal, Signal]把前飞状态下的机体系速度转换为可微气动角。
本函数假设前飞:它在零速处平滑趋近零攻角与零侧滑角,不能用于表示反向飞行。speed_epsilon 与 uvw 使用相同速度单位。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
uvw | Signal | — | 机体系速度向量 (3,) [u, v, w] (m/s)。 |
speed_epsilon | float | 0.001 | 平滑参数,与 uvw 同速度单位,默认 1.0e-3。 |
返回
| 类型 | 说明 |
|---|---|
(v_tas, alpha, beta) | 平滑真空速 (m/s)、攻角 (rad)、侧滑角 (rad)。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import body_vel_to_aero_regularized
@fr.block
def AirData():
air_velocity = fr.input("air_velocity", (3,), unit="m/s")
v_tas, alpha, beta = body_vel_to_aero_regularized(air_velocity)
fr.output("v_tas", v_tas, dim=(1,), unit="m/s")实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:60
horizontal_velocity_direction
python
def horizontal_velocity_direction(velocity_ned: Signal, *, speed_epsilon: float = 0.001) -> Signal返回连续的水平方向向量,而不是航向角。
该向量随水平速度趋近于零;与航向角不同,它在零速处仍有定义。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
velocity_ned | Signal | — | NED 系速度向量 (3,) (m/s)。 |
speed_epsilon | float | 0.001 | 平滑参数,与 velocity_ned 同速度单位,默认 1.0e-3。 |
返回
| 类型 | 说明 |
|---|---|
Signal | 水平方向单位向量 (2,)。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import horizontal_velocity_direction
@fr.block
def GroundTrack():
vel_ned = fr.input("vel_ned", (3,), unit="m/s")
fr.output("track", horizontal_velocity_direction(vel_ned), dim=(2,))实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:98
aero_to_body_vel
python
def aero_to_body_vel(v_tas: Signal, alpha: Signal, beta: Signal) -> Signal把气动角转换为机体系速度向量。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
v_tas | Signal | — | 真空速 (m/s)。 |
alpha | Signal | — | 攻角 (rad)。 |
beta | Signal | — | 侧滑角 (rad)。 |
返回
| 类型 | 说明 |
|---|---|
Signal | 机体系速度向量 (3,) (m/s)。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import aero_to_body_vel
@fr.block
def BodyVelocity():
v_tas = fr.input("v_tas", (1,), unit="m/s")
alpha = fr.input("alpha", (1,), unit="rad")
beta = fr.input("beta", (1,), unit="rad")
fr.output("uvw", aero_to_body_vel(v_tas, alpha, beta), dim=(3,))实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:127
ned_vel_to_flight_path
python
def ned_vel_to_flight_path(velocity_ned: Signal) -> tuple[Signal, Signal]由 NED 地速求正爬升航迹角与从北向东的航向角。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
velocity_ned | Signal | — | NED 速度 (3,) [north,east,down],m/s。 |
返回
| 类型 | 说明 |
|---|---|
Signal | (gamma,chi),均为 rad。gamma=atan2(-V_D,sqrt(V_N²+V_E²+epsilon²)), |
Signal | chi=atan2(V_E,V_N),epsilon=1e-3 m/s。 |
NOTE
水平速度的正则化使静止时 gamma 导数有限;chi 在静止时没有物理方向,不保证该点的导数。FRD 速度需先按 BODY→NED 姿态旋转,不能直接传入。
实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:159
ned_position_to_geodetic
python
def ned_position_to_geodetic(pos_ned: Signal, ref_lla: Signal) -> Signal把 NED 相对位置转换为 WGS-84 地理坐标。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
pos_ned | Signal | — | NED 位移向量 (3,) [n, e, d] (m)。 |
ref_lla | Signal | — | 参考点 [lat(deg), lon(deg), alt(m)] (3,)。 |
返回
| 类型 | 说明 |
|---|---|
Signal | 地理坐标 (3,) [lat(deg), lon(deg), alt(m)]。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import ned_position_to_geodetic
@fr.block
def Geodetic():
pos_ned = fr.input("pos_ned", (3,), unit="m")
ref_lla = fr.param("ref_lla", (3,), default=[0.0, 0.0, 0.0])
fr.output("lla", ned_position_to_geodetic(pos_ned, ref_lla), dim=(3,))实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:179
geodetic_to_ned_position
python
def geodetic_to_ned_position(lla: Signal, ref_lla: Signal) -> Signal把 WGS-84 地理坐标转换为 NED 相对位置。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
lla | Signal | — | 地理坐标 (3,) [lat(deg), lon(deg), alt(m)]。 |
ref_lla | Signal | — | 参考点 [lat(deg), lon(deg), alt(m)] (3,)。 |
返回
| 类型 | 说明 |
|---|---|
Signal | NED 位移向量 (3,) [n, e, d] (m)。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import geodetic_to_ned_position
@fr.block
def NedPosition():
lla = fr.input("lla", (3,))
ref_lla = fr.param("ref_lla", (3,), default=[0.0, 0.0, 0.0])
fr.output("pos_ned", geodetic_to_ned_position(lla, ref_lla), dim=(3,))实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:220
ned_to_body
python
def ned_to_body(q_bn: Signal, v_ned: Signal) -> Signal把 NED 向量旋转到机体坐标系。
q_bn 是历史参数名;其实际语义与 RigidBody6DOFQuaternion.quat 一致,表示 Body → NED。函数内部取共轭,因此把 v_ned 视为纯四元数时 v_body = q_bn^* * v_ned * q_bn。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
q_bn | Signal | — | Body→NED 的姿态四元数 (4, scalar-first)。 |
v_ned | Signal | — | NED 系中的向量 (3,)。 |
返回
| 类型 | 说明 |
|---|---|
Signal | 机体坐标系中的向量 (3,)。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import ned_to_body
@fr.block
def VelocityBody():
quat = fr.input("quat", (4,))
vel_ned = fr.input("vel_ned", (3,), unit="m/s")
vel_body = Quaternion.rotate_vector(Quaternion.conjugate(quat), vel_ned)
fr.output("vel_body", vel_body, dim=(3,))实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:261
body_to_ned
python
def body_to_ned(q_bn: Signal, v_body: Signal) -> Signal把机体坐标系向量旋转到 NED 坐标系。
等价于 v_ned = q_bn * v_body * q_bn^*。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
q_bn | Signal | — | Body→NED 的姿态四元数 (4, scalar-first)。 |
v_body | Signal | — | 机体坐标系中的向量 (3,)。 |
返回
| 类型 | 说明 |
|---|---|
Signal | NED 坐标系中的向量 (3,)。 |
python
import fly_ruler_core as fr
from fly_ruler_std.libs.coordinates import body_to_ned
@fr.block
def VelocityNed():
quat = fr.input("quat", (4,))
vel_body = fr.input("vel_body", (3,), unit="m/s")
fr.output("vel_ned", Quaternion.rotate_vector(quat, vel_body), dim=(3,))实现位置:packages/fly_ruler/python/fly_ruler_std/libs/coordinates.py:294