From a27a82b4adc46243c8faa810b6beb0fb3c81cb12 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Wed, 23 Nov 2016 15:34:04 +0200 Subject: [PATCH] Tentative fix for accelerometers using YaSim properties in JSBSim or optionally generated properties --- Aircraft/Generic/g-forces.xml | 1705 ++++++++++++++++----------------- Nasal/redout.nas | 176 ++-- preferences.xml | 7 +- 3 files changed, 926 insertions(+), 962 deletions(-) diff --git a/Aircraft/Generic/g-forces.xml b/Aircraft/Generic/g-forces.xml index 523afb8e9..f94b9d817 100644 --- a/Aircraft/Generic/g-forces.xml +++ b/Aircraft/Generic/g-forces.xml @@ -1,863 +1,842 @@ - - - - - - sim/rendering/redout/parameters/blackout-onset-g - sim/rendering/redout/parameters/blackout-complete-g - sim/rendering/redout/parameters/redout-onset-g - sim/rendering/redout/parameters/redout-complete-g - sim/rendering/redout/parameters/onset-blackout-sec - sim/rendering/redout/parameters/fast-blackout-sec - sim/rendering/redout/parameters/onset-redout-sec - sim/rendering/redout/parameters/fast-redout-sec - sim/rendering/redout/parameters/recover-fast-sec - sim/rendering/redout/parameters/recover-slow-sec - - sim/rendering/redout/internal/log/g-force - sim/rendering/redout/internal/log/onset-b - sim/rendering/redout/internal/log/fast-b - sim/rendering/redout/internal/log/g-force-r - sim/rendering/redout/internal/log/onset-r - sim/rendering/redout/internal/log/fast-r - - sim/rendering/redout/internal/g-force - sim/rendering/redout/internal/g-force-inv - sim/rendering/redout/internal/blackout - sim/rendering/redout/internal/redout - - sim/rendering/redout/alpha - sim/rendering/redout/red - sim/current-view/internal - sim/rendering/redout/internal/sum - sim/rendering/redout/enabled - - - - gain - 0 - - - - - - - 1000.0 - - - - -1000.0 - - - - - - 0 - - - - - - gain - 0 - - - - - - - 1000.0 - - - - -1000.0 - - - - - - 0 - - - - - - gain - 1 - - - - - - - 1.25 - - - - - - - - - 1.25 - - - - - - - - gain - 1 - - - - - - - - - - - 1.5 - - - - - - - - - - 0.50 - - 1.5 - - - - - - - - gain - 1 - - - - - - - -1.00 - - - - - - - - - -1.00 - - - - - - - - gain - 1 - - - - - - - - - - - -1.25 - - - - - - - - - - -0.50 - - -1.25 - - - - - - - - gain - -1 - - - - - - fdm/jsbsim/aero/alpha-deg - 180.0 - - - fdm/jsbsim/aero/alpha-deg - -180.0 - - - - - -
- accelerations/pilot/z-accel-fps_sec - 32.174 -
-
- - -
- - - gain - 1 - - - - - - - fdm/jsbsim/aero/alpha-deg - 180.0 - - - fdm/jsbsim/aero/alpha-deg - -180.0 - - - - - - accelerations/pilot-g[0] - - - - - - gain - 1 - - - - - - - - - - - - - - - - - gain - 1 - - - - - - - - - - - - - - - - - gain - 1 - - - - - - 1 - - - - - 0 - - - - - - gain - 1 - - - - - - 1 - - - - - - - - - - - - - - - gain - 1 - - - - - - - - - - - - - 1 - - 0 - - - - sim/time/delta-sec -
- 1 - - 0 - - - -
- - - - 1 - - - - - - 1 - - -
- - - - -
-
-
-
-
-
-
-
-
- - -
- - - gain - 1 - - - - - - - - - - - - - 1 - - 0 - - - - sim/time/delta-sec -
- 1 - - 0 - - 10 - - - - - -
- - - - - - - - -
- - - - - - - - -
-
-
-
-
-
-
-
-
-
- - -
- - - gain - 1 - - - - - - - - - - -1 - - - 2 - - - - - - - - - - gain - 1 - - - - - - - - - - -1 - - - 2 - - - - - - - - - - gain - -1 - - - - - - - - - - 2 - - - - - - - - gain - 1 - - - - - - 1 - - - - - 0 - - - - - - gain - 1 - - - - - - 1 - - - - - - - - - - - - - - - gain - 1 - - - - - - - - - - - - - 1 - - 0 - - - - sim/time/delta-sec -
- 1 - - 0 - - - -
- - - - 1 - - - - - - 1 - - -
- - - - -
-
-
-
-
-
-
-
-
- - -
- - - gain - 1 - - - - - - - - - - - - - 1 - - 0 - - - - sim/time/delta-sec -
- 1 - - 0 - - 10 - - - - - -
- - - - - - - - -
- - - - - - - - -
-
-
-
-
-
-
-
-
-
- - -
- - - gain - 1 - - - - - - - - - - - - - - - - - - gain - 1 - - - - - - 1 - - - - 0 - - - - - 1 - - - - - - gain - 1 - - - - - - 1 - - - - 0 - - - - - - - - -1 - - - - - - - - gain - 1 - - - - - - 1 - - - - 0 - - - - - 0 - - - - - - gain - 1 - - - - - - 1 - - - - 0 - - - - - - - - - - - gain - 0 - - - - - - - - - 0 - - - - - - 0 - - - - - - gain - 0 - - - - - - - - - 0 - - - - - - gain - 0 - - - - - - - - - 0 - - - - -
+ + + + + + sim/rendering/redout/parameters/blackout-onset-g + sim/rendering/redout/parameters/blackout-complete-g + sim/rendering/redout/parameters/redout-onset-g + sim/rendering/redout/parameters/redout-complete-g + sim/rendering/redout/parameters/onset-blackout-sec + sim/rendering/redout/parameters/fast-blackout-sec + sim/rendering/redout/parameters/onset-redout-sec + sim/rendering/redout/parameters/fast-redout-sec + sim/rendering/redout/parameters/recover-fast-sec + sim/rendering/redout/parameters/recover-slow-sec + + sim/rendering/redout/internal/log/g-force + sim/rendering/redout/internal/log/onset-b + sim/rendering/redout/internal/log/fast-b + sim/rendering/redout/internal/log/g-force-r + sim/rendering/redout/internal/log/onset-r + sim/rendering/redout/internal/log/fast-r + + accelerations/pilot-gdamped + sim/rendering/redout/internal/g-force-inv + sim/rendering/redout/internal/blackout + sim/rendering/redout/internal/redout + sim/rendering/redout/internal/jsb + sim/rendering/redout/alpha + sim/rendering/redout/red + sim/current-view/internal + sim/rendering/redout/internal/sum + sim/rendering/redout/enabled + accelerations/pilot-g[0] + + + + gain + 0 + + + + + + + 1000.0 + + + + -1000.0 + + + + + + 0 + + + + + + gain + 0 + + + + + + + 1000.0 + + + + -1000.0 + + + + + + 0 + + + + + + gain + 1 + + + + + + + 1.25 + + + + + + + + + 1.25 + + + + + + + + gain + 1 + + + + + + + + + + + 1.5 + + + + + + + + + + 0.50 + + 1.5 + + + + + + + + gain + 1 + + + + + + + -1.00 + + + + + + + + + -1.00 + + + + + + + + gain + 1 + + + + + + + + + + + -1.25 + + + + + + + + + + -0.50 + + -1.25 + + + + + + + + gain + -1 + + + + + + 1 + + + + + +
+ accelerations/pilot/z-accel-fps_sec + 32.174 +
+
+ + +
+ + + + exponential + 0.2 + + + + + + gain + 1 + + + + + + + + + + + + + + + + + gain + 1 + + + + + + + + + + + + + + + + + gain + 1 + + + + + + 1 + + + + + 0 + + + + + + gain + 1 + + + + + + 1 + + + + + + + + + + + + + + + gain + 1 + + + + + + + + + + + + + 1 + + 0 + + + + sim/time/delta-sec +
+ 1 + + 0 + + + +
+ + + + 1 + + + + + + 1 + + +
+ + + + +
+
+
+
+
+
+
+
+
+ + +
+ + + gain + 1 + + + + + + + + + + + + + 1 + + 0 + + + + sim/time/delta-sec +
+ 1 + + 0 + + 10 + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+
+
+
+
+
+
+
+
+
+ + +
+ + + gain + 1 + + + + + + + + + + -1 + + + 2 + + + + + + + + + + gain + 1 + + + + + + + + + + -1 + + + 2 + + + + + + + + + + gain + -1 + + + + + + + + + + 2 + + + + + + + + gain + 1 + + + + + + 1 + + + + + 0 + + + + + + gain + 1 + + + + + + 1 + + + + + + + + + + + + + + + gain + 1 + + + + + + + + + + + + + 1 + + 0 + + + + sim/time/delta-sec +
+ 1 + + 0 + + + +
+ + + + 1 + + + + + + 1 + + +
+ + + + +
+
+
+
+
+
+
+
+
+ + +
+ + + gain + 1 + + + + + + + + + + + + + 1 + + 0 + + + + sim/time/delta-sec +
+ 1 + + 0 + + 10 + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+
+
+
+
+
+
+
+
+
+ + +
+ + + gain + 1 + + + + + + + + + + + + + + + + + + gain + 1 + + + + + + 1 + + + + 0 + + + + + 1 + + + + + + gain + 1 + + + + + + 1 + + + + 0 + + + + + + + + -1 + + + + + + + + gain + 1 + + + + + + 1 + + + + 0 + + + + + 0 + + + + + + gain + 1 + + + + + + 1 + + + + 0 + + + + + + + + + + + gain + 0 + + + + + + + + + 0 + + + + + + 0 + + + + + + gain + 0 + + + + + + + + + 0 + + + + + + gain + 0 + + + + + + + + + 0 + + + + +
\ No newline at end of file diff --git a/Nasal/redout.nas b/Nasal/redout.nas index 275cbc596..0c88badef 100644 --- a/Nasal/redout.nas +++ b/Nasal/redout.nas @@ -1,98 +1,78 @@ -# Damped G value - starts at 1. -var GDamped = 1.0; -var previousG = 1.0; -var running_compression = 0; -var fdm = "jsb"; - -var compression_rate = nil; -var internal = nil; - -var lp_black = nil; -var lp_red = nil; - -var run = func { - - if (running_compression) - { - var GCurrent = 1.0; - - if (fdm == "jsb") - { - GCurrent = getprop("/accelerations/pilot/z-accel-fps_sec"); - if (GCurrent != nil) GCurrent = - GCurrent / 32; - } - else - { - GCurrent = getprop("/accelerations/pilot-g[0]"); - } - - if (GCurrent == nil) - { - GCurrent = 1.0; - } - - # Updated the GDamped using a filter. - if (GDamped < 0) - { - # Redout happens faster and clears quicker - GDamped = lp_red.filter(GCurrent); - } - else - { - GDamped = lp_black.filter(GCurrent); - } - - setprop("/accelerations/pilot-gdamped", GDamped); - - if (internal) - { - if (running_compression) - { - # Apply any compression due to G-forces - if (GDamped != previousG) - { - var current_y_offset = getprop("/sim/current-view/y-offset-m"); - setprop("/sim/current-view/y-offset-m", current_y_offset - (GDamped - previousG) * compression_rate); - previousG = GDamped; - } - } - } - - settimer(run, 0); - } -} - -var fdm_init_listener = _setlistener("/sim/signals/fdm-initialized", - func { - removelistener(fdm_init_listener); # uninstall, so we're only called once - fdm = getprop("/sim/flight-model"); - running_compression = getprop("/sim/rendering/headshake/enabled"); - internal = getprop("/sim/current-view/internal"); - lp_black = aircraft.lowpass.new(0.2); - lp_red = aircraft.lowpass.new(0.25); - - setlistener("/sim/current-view/internal", func(n) { - internal = n.getBoolValue(); - }); - - setlistener("/sim/rendering/headshake/rate-m-g", func(n) { - compression_rate = n.getValue(); - }, 1); - - setlistener("/sim/rendering/headshake/enabled", func(n) { - if ((running_compression == 0) and n.getBoolValue()) - { - running_compression = 1; - # start new timer now - run(); - } - else - { - running_compression = n.getBoolValue(); - } - }, 1); - - # Now we've set up the listeners (which will have triggered), run it. - run(); - } -); +# Damped G value - starts at 1. +var GDamped = 1.0; +var previousG = 1.0; +var running_compression = 0; +var fdm = "jsb"; + +var compression_rate = nil; +var internal = nil; + +var lp_black = nil; +var lp_red = nil; + +var run = func { + + if (running_compression) + { + GDamped = getprop("/accelerations/pilot-gdamped"); + + if (internal) + { + if (running_compression) + { + # Apply any compression due to G-forces + if (GDamped != previousG) + { + var current_y_offset = getprop("/sim/current-view/y-offset-m"); + setprop("/sim/current-view/y-offset-m", current_y_offset - (GDamped - previousG) * compression_rate); + previousG = GDamped; + } + } + } + + settimer(run, 0); + } +} + +var fdm_init_listener = _setlistener("/sim/signals/fdm-initialized", + func { + removelistener(fdm_init_listener); # uninstall, so we're only called once + fdm = getprop("/sim/flight-model"); + + if (fdm == "jsb") { + # this is used in the g-force property rules. + setprop("/sim/rendering/redout/internal/jsb", 1); + } else { + setprop("/sim/rendering/redout/internal/jsb", 0); + } + + running_compression = getprop("/sim/rendering/headshake/enabled"); + internal = getprop("/sim/current-view/internal"); + lp_black = aircraft.lowpass.new(0.2); + lp_red = aircraft.lowpass.new(0.25); + + setlistener("/sim/current-view/internal", func(n) { + internal = n.getBoolValue(); + }); + + setlistener("/sim/rendering/headshake/rate-m-g", func(n) { + compression_rate = n.getValue(); + }, 1); + + setlistener("/sim/rendering/headshake/enabled", func(n) { + if ((running_compression == 0) and n.getBoolValue()) + { + running_compression = 1; + # start new timer now + run(); + } + else + { + running_compression = n.getBoolValue(); + } + }, 1); + + # Now we've set up the listeners (which will have triggered), run it. + run(); + } +); diff --git a/preferences.xml b/preferences.xml index f20786681..e2342b8ce 100644 --- a/preferences.xml +++ b/preferences.xml @@ -266,7 +266,7 @@ Started September 2000 by David Megginson, david@megginson.com 15 - 1 + false 1 0 0 @@ -919,6 +919,11 @@ Started September 2000 by David Megginson, david@megginson.com 10 + + + 1.0 + 1.0 +