飞机游戏三 JSBSim介绍
目录1 介绍
JSBSim Open Source Flight Dynamics Model (sourceforge.net)
发布 ·JSBSim-Team/jsbsim ·GitHub
2 xml配置文件解析
【jsbsim学习】飞行器模型配置文件解读 - 知乎 (zhihu.com)
3 气动力模型
【jsbsim学习】标准大气模型 - 知乎 (zhihu.com)
4 基本状态和动作
1 简易demo
import jsbsim
# FDM Initialization 空气动力学模型初始化
fdm = jsbsim.FGFDMExec(None) # Use JSBSim default aircraft data.
# FDM Initialization 空气动力学模型初始化
self.fdm = jsbsim.FGFDMExec(None)
# Aircraft Loading 加载飞机模型
self.fdm.load_model(fdm_aircraft)
# FlightGear Visualization 可视化
if fdm_fgfs is True:
self.fdm.set_output_directive('./data_output/flightgear{}.xml'.format(fdm_id))
# Velocity Initialization 速度初始化
self.fdm['ic/vc-kts'] = fdm_ic_v
# Position Initialization 位置初始化
self.fdm["ic/lat-gc-deg"] = fdm_ic_lat
self.fdm["ic/long-gc-deg"] = fdm_ic_long
self.fdm["ic/h-sl-ft"] = fdm_ic_h
# Attitude Initialization 姿态初始化
self.fdm["ic/psi-true-deg"] = fdm_ic_psi
self.fdm["ic/theta-deg"] = fdm_ic_theta
self.fdm["ic/phi-deg"] = fdm_ic_phi
##########################
## Model Initialization ##
## 模型初始化 ##
self.fdm.run_ic() ##
##########################
# Turning on the Engine 启动引擎
self.fdm["propulsion/starter_cmd"] = 1
# First but not Initial 第一帧设置(初始状态)
self.fdm.run()
self.fdm["propulsion/active_engine"] = True
self.fdm["propulsion/set-running"] = -1
# Number of Frames 帧数
self.nof = 1
2 获取状态空间(状态空间)
-
位置 : 横轴,纵轴,竖轴 坐标 \(x,y,z\)
fdm["position/lat-gc-deg"] # Latitude 纬度 fdm["position/long-gc-deg"] # Longitude fdm["position/h-sl-ft"] # altitude # Earth-centered inertial(feet) 地心惯性坐标系(英尺),与Ecef相比相对静止 "position/eci-x-ft", # 指向春分点 "position/eci-y-ft", # 左手系决定 "position/eci-z-ft", # 指向北极点 # Earth-centered, Earth-fixed coordinate system(feet) 地心地固坐标系(英尺) "position/ecef-x-ft", # 指向经纬度为0的点(本初子午线与赤道的交点) "position/ecef-y-ft", # 左手系决定 "position/ecef-z-ft", # 指向北极点
-
姿态 : 俯仰角\(\theta\)、滚转角\(\phi\)、偏航角\(\psi\)
# 弧度 fdm["attitude/theta-deg"] # pitch Yaw 偏航角 fdm["attitude/phi-deg"] # rollPitch 俯仰角 fdm["attitude/psi-deg"] # yawRoll 翻滚角 #角度 "attitude/psi-deg" # Yaw 偏航角 "attitude/theta-deg" # Pitch 俯仰角 "attitude/phi-deg" # Roll 翻滚角
-
速度 :速度\((u,v,w)\) ,
载体坐标系(Body Frame,符号b) fdm["velocities/p-rad_sec"] # The roll rotation rates fdm["velocities/q-rad_sec"] # The pitch rotation rates fdm["velocities/r-rad_sec"] # The yaw rotation rates #速度 "velocities/u-fps" #b 载体坐标系 "velocities/v-fps" "velocities/w-fps" #局部导航坐标系,东北天ENU坐标系 "velocities/v-north-fps" "velocities/v-east-fps" "velocities/v-down-fps" "velocities/h-dot-fps"#高度变化
-
角速度\((p,q,r)\)
#角速度 'velocities/p-rad_sec' 'velocities/q-rad_sec' 'velocities/r-rad_sec'
-
翼弦 迎角、侧滑角\(AOA,AOS\)
fdm["aero/alpha-deg"] # The angle of Attack 迎角 fdm["aero/beta-deg"] # The angle of Slip 侧滑角
-
当前指令
# controls state 控制指令状态 fcs/left-aileron-pos-norm' #左副翼 fcs/right-aileron-pos-norm'#右副翼 'fcs/elevator-pos-norm'#升降副翼 'fcs/rudder-pos-norm'#尾舵 'fcs/throttle-pos-norm'#油门
3 直接设置初始状态
-
位置 横轴,纵轴,竖轴 坐标
fdm["ic/lat-gc-deg"] = # Latitude initial condition in degrees fdm["ic/long-gc-deg"] = # Longitude initial condition in degrees fdm["ic/h-sl-ft"] = # Height above sea level initial condition in feet
-
姿态 : 俯仰角、偏转角、翻滚角
fdm["ic/theta-deg"] = # Pitch angle initial condition in degrees fdm["ic/phi-deg"] = # Roll angle initial condition in degrees fdm["ic/psi-true-deg"] = # Heading angle initial condition in degrees
-
速度
fdm["ic/ve-fps"] = # Local frame y-axis (east) velocity initial condition in feet/second fdm["ic/vd-fps"] = # Local frame z-axis (down) velocity initial condition in feet/second fdm["ic/vn-fps"] = # Local frame x-axis (north) velocity initial condition in feet/second
-
角速度设置
fdm["ic/q-rad_sec"] = 0 # Pitch rate initial condition in radians/second
fdm["ic/p-rad_sec"] = 0 # Roll rate initial condition in radians/second
fdm["ic/r-rad_sec"] = 0 # Yaw rate initial condition in radians/second
4 控制指令(动作空间)
"fcs/aileron-cmd-norm" # 副翼
"fcs/elevator-cmd-norm" # 升降舵
"fcs/rudder-cmd-norm" # 方向舵
"fcs/throttle-cmd-norm" # 油门
"fcs/flap-cmd-norm" # 襟翼
"fcs/speedbrake-cmd-norm" # 减速板
"fcs/spoiler-cmd-norm" # 扰流片
标签:飞机,游戏,self,velocities,fdm,ic,JSBSim,condition,deg
From: https://www.cnblogs.com/zuti666/p/16966391.html