3-D Flight Data Playback

Aerospace Toolbox Animation Objects

To visualize flight data in the Aerospace Toolbox environment, you can use the following animation objects and their associated methods. These animation objects use the MATLAB® time series object, timeseries to visualize flight data.

Using Aero.Animation Objects

The toolbox interface to animation objects uses the Handle Graphics® product. The demo, Overlaying Simulated and Actual Flight Data (astmlanim), visually compares simulated and actual flight trajectory data. It does this by creating animation objects, creating bodies for those objects, and loading the flight trajectory data. This section describes what happens when the demo runs.

  1. Create and configure an animation object.

    1. Configure the animation object.

    2. Create and load bodies for that object.

  2. Load recorded data for flight trajectories.

  3. Display body geometries in a figure window.

  4. Play back flight trajectories using the animation object.

  5. Manipulate the camera.

  6. Manipulate bodies, as follows:

    1. Move and reposition bodies.

    2. Create a transparency in the first body.

    3. Change the color of the second body.

    4. Turn off the landing gear of the second body.

Running the Demo

  1. Start the MATLAB software.

  2. Run the demo either by entering astmlanim in the MATLAB Command Window or by finding the demo entry (Overlaying Simulated and Actual Flight Data) in the Demos browser and clicking Run in the Command Window on its demo page.

    While running, the demo performs several steps by issuing a series of commands, as explained below.

Creating and Configuring an Animation Object

This series of commands creates an animation object and configures the object.

  1. Create an animation object.

    h = Aero.Animation;
  2. Configure the animation object to set the number of frames per second (FramesPerSecond) property. This controls the rate at which frames are displayed in the figure window.

    h.FramesPerSecond = 10;
  3. Configure the animation object to set the seconds of animation data per second time scaling (TimeScaling) property.

    h.TimeScaling = 5;

    The combination of FramesPerSecond and TimeScaling property determine the time step of the simulation. The settings in this demo result in a time step of approximately 0.5 s.

  4. Create and load bodies for the animation object. The demo will use these bodies to work with and display the simulated and actual flight trajectories. The first body is orange; it represents simulated data. The second body is blue; it represents the actual flight data.

    idx1 = h.createBody('pa24-250_orange.ac','Ac3d');
    idx2 = h.createBody('pa24-250_blue.ac','Ac3d');

    Both bodies are AC3D format files. AC3D is one of several file formats that the animation objects support. FlightGear uses the same file format. The animation object reads in the bodies in the AC3D format and stores them as patches in the geometry object within the animation object.

Loading Recorded Data for Flight Trajectories

This series of commands loads the recorded flight trajectory data, which is contained in files in the matlabroot\toolbox\aero\astdemos directory.

  1. Load the flight trajectory data.

    load simdata
    load fltdata
  2. Set the time series data for the two bodies.

    h.Bodies{1}.TimeSeriesSource = simdata;
    h.Bodies{2}.TimeSeriesSource = fltdata;
  3. Identify the time series for the second body as custom.

    h.Bodies{2}.TimeSeriesSourceType = 'Custom';
  4. Specify the custom read function to access the data in fltdata for the second body. The demo provides the custom read function in matlabroot\toolbox\aero\astdemos\CustomReadBodyTSData.m.

    h.Bodies{2}.TimeseriesReadFcn = @CustomReadBodyTSData;

Displaying Body Geometries in a Figure Window

This command creates a figure object for the animation object.

h.show();

Playing Back Flight Trajectories Using the Animation Object

This command plays the animation bodies for the duration of the time series data. This illustrates the differences between the simulated and actual flight data.

h.play();

Manipulating the Camera

This command series describes how you can manipulate the camera on the two bodies, and redisplay the animation. The PositionFcn property of a camera object controls the camera position relative to the bodies in the animation. In the section Playing Back Flight Trajectories Using the Animation Object, the camera object uses a default value for the PositionFcn property. In this command series, the demo references a custom PositionFcn function, which uses a static position based on the position of the bodies; no dynamics are involved. The custom PositionFcn function is located in the matlabroot\toolbox\aero\astdemos directory.

  1. Set the camera PositionFcn to the custom function staticCameraPosition.

    h.Camera.PositionFcn = @staticCameraPosition;
  2. Run the animation again.

    h.play();

