此示例的飞行轨迹数据存储在逗号分离的值格式的文件中。要读取此数据,请使用readmatrix
。
tdata = readmatrix('asthl20log.csv');
时间序列对象,TS
,由纬度,经度,高度,欧拉角数据和时间阵列创建tdata
使用MATLAB®时间序列
命令。纬度、经度和欧拉角also converted from degrees to radians using the交流
功能。
ts = limeseries([condang(tdata(:,[3 2]),'deg','rad')... tdata(:,4)condang(tdata(:,5:7),'deg',',''rad')],tdata(:,1));
This series of commands creates a FlightGearAnimation object:
Open a FlightGearAnimation object.
h = fganimation;
Set FlightGearAnimation object properties for the time series.
h.timeseriessourcetype ='limeseries';h.timeseriessource = ts;
设置与Flightgear有关的flightgearanimation对象属性。这些属性包括通往安装文件夹的路径,版本号,飞机几何模型以及FlightGear Flight Simulator的网络信息。
H。FlightGearBasedirectory= 'C:\Program Files\FlightGear'; h.GeometryModelName = 'HL20'; h.DestinationIpAddress = '127.0.0.1'; h.DestinationPort = '5502';
为Flightgear Flight Simulator设置初始条件(位置和方向)。
h.AirportID ='ksfo';h.runwayid ='10l';H.Initialaltitude = 7224;H.Initialheading = 113;H.OffsetDistance = 4.72;h.offsetazimuth = 0;
设置壁式锁定时间每秒的动画数据的秒。
H。TimeScaling = 5;
检查FlightGearanimation对象属性及其值。
获取(h)
该示例停止运行并返回flightgearanimation对象,H
:
TimeseriesSource: [1x1 timeseries] TimeseriesSourceType: 'Timeseries' TimeseriesReadFcn: @TimeseriesRead TimeScaling: 5 FramesPerSecond: 12 FlightGearVersion: '2018.1' OutputFileName: 'runfg.bat' FlightGearBaseDirectory: 'C:\Program Files\FlightGear' GeometryModelName: 'HL20' DestinationIpAddress: '127.0.0.1' DestinationPort: '5502' AirportId: 'KSFO' RunwayId: '10L' InitialAltitude: 7224 InitialHeading: 113 OffsetDistance: 4.7200 OffsetAzimuth: 0 TStart: NaN TFinal: NaN Architecture: 'Default'
您现在可以为数据播放设置对象属性(请参阅Modifying the FlightGearAnimation Object Properties)。
根据需要修改FlightGearanimation对象属性。如果您的FlightGear安装文件夹除了示例中的文件夹之外(例如,Flightgear
),修改FlightGearBasedirectory
通过发出以下命令的属性:
H。FlightGearBasedirectory= 'C:\Program Files\FlightGear';
同样,如果要使用运行脚本的特定文件名,请修改OutputFileName
财产。
验证FlightGearanimation对象属性:
获取(h)
您现在可以生成运行脚本(请参阅生成运行脚本)。
要以最初条件(位置,日期,时间,天气,操作模式)开始FlightGear,请使用Generatarunscript
命令:
Generatarunscript(H)
默认,Generatarunscript
将运行脚本保存为名为的文本文件runfg.bat
。您可以通过修改OutputFileName
property of the FlightGearAnimation object, as described in the previous step.
只有在初始条件或Flightgear信息更改时,您就无需每次查看数据时生成文件。
You are now ready to start FlightGear (see启动FlightGear飞行模拟器)。
笔记
这FlightGearBasedirectory
andOutputFileName
属性必须由ASCII字符组成。
要从MATLAB命令提示开始FlightGear,请使用系统
命令执行运行脚本。提供由GenerataruNscript创建的输出文件的名称作为参数:
系统('runfg.bat&');
Flightgear从单独的窗口开始。
小费
随着Flightgear窗口的焦点,按vkey to alternate between the different aircraft views: cockpit, helicopter, chase, and so on.
您现在准备好播放数据(请参阅弹回飞行轨迹)。如果您无法查看场景,请参阅安装其他飞行风景。
小费
If FlightGear uses more computer resources than you want, you can change its scheduling priority to a lesser one. For example, see commands like Windows®开始
和Linux®好的
或他们的等效物。
一旦Flightgear运行,FlightGearanimation对象就可以开始与Flightgear通信。要动画飞行轨迹数据,请使用play命令:
play(h)
下图显示了无偏航的塔视图中飞行数据播放的快照。