1
0
Fork 0

Tentative fix for accelerometers using YaSim properties in JSBSim or optionally generated properties

This commit is contained in:
Thorsten Renk 2016-11-23 15:34:04 +02:00
parent 52e5592442
commit a27a82b4ad
3 changed files with 926 additions and 962 deletions

View file

@ -9,7 +9,7 @@
## Todo: Tie in with Thorstens ALS greyout and tunnel vision filters ## ## Todo: Tie in with Thorstens ALS greyout and tunnel vision filters ##
## ## ## ##
## ## ## ##
## Version 2.03 License: GPL 2.0 ## ## Version 2.04 License: GPL 2.0 ##
## ## ## ##
################################################################################### ###################################################################################
--> -->
@ -34,16 +34,17 @@
<onset-r>sim/rendering/redout/internal/log/onset-r</onset-r> <onset-r>sim/rendering/redout/internal/log/onset-r</onset-r>
<fast-r>sim/rendering/redout/internal/log/fast-r</fast-r> <fast-r>sim/rendering/redout/internal/log/fast-r</fast-r>
</log> </log>
<g-force>sim/rendering/redout/internal/g-force</g-force> <g-damp>accelerations/pilot-gdamped</g-damp>
<g-force-inv>sim/rendering/redout/internal/g-force-inv</g-force-inv> <g-force-inv>sim/rendering/redout/internal/g-force-inv</g-force-inv>
<blackout>sim/rendering/redout/internal/blackout</blackout> <blackout>sim/rendering/redout/internal/blackout</blackout>
<redout>sim/rendering/redout/internal/redout</redout> <redout>sim/rendering/redout/internal/redout</redout>
<jsb>sim/rendering/redout/internal/jsb</jsb>
<alpha>sim/rendering/redout/alpha</alpha> <alpha>sim/rendering/redout/alpha</alpha>
<red>sim/rendering/redout/red</red> <red>sim/rendering/redout/red</red>
<inside>sim/current-view/internal</inside> <inside>sim/current-view/internal</inside>
<sum>sim/rendering/redout/internal/sum</sum> <sum>sim/rendering/redout/internal/sum</sum>
<enable>sim/rendering/redout/enabled</enable> <enable>sim/rendering/redout/enabled</enable>
<g-force>accelerations/pilot-g[0]</g-force>
</params> </params>
<filter><!-- check for NaN --> <filter><!-- check for NaN -->
@ -214,15 +215,10 @@
<enable> <enable>
<!-- check if JSBSim is the FDM. --> <!-- check if JSBSim is the FDM. -->
<condition> <condition>
<property alias="/params/enable"/> <equals>
<less-than> <property alias="/params/jsb"/>
<property>fdm/jsbsim/aero/alpha-deg</property> <value>1</value>
<value>180.0</value> </equals>
</less-than>
<greater-than>
<property>fdm/jsbsim/aero/alpha-deg</property>
<value>-180.0</value>
</greater-than>
</condition> </condition>
</enable> </enable>
<input> <input>
@ -237,28 +233,11 @@
</filter> </filter>
<filter> <filter>
<type>gain</type> <!-- for backwards compatibility for planes that use gdamped property -->
<gain>1</gain> <type>exponential</type>
<enable> <filter-time>0.2</filter-time>
<!-- check if YaSim is the FDM. --> <input alias="/params/g-force"/>
<condition> <output alias="/params/g-damp"/>
<property alias="/params/enable"/>
<not>
<less-than>
<property>fdm/jsbsim/aero/alpha-deg</property>
<value>180.0</value>
</less-than>
<greater-than>
<property>fdm/jsbsim/aero/alpha-deg</property>
<value>-180.0</value>
</greater-than>
</not>
</condition>
</enable>
<input>
<property>accelerations/pilot-g[0]</property>
</input>
<output alias="/params/g-force"/>
</filter> </filter>
<filter> <filter>

View file

@ -14,35 +14,7 @@ var run = func {
if (running_compression) if (running_compression)
{ {
var GCurrent = 1.0; GDamped = getprop("/accelerations/pilot-gdamped");
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 (internal)
{ {
@ -66,6 +38,14 @@ var fdm_init_listener = _setlistener("/sim/signals/fdm-initialized",
func { func {
removelistener(fdm_init_listener); # uninstall, so we're only called once removelistener(fdm_init_listener); # uninstall, so we're only called once
fdm = getprop("/sim/flight-model"); 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"); running_compression = getprop("/sim/rendering/headshake/enabled");
internal = getprop("/sim/current-view/internal"); internal = getprop("/sim/current-view/internal");
lp_black = aircraft.lowpass.new(0.2); lp_black = aircraft.lowpass.new(0.2);

View file

@ -266,7 +266,7 @@ Started September 2000 by David Megginson, david@megginson.com
<recover-slow-sec type="double">15</recover-slow-sec> <recover-slow-sec type="double">15</recover-slow-sec>
</parameters> </parameters>
<internal> <internal>
<g-force type="double">1</g-force> <jsb type="bool">false</jsb>
<g-force-inv type="double">1</g-force-inv> <g-force-inv type="double">1</g-force-inv>
<blackout type="double">0</blackout> <blackout type="double">0</blackout>
<redout type="double">0</redout> <redout type="double">0</redout>
@ -919,6 +919,11 @@ Started September 2000 by David Megginson, david@megginson.com
<warp-easing-duration-secs type="double">10</warp-easing-duration-secs> <warp-easing-duration-secs type="double">10</warp-easing-duration-secs>
</time> </time>
</sim> </sim>
<!-- accelerations -->
<accelerations>
<pilot-gdamped type="double">1.0</pilot-gdamped>
<pilot-g type="double">1.0</pilot-g>
</accelerations>
<!-- mouse mode --> <!-- mouse mode -->
<devices> <devices>
<status> <status>