Manipulating Bodies

This section illustrates some of the actions you can perform on bodies.

Moving and Repositioning Bodies.   This series of commands illustrates how to move and reposition bodies.

  1. Set the starting time to 0.

    t = 0;
  2. Move the body to the starting position that is based on the time series data. Use the Aero.Animation object updateBodies method.

    h.updateBodies(t);
  3. Update the camera position using the custom PositionFcn function set in the previous section. Use the Aero.Animation object updateCamera method.

    h.updateCamera(t);
  4. Reposition the bodies by first getting the current body position, then separating the bodies.

    1. Get the current body positions and rotations from the objects of both bodies.

      pos1 = h.Bodies{1}.Position;
      rot1 = h.Bodies{1}.Rotation;
      pos2 = h.Bodies{2}.Position;
      rot2 = h.Bodies{2}.Rotation;
      
    2. Separate and reposition the bodies by moving them to new positions.

      h.moveBody(1,pos1 + [0 0 -3],rot1);
      h.moveBody(2,pos1 + [0 0  0],rot2);
      

Creating a Transparency in the First Body.   This series of commands illustrates how to create and attach a transparency to a body. The animation object stores the body geometry as patches. This example manipulates the transparency properties of these patches (see Creating 3-D Models with Patches in the MATLAB documentation).

  1. Change the body patch properties. Use the Aero.Body PatchHandles property to get the patch handles for the first body.

    patchHandles2 = h.Bodies{1}.PatchHandles;
  2. Set the desired face and edge alpha values for the transparency.

    desiredFaceTransparency = .3;
    desiredEdgeTransparency = 1;
  3. Get the current face and edge alpha data and change all values to the desired alpha values. In the figure, note the first body now has a transparency.

    for k = 1:size(patchHandles2,1)
        tempFaceAlpha = get(patchHandles2(k),'FaceVertexAlphaData');
        tempEdgeAlpha = get(patchHandles2(k),'EdgeAlpha');
    	   set(patchHandles2(k),...
            'FaceVertexAlphaData',repmat(desiredFaceTransparency,size(tempFaceAlpha)));
        set(patchHandles2(k),...
            'EdgeAlpha',repmat(desiredEdgeTransparency,size(tempEdgeAlpha)));
    end

Changing the Color of the Second Body.   This series of commands illustrates how to change the color of a body. The animation object stores the body geometry as patches. This example will manipulate the FaceVertexColorData property of these patches.

  1. Change the body patch properties. Use the Aero.Body PatchHandles property to get the patch handles for the first body.

    patchHandles3 = h.Bodies{2}.PatchHandles;
  2. Set the patch color to red.

    desiredColor = [1 0 0];
  3. Get the current face color and data and propagate the new patch color, red, to the face. Note the following:

    for k = 1:size(patchHandles3,1)
        tempFaceColor = get(patchHandles3(k),'FaceVertexCData');
        tempName = h.Bodies{2}.Geometry.FaceVertexColorData(k).name;
        if isempty(strfind(tempName,'Windshield')) &&...
           isempty(strfind(tempName,'front-windows')) &&...
           isempty(strfind(tempName,'rear-windows'))
        set(patchHandles3(k),...
            'FaceVertexCData',repmat(desiredColor,[size(tempFaceColor,1),1]));
        end
    end

Turning Off the Landing Gear of the Second Body.   This command series illustrates how to turn off the landing gear on the second body by turning off the visibility of all the vehicle parts associated with the landing gear.

for k = [1:8,11:14,52:57]
    set(patchHandles3(k),'Visible','off')
end

Using Aero.VirtualRealityAnimation Objects

The Aerospace Toolbox interface to virtual reality animation objects uses the Virtual Reality Toolbox software. See Aero.VirtualRealityAnimation, Aero.Node, and Aero.Viewpoint for details.

  1. Create and configure an animation object.

    1. Configure the animation object.

    2. Initialize that object.

  2. Enable the tracking of changes to virtual worlds.

  3. Load the animation world.

  4. Load time series data for simulation.

  5. Set coordination information for the object.

  6. Add a chase helicopter to the object.

  7. Load time series data for chase helicopter simulation.

  8. Set coordination information for the new object.

  9. Add a new viewpoint for the helicopter.

  10. Play the animation.

  11. Create a new viewpoint.

  12. Add a route.

  13. Add another helicopter.

  14. Remove bodies.

  15. Revert to the original world.

