fly_ruler_std.blocks.physics
本页由
fr-docs-dev gen-api从源码 docstring 生成,请勿手工编辑;重新生成执行just api。
物理 Block:重力、地面接触与六自由度刚体。
公开成员
定义
ConstantGravity
python
def ConstantGravity(cfg: ConstantGravityConfig = _DEFAULT_CONSTANT_GRAVITY_CONFIG) -> None构造 NED 系下的常值重力模型。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cfg | ConstantGravityConfig | _DEFAULT_CONSTANT_GRAVITY_CONFIG | 重力配置,给出 g0、质量来源与质量取值。 |
NOTE
输出 g_ned 为 NED 系重力力矢量 [0, 0, mass * g0],单位 N;参数 g0 为重力加速度。cfg.enable_external_mass 为 True 时质量来自输入 mass,否则来自参数 mass。效应 gravity_norm 记录重力大小。
python
@fr.system
def Sys():
gravity = ConstantGravity("gravity")
fr.export(g_ned=gravity.g_ned)实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:27
ConstantGravityConfig
python
class ConstantGravityConfig(BaseModel)常值重力模型的编译期配置。
g0
python
g0: float = 9.80665重力加速度常数,单位 m/s^2,默认 9.80665。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:12
enable_external_mass
python
enable_external_mass: bool = False质量是否由外部输入提供,为 False 时声明为参数。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:16
mass
python
mass: list[float] = [1.0]飞行器质量向量,单位 kg,仅在质量为参数时使用。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:20
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:9
GroundContact
python
def GroundContact(cfg: GroundContactConfig) -> None聚合并配置任意数量的轮、滑橇或着陆接触点。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cfg | GroundContactConfig | — | 地面接触配置,含启用开关、摩擦尺度与接触点列表。 |
NOTE
输入为质心 NED 位置 position、机体系速度 velocity_body、体到 NED 的 dcm 与机体系角速度 omega_body。每个接触点实例以配置中的 name 命名。导出 force_body、moment_body、 penetrations、normal_forces、longitudinal_forces、 lateral_forces 与 contact_count。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:331
GroundContactConfig
python
class GroundContactConfig(BaseModel)平直地面子系统的编译期开关与接触数据。
enabled
python
enabled: bool = False是否启用地面接触,为 False 时法向力与接触计数恒为 0。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:71
ground_down
python
ground_down: float = 0.0地面在 NED 系下的 Down 坐标,单位 m。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:73
friction_velocity_scale
python
friction_velocity_scale: float = 0.1摩擦速度正则化尺度,必须为正数,单位 m/s。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:75
contacts
python
contacts: list[GroundContactPointConfig]接触点配置列表,至少一个且名称互不重复。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:77
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:68
GroundContactPoint
python
def GroundContactPoint(cfg: GroundContactPointConfig, friction_velocity_scale: float, enabled: bool) -> None构造单个接触点的法向支撑与水平摩擦力 Block。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cfg | GroundContactPointConfig | — | 该接触点的几何与力学配置。 |
friction_velocity_scale | float | — | 摩擦速度正则化尺度,单位 m/s。 |
enabled | bool | — | 是否启用接触,为 False 时法向力与接触标志恒为 0。 |
NOTE
输入为质心 NED 位置 position、机体系速度 velocity_body、体到 NED 的 dcm、机体系角速度 omega_body 与地面 Down 坐标 ground_down。法向力由穿透量与闭合速度经刚度、阻尼计算并截断到 max_normal_force;摩擦力按水平速度分解为纵向滚动阻力与侧向摩擦。输出 force_body、moment_body、penetration、 normal_force、longitudinal_force、lateral_force 与 contact。
python
cfg = GroundContactPointConfig(
name="nose",
point_body=[2.0, 0.0, 0.5],
normal_stiffness=1.0e5,
normal_damping=1.0e3,
max_normal_force=1.0e5,
)
contact = GroundContactPoint("nose", cfg, 0.1, True)实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:210
GroundContactPointConfig
python
class GroundContactPointConfig(BaseModel)相对质心(FRD 机体系)的一个轮、滑橇或着陆接触点。
name
python
name: str接触点名称,必须是合法的 FlyRuler 组件名。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:15
point_body
python
point_body: list[float]接触点在 FRD 机体系下的坐标 [x, y, z],单位 m。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:17
normal_stiffness
python
normal_stiffness: float法向接触刚度,必须为正数,单位 N/m。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:19
normal_damping
python
normal_damping: float法向接触阻尼,必须非负。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:21
rolling_resistance_coefficient
python
rolling_resistance_coefficient: float = 0.02滚动阻力系数,默认 0.02,必须非负。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:23
lateral_friction_coefficient
python
lateral_friction_coefficient: float = 0.5侧向摩擦系数,默认 0.5,必须非负。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:25
max_normal_force
python
max_normal_force: float法向力上限,必须为正数,单位 N。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:27
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:12
RigidBody6DOFConfig
python
class RigidBody6DOFConfig(BaseModel)六自由度刚体的编译期配置。
enable_external_mass
python
enable_external_mass: bool = False质量、惯量与惯量逆是否由外部输入提供。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:17
enable_geodetic_output
python
enable_geodetic_output: bool = True是否声明 ref_lla 参数与 pos_lla 输出。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:19
ref_lla
python
ref_lla: list[float] = [0.0, 0.0, 0.0]参考大地坐标 [纬度, 经度, 高度],单位 deg,deg,m。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:24
mass
python
mass: float = 1.0飞行器质量,单位 kg,默认 1.0。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:28
inertia
python
inertia: list[list[float]] = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]惯量矩阵,单位 kg*m^2,默认 3x3 单位阵。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:30
inertia_inv
python
inertia_inv: list[list[float]] = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]惯量矩阵的逆,默认 3x3 单位阵。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:35
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:14
RigidBody6DOFMatrix
python
def RigidBody6DOFMatrix(cfg: RigidBody6DOFConfig = _DEFAULT_CONFIG) -> None构造以旋转矩阵存储姿态的六自由度刚体 Block。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cfg | RigidBody6DOFConfig | _DEFAULT_CONFIG | 刚体配置,给出质量、惯量来源、大地坐标输出与参考点。 |
NOTE
动力学方程与 RigidBody6DOFQuaternion 相同,但姿态状态是 3x3 的 SO(3) 旋转矩阵 rotation_matrix,对应输出 rotation_matrix_out。输入、其余状态与输出端口一致。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:234
RigidBody6DOFQuaternion
python
def RigidBody6DOFQuaternion(cfg: RigidBody6DOFConfig = _DEFAULT_CONFIG) -> None构造以四元数存储姿态的六自由度刚体 Block。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cfg | RigidBody6DOFConfig | _DEFAULT_CONFIG | 刚体配置,给出质量、惯量来源、大地坐标输出与参考点。 |
NOTE
输入为机体系力 force_body 与力矩 moment_body。状态为 pos_ned、vel_body、SO(3) 四元数 quat 与 omega_body。输出含 pos_ned_out、vel_body_out、quat_out 与 omega_body_out,以及 velocity_ned、euler_angles、DCM、 gamma、chi、acceleration_body 与 angular_acceleration_body;启用大地输出时另有 pos_lla。 cfg.enable_external_mass 为 True 时质量与惯量来自输入,否则来自参数。
python
@fr.system
def Sys():
force = fr.input("force", (3,))
moment = fr.input("moment", (3,))
cfg = RigidBody6DOFConfig(enable_geodetic_output=False)
body = RigidBody6DOFQuaternion("body", cfg)
force >> body.force_body
moment >> body.moment_body
fr.export(dcm=body.DCM)实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/rigid_body_6dof.py:45
solve_static_ground_pose
python
def solve_static_ground_pose(cfg: GroundContactConfig, weight: float) -> np.ndarray求解静力支撑下的位姿。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cfg | GroundContactConfig | — | 地面接触配置,必须已启用且至少包含 3 个接触点。 |
weight | float | — | 飞行器重量,单位 N,必须为正且有限。 |
返回
| 类型 | 说明 |
|---|---|
np.ndarray | np.ndarray: 长度为 3 的位姿 [down, roll, pitch],单位 m 与 rad。 |
异常
| 类型 | 说明 |
|---|---|
ValueError | 未启用接触、接触点少于 3 个、重量非正、支撑多边形 退化、质心落在支撑多边形外、静载超过法向力上限、雅可比 奇异或迭代不收敛时抛出。 |
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/ground_contact.py:100
WGS84Gravity
python
def WGS84Gravity(cfg: WGS84GravityConfig = _DEFAULT_WGS84_GRAVITY_CONFIG) -> None构造带高度修正的 WGS84 Somigliana 重力模型。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cfg | WGS84GravityConfig | _DEFAULT_WGS84_GRAVITY_CONFIG | 重力配置,给出质量来源与质量取值。 |
NOTE
输入 lla 为大地坐标 [纬度, 经度, 高度],单位 deg,deg,m;输出 g_ned 为 NED 系重力力矢量,单位 N。模型先按 Somigliana 公式由纬度计算海平面重力,再按 (re / (re + h))^2 做反平方高度修正。质量来自输入或参数 mass。
python
@fr.system
def Sys():
lla = fr.input("lla", (3,))
gravity = WGS84Gravity("gravity")
lla >> gravity.lla
fr.export(g_ned=gravity.g_ned)实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:90
WGS84GravityConfig
python
class WGS84GravityConfig(BaseModel)WGS84 重力模型的编译期配置。
enable_external_mass
python
enable_external_mass: bool = False质量是否由外部输入提供,为 False 时声明为参数。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:79
mass
python
mass: list[float] = [1.0]飞行器质量向量,单位 kg,仅在质量为参数时使用。
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:83
实现位置:packages/fly_ruler/python/fly_ruler_std/blocks/physics/gravity.py:76