Main Content

飞行轨迹数据

加载记录的飞行轨迹数据

此示例的飞行轨迹数据存储在逗号分离的值格式的文件中。要读取此数据,请使用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));

创建一个flightgearanimation对象

This series of commands creates a FlightGearAnimation object:

  1. Open a FlightGearAnimation object.

    h = fganimation;
  2. Set FlightGearAnimation object properties for the time series.

    h.timeseriessourcetype ='limeseries';h.timeseriessource = ts;
  3. 设置与Flightgear有关的flightgearanimation对象属性。这些属性包括通往安装文件夹的路径,版本号,飞机几何模型以及FlightGear Flight Simulator的网络信息。

    H。FlightGearBasedirectory= 'C:\Program Files\FlightGear'; h.GeometryModelName = 'HL20'; h.DestinationIpAddress = '127.0.0.1'; h.DestinationPort = '5502';
  4. 为Flightgear Flight Simulator设置初始条件(位置和方向)。

    h.AirportID ='ksfo';h.runwayid ='10l';H.Initialaltitude = 7224;H.Initialheading = 113;H.OffsetDistance = 4.72;h.offsetazimuth = 0;
  5. 设置壁式锁定时间每秒的动画数据的秒。

    H。TimeScaling = 5;
  6. 检查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)。

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。您可以通过修改OutputFileNameproperty of the FlightGearAnimation object, as described in the previous step.

只有在初始条件或Flightgear信息更改时,您就无需每次查看数据时生成文件。

You are now ready to start FlightGear (see启动FlightGear飞行模拟器)。

笔记

FlightGearBasedirectoryandOutputFileName属性必须由ASCII字符组成。

启动FlightGear飞行模拟器

要从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)

下图显示了无偏航的塔视图中飞行数据播放的快照。

也可以看看

Related Topics