Running the Demo

  1. Start the MATLAB software.

  2. Run the demo either by entering astvranim in the MATLAB Command Window or by finding the demo entry (Visualize Aircraft Takeoff via the Virtual Reality Toolbox product) in the Demos browser and clicking Run in the Command Window on its demo page.

    While running, the demo performs several steps by issuing a series of commands, as explained below.

Creating and Configuring a Virtual Reality Animation Object

This series of commands creates an animation object and configures the object.

  1. Create an animation object.

    h = Aero.VirtualRealityAnimation;
  2. Configure the animation object to set the number of frames per second (FramesPerSecond) property. This controls the rate at which frames are displayed in the figure window.

    h.FramesPerSecond = 10;
  3. Configure the animation object to set the seconds of animation data per second time scaling (TimeScaling) property.

    h.TimeScaling = 5;

    The combination of FramesPerSecond and TimeScaling property determine the time step of the simulation. The settings in this demo result in a time step of approximately 0.5 s.

  4. Specify the .wrl file for the vrworld object.

    h.VRWorldFilename = [matlabroot,'/toolbox/aero/astdemos/vrtkoff.wrl'];

    The virtual reality animation object reads in the .wrl file.

Enabling Aero.VirtualRealityAnimation Methods to Track Changes to Virtual Worlds

Aero.VirtualRealityAnimation methods that change the current virtual reality world use a temporary .wrl file to manage those changes. To enable these methods to work in a write-protected directory such as astdemos, type the following.

  1. Copy the virtual world file, vrtkoff.wrl, to a temporary directory.

    copyfile(h.VRWorldFilename,[tempdir,'vrtkoff.wrl'],'f');
  2. Set the vrtkoff.wrl world filename to the copied .wrl file.

    h.VRWorldFilename = [tempdir,'vrtkoff.wrl'];

Loading the Animation World

Load the animation world described in the VRWorldFilename field of the animation object. When parsing the world, this method creates node objects for existing nodes with DEF names. The initialize method also opens the Virtual Reality Toolbox Viewer.

h.initialize();

Displaying Figures

While working with this demo, you can capture a view of a scene with the takeVRCapture tool. This tool is specific to the astvranim demo. To display the initial scene, type

takeVRCapture(h.VRFigure);

A MATLAB figure window displays with the initial scene.

Loading Time Series Data for Simulation

To prepare for simulation, set the simulation time series data. takeoffData.mat contains logged simulated data that you can use to set the time series data. takeoffData is set up as the Simulink® structure'StructureWithTime', which is a default data format.

  1. Load the takeoffData.

    load takeoffData
  2. Set the time series data for the node.

    h.Nodes{7}.TimeseriesSource = takeoffData;
    h.Nodes{7}.TimeseriesSourceType = 'StructureWithTime';

Aligning the Position and Rotation Data with Surrounding Virtual World Objects

The virtual reality animation object expects positions and rotations in aerospace body coordinates. If the input data coordinate system is different, as is the case in this demo, you must create a coordinate transformation function to correctly line up the position and rotation data with the surrounding objects in the virtual world. This code should set the coordinate transformation function for the virtual reality animation. The custom transfer function for this demo is matlabroot/toolbox/aero/astdemos/vranimCustomTransform.m. In this demo, if the input translation coordinates are [x1,y1,z1], the custom transform function must adjust them as:

 [X,Y,Z] = -[y1,x1,z1]

To run this custom transformation function, type:

h.Nodes{7}.CoordTransformFcn = @vranimCustomTransform;

Viewing the Nodes in a Virtual Reality Animation Object

While working with this demo, you can view all the nodes currently in the virtual reality animation object with the nodeInfo method.

h.nodeInfo;

This method displays the nodes currently in your demo:

Node Information
1	_v1
2	Lighthouse
3	_v3
4	Terminal
5	Block
6	_V2
7	Plane
8	Camera1

Adding a Chase Helicopter

