Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
'''
|
|
|
|
Test script for record/replay. Only tested on Unix.
|
|
|
|
|
|
|
|
E.g.:
|
|
|
|
|
|
|
|
./flightgear/scripts/python/recordreplay.py -f run_fgfs.sh
|
|
|
|
|
|
|
|
Args:
|
|
|
|
--all
|
|
|
|
Run all tests (this is default).
|
|
|
|
--continuous BOOLS
|
|
|
|
--extra-properties BOOLS
|
|
|
|
--it-max <it>
|
|
|
|
Set min iteration (inclusive) to run; useful when fixing tests and
|
|
|
|
retrying.
|
|
|
|
--it-min <it>
|
|
|
|
Set max iteration (exclusive) to run; useful when fixing tests and
|
|
|
|
retrying.
|
|
|
|
--main-view BOOLS
|
|
|
|
--multiplayer
|
|
|
|
-f <fgfs>
|
|
|
|
The fgfs executable to use. Default assumes the Walk build system.
|
|
|
|
--f-old <fgfs-old>
|
|
|
|
A second fgfs executable. If specified we run all tests twice, first
|
|
|
|
using <fgfs-old> to create the recording and <fgfs> to replay it,
|
|
|
|
second the other way round.
|
2021-03-14 21:06:57 +00:00
|
|
|
--test-motion
|
|
|
|
Checks that speed of aircraft on replay is not affected by frame rate.
|
|
|
|
|
|
|
|
We deliberately change frame rate while recording UFO moving at
|
|
|
|
constant speed.
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
|
|
|
|
BOOLS is comma-sparated list of 0 or 1, with 1 activating the particular
|
|
|
|
feature. So for example '--continuous 0' tests normal recording/replay',
|
|
|
|
'--continuous 1' tests continuous recording/replay, and continuous 0,1'
|
|
|
|
tests both.
|
|
|
|
|
|
|
|
We test all combinations of continuous, extra-properties, main-view and
|
|
|
|
multiplayer recordings. For each test we check that we can create a
|
|
|
|
recording, and replay it in a new fgfs instance. When replaying we check
|
|
|
|
a small number of basic things such as the recording length, and whether
|
|
|
|
extra-properties are replayed.
|
|
|
|
'''
|
|
|
|
|
|
|
|
import os
|
|
|
|
import signal
|
2021-03-05 20:32:48 +00:00
|
|
|
import subprocess
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
|
|
|
|
import FlightGear
|
|
|
|
|
|
|
|
def log(text):
|
|
|
|
print(text, file=sys.stderr)
|
|
|
|
sys.stderr.flush()
|
|
|
|
|
|
|
|
g_cleanup = []
|
|
|
|
|
|
|
|
class Fg:
|
|
|
|
'''
|
|
|
|
Runs flightgear. self.fg is a FlightGear.FlightGear instance, which uses
|
|
|
|
telnet to communicate with Flightgear.
|
|
|
|
'''
|
|
|
|
def __init__(self, aircraft, args, env=None):
|
|
|
|
'''
|
|
|
|
aircraft:
|
|
|
|
Specified as: --aircraft={aircraft}. This is separate from <args>
|
|
|
|
because we need to know the name of recording files.
|
|
|
|
args:
|
|
|
|
Miscellenous args either space-separated name=value strings or a
|
|
|
|
dict.
|
|
|
|
env:
|
|
|
|
Environment to set. If DISPLAY is not in <env> we add 'DISPLAY=:0'.
|
|
|
|
'''
|
2021-03-05 20:32:48 +00:00
|
|
|
self.child = None
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
self.aircraft = aircraft
|
|
|
|
args += f' --aircraft={aircraft}'
|
|
|
|
|
|
|
|
port = 5500
|
|
|
|
args += f' --telnet={port}'
|
|
|
|
args2 = args.split()
|
|
|
|
|
2021-03-14 21:06:57 +00:00
|
|
|
environ = os.environ.copy()
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
if isinstance(env, str):
|
|
|
|
for nv in env.split():
|
|
|
|
n, v = nv.split('=', 1)
|
2021-03-14 21:06:57 +00:00
|
|
|
environ[n] = v
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
if 'DISPLAY' not in environ:
|
|
|
|
environ['DISPLAY'] = ':0'
|
|
|
|
|
|
|
|
# Run flightgear in new process, telling it to open telnet server.
|
2021-03-14 21:06:57 +00:00
|
|
|
#
|
|
|
|
# We run not in a shell, otherwise self.child.terminate() doesn't
|
|
|
|
# work - it would kill the shell but leave fgfs running (there are
|
|
|
|
# workarounds for this, such as prefixing the command with 'exec').
|
|
|
|
#
|
|
|
|
log(f'Command is: {args}')
|
|
|
|
log(f'Running: {args2}')
|
|
|
|
self.child = subprocess.Popen(args2, env=environ)
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
|
|
|
|
# Connect to flightgear's telnet server.
|
|
|
|
timeout = 15
|
|
|
|
t0 = time.time()
|
|
|
|
while 1:
|
|
|
|
time.sleep(1)
|
|
|
|
dt = time.time() - t0
|
|
|
|
if dt > timeout:
|
|
|
|
text = f'Timeout trying to connect. timeout={timeout}'
|
|
|
|
log(text)
|
|
|
|
raise Exception(text)
|
|
|
|
try:
|
|
|
|
log('Connecting... ')
|
|
|
|
self.fg = FlightGear.FlightGear('localhost', port)
|
|
|
|
log(f'Connected. timeout={timeout} dt={dt:.1f}')
|
|
|
|
return
|
|
|
|
except Exception as e:
|
|
|
|
log(f'Failed to connect timeout={timeout} dt={dt:.1f}: {e}')
|
|
|
|
|
|
|
|
def waitfor(self, name, value, timeout=30):
|
|
|
|
'''
|
|
|
|
Waits for specified property to be <value>. Returns time taken.
|
|
|
|
'''
|
|
|
|
t0 = time.time()
|
|
|
|
while 1:
|
|
|
|
time.sleep(1)
|
|
|
|
dt = time.time() - t0
|
|
|
|
try:
|
|
|
|
v = self.fg[name]
|
|
|
|
log(f'Waiting for {name}={value} current value: {v}. timeout={timeout} dt={dt:.1f}')
|
|
|
|
except Exception as e:
|
|
|
|
log(f'Failed to get value of property {name}: {e}. timeout={timeout} dt={dt:.1f}')
|
|
|
|
v = None
|
|
|
|
if v == value:
|
|
|
|
return dt
|
|
|
|
if dt > timeout:
|
|
|
|
raise Exception(f'Timeout waiting for {name}={value}; current value: {v}. timeout={timeout}')
|
|
|
|
|
|
|
|
def run_command(self, command):
|
|
|
|
self.fg.telnet._putcmd(command)
|
|
|
|
ret = self.fg.telnet._getresp()
|
|
|
|
log(f'command={command!r} ret: {ret}')
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def close(self):
|
2021-03-05 20:32:48 +00:00
|
|
|
assert self.child
|
|
|
|
self.child.terminate()
|
|
|
|
self.child.wait()
|
|
|
|
self.child = None
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
|
|
|
|
def __del__(self):
|
2021-03-05 20:32:48 +00:00
|
|
|
if self.child:
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
log('*** Fg.__del__() calling self.close()')
|
|
|
|
self.close()
|
|
|
|
|
|
|
|
def make_recording(
|
|
|
|
fg,
|
|
|
|
continuous=0,
|
|
|
|
extra_properties=0,
|
|
|
|
main_view=0,
|
|
|
|
length=5,
|
|
|
|
):
|
|
|
|
'''
|
|
|
|
Makes a recording, and returns its path.
|
|
|
|
|
|
|
|
We check that the recording file is newly created.
|
|
|
|
'''
|
|
|
|
t = time.time()
|
2021-03-05 20:33:57 +00:00
|
|
|
fg.fg['/sim/replay/record-signals'] = True # Just in case they are disabled by user.
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
if continuous:
|
|
|
|
assert not fg.fg['/sim/replay/record-continuous']
|
|
|
|
fg.fg['/sim/replay/record-continuous'] = 1
|
|
|
|
t0 = time.time()
|
|
|
|
while 1:
|
|
|
|
if time.time() > t0 + length:
|
|
|
|
break
|
|
|
|
fg.run_command('run view-step step=1')
|
|
|
|
time.sleep(1)
|
|
|
|
fg.fg['/sim/replay/record-continuous'] = 0
|
|
|
|
path = f'{fg.aircraft}-continuous.fgtape'
|
|
|
|
time.sleep(1)
|
|
|
|
else:
|
|
|
|
# Normal recording will have effectively already started, so we sleep
|
|
|
|
# for the remaining time. This is a little inaccurate though because it
|
|
|
|
# looks like normal recording starts a little after t=0, e.g. at t=0.5.
|
|
|
|
#
|
|
|
|
# Also, it looks like /sim/time/elapsed-sec doesn't quite track real
|
|
|
|
# time, so we sometimes need to sleep a little longer.
|
|
|
|
#
|
|
|
|
while 1:
|
|
|
|
t = fg.fg['/sim/time/elapsed-sec']
|
|
|
|
log(f'/sim/time/elapsed-sec={t}')
|
|
|
|
if t > length:
|
|
|
|
break
|
|
|
|
time.sleep(length - t + 0.5)
|
|
|
|
log(f'/sim/time/elapsed-sec={t}')
|
|
|
|
fg.fg.telnet._putcmd('run save-tape tape-data/starttime= tape-data/stoptime=')
|
|
|
|
response = fg.fg.telnet._getresp()
|
|
|
|
log(f'response: {response!r}')
|
|
|
|
path = f'{fg.aircraft}.fgtape'
|
|
|
|
|
|
|
|
# Check recording is new.
|
|
|
|
os.system(f'ls -lL {path}')
|
|
|
|
s = os.stat(path, follow_symlinks=True)
|
|
|
|
assert s.st_mtime > t
|
|
|
|
path2 = os.readlink(path)
|
|
|
|
log(f'path={path} path2={path2}')
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
|
|
|
def test_record_replay(
|
|
|
|
fgfs_save,
|
|
|
|
fgfs_load,
|
|
|
|
multiplayer,
|
|
|
|
continuous,
|
|
|
|
extra_properties,
|
|
|
|
main_view,
|
|
|
|
length,
|
|
|
|
):
|
|
|
|
if not fgfs_load:
|
2021-03-07 19:58:44 +00:00
|
|
|
fgfs_load = fgfs_save
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
log(f'=== save: {fgfs_save}')
|
|
|
|
log(f'=== load: {fgfs_load}')
|
|
|
|
log(f'=== --multiplayer {multiplayer} --continuous {continuous} --extra-properties {extra_properties} --main-view {main_view}')
|
|
|
|
log(f'===')
|
|
|
|
|
|
|
|
aircraft = 'harrier-gr3'
|
|
|
|
args = f'--state=vto --airport=egtk'
|
|
|
|
args += f' --prop:bool:/sim/replay/record-extra-properties={extra_properties}'
|
|
|
|
args += f' --prop:bool:/sim/replay/record-main-view={main_view}'
|
|
|
|
args += f' --prop:bool:/sim/replay/record-main-window=0'
|
|
|
|
|
|
|
|
# Start Flightgear.
|
|
|
|
fg = Fg(aircraft, f'{fgfs_save} {args}',
|
|
|
|
#env='SG_LOG_DELTAS=flightgear/src/Network/props.cxx=4',
|
|
|
|
)
|
|
|
|
fg.waitfor('/sim/fdm-initialized', 1, timeout=45)
|
|
|
|
|
|
|
|
assert fg.fg['sim/replay/record-extra-properties'] == extra_properties
|
|
|
|
assert fg.fg['sim/replay/record-main-view'] == main_view
|
|
|
|
log(f'sim/replay/record-extra-properties={fg.fg["sim/replay/record-extra-properties"]}')
|
|
|
|
|
|
|
|
# Save recording:
|
|
|
|
path = make_recording(fg,
|
|
|
|
continuous=continuous,
|
|
|
|
extra_properties=extra_properties,
|
|
|
|
main_view=main_view,
|
|
|
|
length=length,
|
|
|
|
)
|
|
|
|
|
|
|
|
g_cleanup.append(lambda: os.remove(path))
|
|
|
|
fg.close()
|
|
|
|
|
|
|
|
# Load recording into new Flightgear.
|
|
|
|
path = f'{aircraft}-continuous.fgtape' if continuous else f'{aircraft}.fgtape'
|
|
|
|
fg = Fg(aircraft, f'{fgfs_load} {args} --load-tape={path}')
|
|
|
|
fg.waitfor('/sim/fdm-initialized', 1, timeout=45)
|
|
|
|
fg.waitfor('/sim/replay/replay-state', 1)
|
|
|
|
|
|
|
|
# Check replay time is ok.
|
|
|
|
rtime_begin = fg.fg['/sim/replay/start-time']
|
|
|
|
rtime_end = fg.fg['/sim/replay/end-time']
|
|
|
|
rtime = rtime_end - rtime_begin
|
|
|
|
log(f'rtime={rtime_begin}..{rtime_end}, recording length: {rtime}, length={length}')
|
|
|
|
assert rtime > length-1 and rtime < length+2, \
|
|
|
|
f'length={length} rtime_begin={rtime_begin} rtime_end={rtime_end} rtime={rtime}'
|
|
|
|
|
|
|
|
num_frames_extra_properties = fg.fg['/sim/replay/continuous-stats-num-frames-extra-properties']
|
|
|
|
log(f'num_frames_extra_properties={num_frames_extra_properties}')
|
|
|
|
if continuous:
|
|
|
|
if main_view:
|
|
|
|
assert num_frames_extra_properties > 1
|
|
|
|
else:
|
|
|
|
assert num_frames_extra_properties == 0
|
|
|
|
else:
|
|
|
|
assert num_frames_extra_properties in (0, None), \
|
|
|
|
f'num_frames_extra_properties={num_frames_extra_properties}'
|
|
|
|
|
|
|
|
time.sleep(length)
|
|
|
|
|
|
|
|
fg.close()
|
|
|
|
|
|
|
|
os.remove(path)
|
|
|
|
|
|
|
|
log('Test passed')
|
|
|
|
|
|
|
|
|
2021-03-14 21:06:57 +00:00
|
|
|
def test_motion(fgfs):
|
|
|
|
|
|
|
|
aircraft = 'ufo'
|
|
|
|
fg = Fg( aircraft, f'{fgfs} --aircraft={aircraft}')
|
|
|
|
path = f'{fg.aircraft}-continuous.fgtape'
|
|
|
|
|
|
|
|
if 0:
|
|
|
|
items = fg.fg.ls( '/sim')
|
|
|
|
log( '/sim is:')
|
|
|
|
for item in items:
|
|
|
|
log( f' {item}')
|
|
|
|
fg.close()
|
|
|
|
return
|
|
|
|
|
|
|
|
fg.waitfor('/sim/fdm-initialized', 1, timeout=45)
|
|
|
|
|
|
|
|
# Run UFO with constant speed, varying the framerate so we check whether
|
|
|
|
# recorded speeds are affected.
|
|
|
|
#
|
|
|
|
fg.fg['/controls/engines/engine[0]/throttle'] = 0.1
|
|
|
|
fg.fg['/sim/frame-rate-throttle-hz'] = 5
|
|
|
|
|
|
|
|
# Delay to let frame rate settle.
|
|
|
|
time.sleep(10)
|
|
|
|
|
|
|
|
# Start recording.
|
|
|
|
fg.fg['/sim/replay/record-continuous'] = 1
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
# Change frame rate.
|
|
|
|
fg.fg['/sim/frame-rate-throttle-hz'] = 2
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
# Restore original frame rate.
|
|
|
|
fg.fg['/sim/frame-rate-throttle-hz'] = 5
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
# Stop recording.
|
|
|
|
fg.fg['/sim/replay/record-continuous'] = 0
|
|
|
|
|
|
|
|
fg.close()
|
|
|
|
|
|
|
|
path2 = os.readlink( path)
|
|
|
|
g_cleanup.append(lambda: os.remove(path2))
|
|
|
|
|
|
|
|
fg = Fg( aircraft, f'{fgfs} --load-tape={path} --prop:/sim/replay/log-raw-speed=true')
|
|
|
|
fg.waitfor('/sim/fdm-initialized', 1, timeout=45)
|
|
|
|
fg.fg['/sim/frame-rate-throttle-hz'] = 10
|
|
|
|
fg.waitfor('/sim/replay/replay-state', 1)
|
|
|
|
fg.waitfor('/sim/replay/replay-state-eof', 1)
|
|
|
|
|
|
|
|
items0 = fg.fg.ls( '/sim/replay/log-raw-speed-values')
|
|
|
|
items = []
|
|
|
|
for item in items0:
|
|
|
|
if item.name == 'value':
|
|
|
|
items.append(item)
|
|
|
|
num_errors = 0
|
|
|
|
for item in items[:-1]: # Ignore last item because replay at end interpolates.
|
|
|
|
speed = float(item.value)
|
|
|
|
prefix = ' '
|
|
|
|
if abs(speed - 200) > 0.5:
|
|
|
|
num_errors += 1
|
|
|
|
prefix = '*'
|
|
|
|
log( f' {prefix} speed={speed} details: {item}')
|
|
|
|
fg.close()
|
|
|
|
assert num_errors == 0, 'Replay showed uneven speed.'
|
|
|
|
|
|
|
|
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
fgfs = f'./build-walk/fgfs.exe-run.sh'
|
|
|
|
fgfs_old = None
|
|
|
|
|
2021-03-14 21:06:57 +00:00
|
|
|
do_test = 'all'
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
continuous_s = [0, 1]
|
|
|
|
extra_properties_s = [0, 1]
|
|
|
|
main_view_s = [0, 1]
|
|
|
|
multiplayer_s = [0, 1]
|
|
|
|
fgfs_reverse_s = [0]
|
|
|
|
it_min = None
|
|
|
|
it_max = None
|
|
|
|
|
|
|
|
if len(sys.argv) == 1:
|
|
|
|
do_all = True
|
|
|
|
|
|
|
|
args = iter(sys.argv[1:])
|
|
|
|
while 1:
|
|
|
|
try:
|
|
|
|
arg = next(args)
|
|
|
|
except StopIteration:
|
|
|
|
break
|
|
|
|
if arg == '--all':
|
|
|
|
do_all = True
|
|
|
|
elif arg == '--continuous':
|
|
|
|
continuous_s = map(int, next(args).split(','))
|
|
|
|
elif arg == '--extra-properties':
|
|
|
|
extra_properties_s = map(int, next(args).split(','))
|
|
|
|
elif arg == '--it-max':
|
|
|
|
it_max = int(next(args))
|
|
|
|
elif arg == '--it-min':
|
|
|
|
it_min = int(next(args))
|
|
|
|
elif arg == '--main-view':
|
|
|
|
main_view_s = map(int, next(args).split(','))
|
|
|
|
elif arg == '--multiplayer':
|
|
|
|
multiplayer_s = map(int, next(args).split(','))
|
|
|
|
elif arg == '-f':
|
|
|
|
fgfs = next(args)
|
|
|
|
elif arg == '--f-old':
|
|
|
|
fgfs_old = next(args)
|
|
|
|
fgfs_reverse = [0, 1]
|
2021-03-14 21:06:57 +00:00
|
|
|
elif arg == '--test-motion':
|
|
|
|
do_test = 'motion'
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
else:
|
|
|
|
raise Exception(f'Unrecognised arg: {arg!r}')
|
|
|
|
|
2021-03-14 21:06:57 +00:00
|
|
|
if do_test == 'motion':
|
|
|
|
test_motion( fgfs)
|
|
|
|
elif do_test == 'all':
|
|
|
|
try:
|
|
|
|
if fgfs_old:
|
|
|
|
for fgfs1, fgfs2 in [(fgfs, fgfs_old), (fgfs_old, fgfs)]:
|
|
|
|
for multiplayer in 0, 1:
|
|
|
|
test_record_replay(
|
|
|
|
fgfs1,
|
|
|
|
fgfs2,
|
|
|
|
multiplayer,
|
|
|
|
continuous=0,
|
|
|
|
extra_properties=0,
|
|
|
|
main_view=0,
|
|
|
|
length=10,
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
its_max = len(multiplayer_s) * len(continuous_s) * len(extra_properties_s) * len(main_view_s) * len(fgfs_reverse_s)
|
|
|
|
it = 0
|
|
|
|
for multiplayer in multiplayer_s:
|
|
|
|
for continuous in continuous_s:
|
|
|
|
for extra_properties in extra_properties_s:
|
|
|
|
for main_view in main_view_s:
|
|
|
|
for fgfs_reverse in fgfs_reverse_s:
|
|
|
|
if fgfs_reverse:
|
|
|
|
fgfs_save = fgfs_old
|
|
|
|
fgfs_load = fgfs
|
|
|
|
else:
|
|
|
|
fgfs_save = fgfs
|
|
|
|
fgfs_load = fgfs_old
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
|
2021-03-14 21:06:57 +00:00
|
|
|
ok = True
|
|
|
|
if it_min is not None:
|
|
|
|
if it < it_min:
|
|
|
|
ok = False
|
|
|
|
if it_max is not None:
|
|
|
|
if it >= it_max:
|
|
|
|
ok = False
|
|
|
|
log('')
|
|
|
|
log(f'===')
|
|
|
|
log(f'=== {it}/{its_max}')
|
|
|
|
if ok:
|
|
|
|
test_record_replay(
|
|
|
|
fgfs_save,
|
|
|
|
fgfs_load,
|
|
|
|
multiplayer=multiplayer,
|
|
|
|
continuous=continuous,
|
|
|
|
extra_properties=extra_properties,
|
|
|
|
main_view=main_view,
|
|
|
|
length=10
|
|
|
|
)
|
|
|
|
it += 1
|
|
|
|
finally:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
assert 0, f'do_test={do_test}'
|
Added record/replay of extra properties, with specific support for window size/position and view settings.
Recording of extra properties is only supported in Continuous recordings.
Modified Continuous recording format to allow future forwards
compatibility. See docs-mini/README-recordings.md for details. This breaks
compatibility with previously-generated Continuous recordings, but this only
affects next.
To reduce overhead we record all extra property values in the first frame and
then later frames contain only extra property changes. When replaying, if the
user jumps backwards we replay all extra property changes since the start of
the recording. Similarly if the user jumps forwards, we replay any intervening
extra property changes.
Recording extra properties:
This is enabled by:
/sim/replay/record-extra-properties
The extra properties that are recorded are identified by the property
paths in the values of /sim/replay/record-extra-properties-paths/path[]
properties. We record the entire tree for each specified path.
Recording of main window position size:
We have specific support for record and replay of main window position/size.
This is enabled by:
/sim/replay/record-main-window
Recording of main window view:
We have specific support for recording the view type and direction/zoom
settings.
This is enabled by:
/sim/replay/record-main-view
We record the /sim/current-view/ property tree, excluding some subtrees
that continuously vary but are not required for replaying of the view.
When replaying, we allow separate control of what extra property changes are
replayed, with:
/sim/replay/replay-extra-property-changes
/sim/replay/replay-extra-property-removal
/sim/replay/replay-main-window-position
/sim/replay/replay-main-window-size
/sim/replay/replay-main-view
We work around some problems caused by the use of tied properties when
replaying changes to view-number.
Window position issue:
When replaying window position and size changes, things get a little tricky
because osgViewer::GraphicsWindow::setWindowRectangle() takes a position
for the entire window, but osgGA::GUIEventAdapter::RESIZE events contain
the position of the interior of the window; for example the y values will
differ by the height of the window's titlebar. This can cause windows to
move progressively further down each time they are positioned or resized.
There doesn't seem to be a way of finding the size of a window's
furniture directly. So instead this commit adds a new method
osgGA::GUIEventAdapter::setWindowRectangleInteriorWithCorrection() which
wraps osgViewer::GraphicsWindow::setWindowRectangle(). We listen for the
following osgGA::GUIEventAdapter::RESIZE event and calculate corrections
for x and y position that are used for subsequent calls.
docs-mini/README-recordings.md:
Updated to document new Continuous format.
scripts/python/recordreplay.py:
New script to test various aspects of record/replay.
Other:
We now create convenience softlink to most recent continuous recording, using
SGPath::makeLink(). Note that SGPath::makeLink() currently does nothing on
Windows.
Changed format of Continuous recordings to contain a single property tree
in header. This is much simpler than having separate Config and Meta trees.
2020-12-24 14:21:38 +00:00
|
|
|
|
|
|
|
# If everything passed, cleanup. Otherwise leave recordings in place, as
|
|
|
|
# they can be useful for debugging.
|
|
|
|
#
|
|
|
|
for f in g_cleanup:
|
|
|
|
try:
|
|
|
|
f()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
if 0:
|
|
|
|
# This path can be used to check we cleanup properly after an error.
|
|
|
|
fg = Fg('./build-walk/fgfs.exe-run.sh --aircraft=harrier-gr3 --airport=egtk')
|
|
|
|
time.sleep(5)
|
|
|
|
assert 0
|