Main Content

play (Aero.FlightGearAnimation)

Animate FlightGear flight simulator using given position/angle time series

Syntax

play(h)
h.play

Description

play(h) and h.play animate FlightGear flight simulator using specified time series data in h. The time series data can be set in h by using the property 'TimeseriesSource'.

The time series data, stored in the property 'TimeseriesSource', is interpreted according to the 'TimeseriesSourceType' property, which can be one of:

'Timeseries'

MATLAB® time series data with six values per time:

latitude longitude altitude phi theta psi

The values are resampled.

'StructureWithTime'

Simulink® struct with time (for example, Simulink root outport logging 'Structure with time'):

  • signals(1).values: latitude longitude altitude

  • signals(2).values: phi theta psi

Signals are linearly interpolated vs. time using interp1.

'Array6DoF'A double-precision array in n rows and 7 columns for 6-DoF data: time latitude longitude altitude phi theta psi. If a double-precision array of 8 or more columns is in 'TimeseriesSource', the first 7 columns are used as 6-DoF data.
'Array3DoF'A double-precision array in n rows and 4 columns for 3-DoF data: time latitude altitude theta. If a double-precision array of 5 or more columns is in 'TimeseriesSource', the first 4 columns are used as 3-DoF data.
'Custom'Position and angle data is retrieved from 'TimeseriesSource' by the currently registered 'TimeseriesReadFcn'.

The time advancement algorithm used by play is based on animation frames counted by ticks:

ticks = ticks + 1;
time  = tstart + ticks*FramesPerSecond*TimeScaling;

where

TimeScalingSpecify the seconds of animation data per second of wall-clock time.
FramesPerSecondSpecify the number of frames per second used to animate the 'TimeseriesSource'.

For default 'TimeseriesReadFcn' methods, the last frame played is the last time value.

Time is in seconds, position values are in the same units as the geometry model to be used by FlightGear (see the property 'GeometryModelName'), and all angles are in radians. A possible result of using incorrect units is the early termination of the FlightGear flight simulator.

Note

If there is a 15% difference between the expected time advance and the actual time advance, this method will generate the following warning:

TimerPeriod has been set to <value>. You may wish to modify the animation
TimeScaling and FramesPerSecond properties to compensate for the 
millisecond limit of the TimerPeriod.  See documentation for details.

The play method supports FlightGear animation objects with custom timers.

Limitations

The following are limitations for the TStart and TFinal values:

  • TStart and TFinal must be numeric.

  • TStart and TFinal cannot be Inf or NaN.

  • TFinal must be greater than or equal to TStart.

  • TFinal cannot be greater than the maximum Timeseries time.

  • TStart cannot be less than the minimum Timeseries time.

Examples

Animate FlightGear flight simulator using the given 'Array3DoF' position/angle time series data:

data = [86.2667 -2.13757034184404 7050.896596 -0.135186746141248;...
        87.2833 -2.13753906554384 6872.545051 -0.117321084678936;...
        88.2583 -2.13751089592972 6719.405713 -0.145815609299676;...
        89.275  -2.13747984652232 6550.117118 -0.150635248762596;...
        90.2667 -2.13744993157894 6385.05883  -0.143124782831999;...
        91.275  -2.13742019116849 6220.358163 -0.147946202530756;...
        92.275  -2.13739055547779 6056.906647 -0.167529704309343;...
        93.2667 -2.13736104196014 5892.356118 -0.152547361677911;...
        94.2583 -2.13733161570895 5728.201718 -0.161979312941906;...
        95.2583 -2.13730231163081 5562.923808 -0.122276929636682;...
        96.2583 -2.13727405475022 5406.736322 -0.160421658944379;...
        97.2667 -2.1372440001805  5239.138477 -0.150591353731908;...
        98.2583 -2.13721598764601 5082.78798  -0.147737722951605];
h = fganimation
h.TimeseriesSource = data
h.TimeseriesSourceType = 'Array3DoF'
play(h)

Animate FlightGear flight simulator using the custom timer, MyFGTimer.

h.play('MyFGTimer')
Introduced in R2007a