As part of the demo, add a chase helicopter node to your demo. Use the addNode method to add another node to the virtual reality animation object.

  1. Disable the message.

    h.ShowSaveWarning = false;
  2. Add the chase helicopter node.

    h.addNode('Lynx',[matlabroot,'/toolbox/aero/astdemos/chaseHelicopter.wrl']);

    The helicopter appears in the Virtual Reality Toolbox Viewer.

  3. Move the camera angle of the virtual reality figure to view the aircraft and newly added helicopter.

    set(h.VRFigure,'CameraDirection',[0.45 0 -1]);
  4. View the scene with the chase helicopter.

    takeVRCapture(h.VRFigure);

Loading Time Series Data for Simulation

To prepare to simulate the chase helicopter, set the simulation time series data. chaseData.mat contains logged simulated data that you can use to set the time series data. chaseData is set up as the Simulink structure'StructureWithTime', which is a default data format.

  1. Load the chaseData.

    load chaseData
  2. Set the time series data for the node.

    h.Nodes{2}.TimeseriesSource = chaseData;
    

Aligning the Chase Helicopter Position and Rotation Data with Surrounding Virtual World Objects

Use the custom transfer function to align the chase helicopter.

h.Nodes{2}.CoordTransformFcn = @vranimCustomTransform;

Adding a New Viewpoint

To add a viewpoint for the chase helicopter, use the addViewpoint method. New viewpoints appear in the Viewpoints menu of the Virtual Reality Toolbox Viewer. Type the following to add the viewpoint View From Helicopter to the Viewpoints menu.

h.addViewpoint(h.Nodes{2}.VRNode,'children','chaseView','View From Helicopter');

Playing Back the Simulation

The play command animates the virtual reality world for the given position and angle for the duration of the time series data. Set the orientation of the viewpoint first.

  1. Set the orientation of the viewpoint via the vrnode object associated with the node object for the viewpoint.

    setfield(h.Nodes{1}.VRNode,'orientation',[0 1 0 convang(160,'deg','rad')]);
    set(h.VRFigure,'Viewpoint','View From Helicopter');
  2. Play the animation.

    h.play();

Adding a Route to the Camera1 Node

The vrworld has a Ride on the Plane viewpoint. To enable this viewpoint to function as intended, connect the plane position to the Camera1 node with the addRoute method. This method adds a VRML ROUTE statement.

h.addRoute('Plane','translation','Camera1','translation');

Adding Another Helicopter and Viewing All Bodies Simultaneously

You can add another helicopter to the scene and also change the viewpoint to one that views all three bodies in the scene at once.

  1. Add a new node, Lynx1.

    h.addNode('Lynx1',[matlabroot,'/toolbox/aero/astdemos/chaseHelicopter.wrl']);
  2. Change the viewpoint to one that views all three bodies.

    set(h.VRFigure,'Viewpoint','See Whole Trajectory');

Removing Bodies

Use the removeNode method to remove the second helicopter. To obtain the name of the node to remove, use the nodeInfo method.

  1. View all the nodes.

    h.nodeInfo
    
    Node Information
    1 Lynx1_Inline
    2 Lynx1
    3 chaseView
    4 Lynx_Inline
    5 Lynx
    6 _v1
    7 Lighthouse
    8 _v3
    9 Terminal
    10 Block
    11 _V2
    12 Plane
    13 Camera1
  2. Remove the Lynx1 node.

    h.removeNode('Lynx1');
  3. Change the viewpoint to one that views the whole trajectory.

    set(h.VRFigure,'Viewpoint','See Whole Trajectory');
  4. Check that you have removed the node.

    h.nodeInfo
    
    Node Information
    1 chaseView
    2 Lynx_Inline
    3 Lynx
    4 _v1
    5 Lighthouse
    6 _v3
    7 Terminal
    8 Block
    9 _V2
    10 Plane
    11 Camera1

The following figure is a view of the entire trajectory with the third body removed.

Reverting to the Original World

The original file name is stored in the 'VRWorldOldFilename' property of the virtual reality animation object. To display the original world, set 'VRWorldFilename' to the original name and reinitialize it.

  1. Revert to the original world, 'VRWorldFilename'.

    h.VRWorldFilename = h.VRWorldOldFilename{1};
  2. Reinitialize the restored world.

    h.initialize();

Closing and Deleting Worlds

To close and delete a world, use the delete method.

h.delete();

Using Aero.FlightGearAnimation Object

The Aerospace Toolbox interface to the FlightGear flight simulator enables you to visualize flight data in a three-dimensional environment. The third-party FlightGear simulator is an open source software package available through a GNU® General Public License (GPL). This section explains how to obtain and install the third-party FlightGear flight simulator. It then explains how to play back 3-D flight data by using a FlightGear demo, provided with your Aerospace Toolbox software, as an example.

About the FlightGear Interface

The FlightGear flight simulator interface included with the Aerospace Toolbox product is a unidirectional transmission link from the MATLAB software to FlightGear using FlightGear's published net_fdm binary data exchange protocol. Data is transmitted via UDP network packets to a running instance of FlightGear. The toolbox supports multiple standard binary distributions of FlightGear. See Working with the Flight Simulator Interface following for interface details.

FlightGear is a separate software entity neither created, owned, nor maintained by The MathWorks.

Obtaining FlightGear.   You can obtain FlightGear from www.flightgear.org in the download area or by ordering CDs from FlightGear. The download area contains extensive documentation for installation and configuration. Because FlightGear is an open source project, source downloads are also available for customization and porting to custom environments.

Configuring Your Computer for FlightGear

You must have a high performance graphics card with stable drivers to use FlightGear. For more information, see the FlightGear CD distribution or the hardware requirements and documentation areas of the FlightGear Web site, www.flightgear.org.

The MathWorks tests of FlightGear's performance and stability indicate significant sensitivity to computer video cards, driver versions, and driver settings. You need OpenGL support with hardware acceleration activated. The OpenGL settings are particularly important. Without proper setup, performance can drop from about a 30 frames-per-second (fps) update rate to less than 1 fps.

Graphics Recommendations for Microsoft Windows.   The MathWorks recommends the following for Windows® users:

Setting Up OpenGL® Graphics on Windows®.   For complete information on Silicon Graphics OpenGL settings, refer to the documentation at the OpenGL Web site, www.opengl.org.

Follow these steps to optimize your video card settings. Your driver's panes might look different.

  1. Ensure that you have activated the OpenGL hardware acceleration on your video card. On Windows, access this configuration through Start > Settings > Control Panel > Display, which opens the following dialog box. Select the Settings tab.

  2. Click the Advanced button in the lower right of the dialog box, which opens the graphics card's custom configuration dialog box, and go to the OpenGL tab. For an ATI Mobility Radeon 9000 video card, the OpenGL pane looks like this:

  3. For best performance, move the Main Settings slider near the top of the dialog box to the Performance end of the slider.

  4. If stability is a problem, try other screen resolutions, other color depths in the Displays pane, and other OpenGL acceleration modes.

Many cards perform much better at 16 bits-per-pixel color depth (also known as 65536 color mode, 16-bit color). For example, on an ATI Mobility Radeon 9000 running a given model, 30 fps are achieved in 16-bit color mode, while 2 fps are achieved in 32-bit color mode.

Setup on Linux®, Mac OS® X, and Other Platforms.   FlightGear distributions are available for Linux®, Mac OS® X, and other UNIX® platforms from the FlightGear Web site, www.flightgear.org. Installation on these platforms, like Windows, requires careful configuration of graphics cards and drivers. Consult the documentation and hardware requirements sections at the FlightGear Web site.

Using MATLAB® Graphics Controls to Configure Your OpenGL® Settings.   You can also control your OpenGL rendering from the MATLAB command line with the MATLAB Graphics opengl command. Consult the opengl command reference for more information.

Installing and Starting FlightGear

The extensive FlightGear documentation guides you through the installation in detail. Consult the documentation section of the FlightGear Web site for complete installation instructions: www.flightgear.org.

Keep the following points in mind:

The Aerospace Toolbox product supports FlightGear on a number of platforms (http://www.mathworks.com/products/aerotb/requirements.html). The following table lists the properties you should be aware of before you start to use FlightGear.

FlightGear PropertyDirectory DescriptionPlatformsTypical Location
FlightGearBaseDirectoryFlightGear installation directory. WindowsC:\Program Files\FlightGear
(default)
Sun™Solaris™ or LinuxDirectory into which you installed FlightGear
Mac®/Applications
(directory to which you dragged the FlightGear icon)
GeometryModelNameModel geometry directoryWindowsC:\Program Files\FlightGear\data\Aircraft\HL20
(default)
Solaris or Linux$FlightGearBaseDirectory/data/Aircraft/HL20
Mac$FlightGearBaseDirectory/FlightGear.app/Contents/Resources/data/Aircraft/HL20

Working with the Flight Simulator Interface

The Aerospace Toolbox product provides a demo named Displaying Flight Trajectory Data, which shows you how you can visualize flight trajectories with FlightGear Animation object. The demo is intended to be modified depending on the particulars of your FlightGear installation. This section explains how to run this demo. Use this demo as an example to play back your own 3-D flight data with FlightGear.

You need to have FlightGear installed and configured before attempting to simulate this model. See About the FlightGear Interface.

To run the demo:

  1. Import the aircraft geometry into FlightGear.

  2. Run the demo. The demo performs the following steps:

    1. Loads recorded trajectory data

    2. Creates a time series object from trajectory data

    3. Creates a FlightGearAnimation object

  3. Modify the animation object properties, if needed.

  4. Create a run script for launching FlightGear flight simulator.

  5. Start FlightGear flight simulator.

  6. Play back the flight trajectory.

The following sections describe how to perform these steps in detail.

Importing the Aircraft Geometry into FlightGear.   Before running the demo, copy the aircraft geometry model into FlightGear. From the following procedures, choose the one appropriate for your platform. This section assumes that you have read Installing and Starting FlightGear.

If your platform is Windows:

  1. Go to your installed FlightGear directory. Open the data directory, then the Aircraft directory: FlightGear\data\Aircraft\.

  2. You may already have an HL20 subdirectory there, if you have previously run the Aerospace Blockset™ NASA HL-20 with FlightGear Interface demo. In this case, you don't have to do anything, because the geometry model is the same.

    Otherwise, copy the HL20 folder from the matlabroot\toolbox\aero\aerodemos\ directory to the FlightGear\data\Aircraft\ directory. This folder contains the preconfigured geometries for the HL-20 simulation and HL20-set.xml. The file matlabroot\toolbox\aero\aerodemos\HL20\models\HL20.xml defines the geometry.

If your platform is Solaris or Linux:

  1. Go to your installed FlightGear directory. Open the data directory, then the Aircraft directory: $FlightGearBaseDirectory/data/Aircraft/.

  2. You may already have an HL20 subdirectory there, if you have previously run the Aerospace Blockset NASA HL-20 with FlightGear Interface demo. In this case, you do not have to do anything, because the geometry model is the same.

    Otherwise, copy the HL20 folder from the matlabroot/toolbox/aero/aerodemos/ directory to the $FlightGearBaseDirectory/data/Aircraft/ directory. This directory contains the preconfigured geometries for the HL-20 simulation and HL20-set.xml. The file matlabroot/toolbox/aero/aerodemos/HL20/models/HL20.xml defines the geometry.

If your platform is Mac:

  1. Open a terminal.

  2. List the contents of the Aircraft directory. For example, type

    ls $FlightGearBaseDirectory/data/Aircraft/
  3. You may already have an HL20 subdirectory there, if you have previously run the Aerospace Blockset NASA HL-20 with FlightGear Interface demo. In this case, you do not have to do anything, because the geometry model is the same. Continue to Running the Demo.

    Otherwise, copy the HL20 folder from the

    matlabroot/toolbox/aero/aerodemos/

    directory to the

    $FlightGearBaseDirectory/FlightGear.app/Contents/Resources/data/Aircraft/

    directory. This directory contains the preconfigured geometries for the HL-20 simulation and HL20-set.xml. The file matlabroot/toolbox/aero/aerodemos/HL20/models/HL20.xml defines the geometry.

Running the Demo

  1. Start the MATLAB software.

  2. Run the demo either by entering astfganim in the MATLAB Command Window or by finding the demo entry (Displaying Flight Trajectory Data) in the Demos browser and clicking Run in the Command Window on its demo page.

    While running, the demo performs several steps by issuing a series of commands, as explained below.

Loading Recorded Flight Trajectory Data.   The flight trajectory data for this example is stored in a comma separated value formatted file. Using csvread, the data is read from the file starting at row 1 and column 0, which skips the header information.

tdata = csvread('asthl20log.csv',1,0);

Creating a Time Series Object from Trajectory Data.   The time series object, ts, is created from the latitude, longitude, altitude, and Euler angle data along with the time array in tdata using the MATLAB timeseries command. Latitude, longitude, and Euler angles are also converted from degrees to radians using the convang function.

ts = timeseries([convang(tdata(:,[3 2]),'deg','rad') ...
        tdata(:,4) convang(tdata(:,5:7),'deg','rad')],tdata(:,1));

Creating a FlightGearAnimation Object.   This series of commands creates a FlightGearAnimation object:

  1. Opening a FlightGearAnimation object.

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

    h.TimeseriesSourceType = 'Timeseries';
    h.TimeseriesSource = ts;
  3. Setting FlightGearAnimation object properties relating to FlightGear. These properties include the path to the installation directory, the version number, the aircraft geometry model, and network information for the FlightGear flight simulator.

    h.FlightGearBaseDirectory = 'D:\Applications\FlightGear0910';
    h.FlightGearVersion = '0.9.10';
    h.GeometryModelName = 'HL20';
    h.DestinationIpAddress = '127.0.0.1';
    h.DestinationPort = '5502';
  4. Setting the initial conditions (location and orientation) for the FlightGear flight simulator.

    h.AirportId = 'KSFO';
    h.RunwayId = '10L';
    h.InitialAltitude = 7224;
    h.InitialHeading = 113;
    h.OffsetDistance = 4.72;
    h.OffsetAzimuth = 0;
  5. Setting the seconds of animation data per second of wall-clock time.

    h.TimeScaling = 5;
  6. Checking the FlightGearAnimation object properties and their values.

    get(h)

At this point, the demo stops running and returns the FlightGearAnimation object, h:

           TimeseriesSource: [196x1 timeseries]
       TimeseriesSourceType: 'Timeseries'
          TimeseriesReadFcn: @TimeseriesRead
                TimeScaling: 5
            FramesPerSecond: 12
          FlightGearVersion: '0.9.10'
             OutputFileName: 'runfg.bat'
    FlightGearBaseDirectory: 'D:\Applications\FlightGear0910'
          GeometryModelName: 'HL20'
       DestinationIpAddress: '127.0.0.1'
            DestinationPort: '5502'
                  AirportId: 'KSFO'
                   RunwayId: '10L'
            InitialAltitude: 7224
             InitialHeading: 113
             OffsetDistance: 4.7200
              OffsetAzimuth: 0

You can now set the object properties for data playback (see Modifying the FlightGearAnimation Object Properties).

Modifying the FlightGearAnimation Object Properties.   Modify the FlightGearAnimation object properties as needed. If your FlightGear installation directory is other than that in the demo (for example, FlightGear), modify the FlightGearBaseDirectory property by issuing the following command:

h.FlightGearBaseDirectory = 'D:\Applications\FlightGear';

Similarly, if you want to use a particular file name for the run script, modify the OutputFileName property.

Verify the FlightGearAnimation object properties:

get(h)

You can now generate the run script (see Generating the Run Script).

Generating the Run Script.   To start FlightGear with the desired initial conditions (location, date, time, weather, operating modes), it is best to create a run script by using the GenerateRunScript command:

GenerateRunScript(h)

By default, GenerateRunScript saves the run script as a text file named runfg.bat. You can specify a different name by modifying the OutputFileName property of the FlightGearAnimation object, as described in the previous step.

This file does not need to be generated each time the data is viewed, only when the desired initial conditions or FlightGear information changes.

You are now ready to start FlightGear (see Starting the FlightGear Flight Simulator).

Starting the FlightGear Flight Simulator.   To start FlightGear from the MATLAB command prompt, use the system command to execute the run script. Provide the name of the output file created by GenerateRunScript as the argument:

system('runfg.bat &');

FlightGear starts in a separate window.

You are now ready to play back data (see Playing Back the Flight Trajectory).

Playing Back the Flight Trajectory.   Once FlightGear is running, the FlightGearAnimation object can start to communicate with FlightGear. To animate the flight trajectory data, use the play command:

play(h)

The following illustration shows a snapshot of flight data playback in tower view without yaw.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS