Hi, digging trough the code I found that the enhanced gyro based heading indicator (heading_indicator_dg.cxx) just is electrically driven.
This patch adds optional vacuum support, so just by configuration the aircraft developer can attach a vacuum source instead of an electrical one.
This happens by supplying the standard <suction> property tag to the instrumentation.xml config:</suction>
A) Electrically driven, by standard power-supply properties:
<heading-indicator-dg>
<name>heading-indicator</name>
<number>0</number>
</heading-indicator-dg>
B) Electrically driven by custom properties:
<heading-indicator-dg>
<name>heading-indicator</name>
<number>0</number>
<power-supply>/systems/electrical/outputs/heading-indicator</power-supply>
<minimum-supply-volts>12.0</minimum-supply-volts>
</heading-indicator-dg>
C) Vacuum driven (NEW):
<heading-indicator-dg>
<name>heading-indicator</name>
<number>0</number>
<suction>/systems/vacuum/suction-inhg</suction>
</heading-indicator-dg>
(I have seen that the patch created with
--format-patchdoes not apply cleanly.Therefore here is gyroEnhancement1.patch, which was created by
git diffand aplies cleanly usinggit apply gyroEnhancement_1.patch.)Diff:
Normal we do electric vs vacuum as seperate instruments, or at least they appear to be (from XML side) even if it's the same C++ code internally. I think that's a bit cleaner than using the presence of absence of the <suction> property, how do you feel about it?</suction>
I do not know of conventions, unfortunately.
The "problem" we have here is, we have already alot of heading_indicator instruments and its not obvious what kind of imlpementation it is.
Maybe the heading_indicator_dg.cxx can in the future replace the heading_indicator.cxx one (or the way around, namewise; the heading_indicator_dg.cxx looks like a vastly expanded copy of heading_indicator.cxx).
The heading_indicator_dg.cxx models a HI tied to a gyro, and I wold naively expect that gyro to be configurable on the power sources.
And then there is also already the heading_indicator_fg.cxx modelling a flux gate HI (and there the implementation really differs, and that is also always electrical).
What is the option here? Copy&Paste the code to another new instrument with the same code?
I would say, that configurable sources is easier to understand, especially since the HI-instrument) itself doesn't care what actually drives the spin of the gyro (hence swappable sources from the inst-definition).
To summarize, my feeling is, that it's better not to have too much duplicated code:
My impression is heading_indicator_dg.cxx was meant to be the configurable, fancy one, and heading_indicator.cxx was left for compat.
I'd suggest we make the gyro source in heading_indicator_dg configurable, and only do bug-fxies (no new features) in heading_indicator.cxx. Ideally we would actually see a vaccum-driven HI in instrumentation.xml but create a heading-indicator-DG witht he vaccum supply set, to avoid code duplication.
(And yeah we cannot do anything about the seperate flux-gate HI of course)
This is basically your points 1 & 2, just we need to be sure we don't break anything, which I would 99% guess is why the 'old' heading_indicator.cxx was kept when the gyro version was added.
Sounds very reasonable :)
So in light of this, maybe we shuld forget about the fix fr the precession in the "old" one.
But we really should ammend the wiki to show the differences (I can do that).
And also a "deprecated" code comment in heading_indicator.cxx would really not harm :)
The patched heading_indicator.cxx here, I checked in the outlined configurations above and it worked like intended.
Okay, made an attempt on this:
https://sourceforge.net/p/flightgear/flightgear/ci/dea806d7adc45aca5b9c87eb618203c05c1742a0/
(Either cherry-pick the patch or pull the branch to test)
We don't do the 'increase error with reducing gyro spin' which heading_indicator_dg.cxx does, but I think we should just bug-fix here and push people to swtich to the DG version if they want features.
(I think you would have wanted to put that comment to the other ticket: https://sourceforge.net/p/flightgear/codetickets/2838/ ; also, the branch name has a number mismatch (2828 instead of 2838)
Ooops, too many tickets
The airport model does not load
Airport:Rjtt
Version:2020.3.19
the scenery loads only the terminal Model Not loading
Last edit: Edward kowalski 2023-12-06
Diff:
Diff:
Hi,
I spent the evenening coding this all here.
You can fetch my private git clone here: https://beni.hallinger.org/git/flightgear.git
The branch is named
gyroEnhancement.I greatly expanded the proposed patch-implementation (which adds optional vaccum support) by making the errors and limits configurable at runtime (see Instruments
limitssubtree) as well as configurable by the instrumentation.xml.Available keys are described in the cxx-headerfile.
A full example is (beware, values totally mad for testing):
Leaving the definitions out will initialize the props in the
limitssubtree of the instrument at default values (which I have taken from the code, so its 100% downward compatible)I did some further reading, and regarding some sources the drift is not modelled correctly:
https://forum.flightgear.org/viewtopic.php?p=366368#p366368 (referencing kcs55.nas which is to be found here)
https://en.wikipedia.org/wiki/Heading_indicator
The drift should be:
I think, the branch is a good spot to work on this, so I try to get my hands wet on this too.
kcs55.nas has this( where D2R is pi/180.0
#define D2R (3.14159 / 180.0))Just pushed commit 81fb5c8a009 to my repo (tested it).
This implements correct gyro drift per latitude (15°/hr at the poles, 0° at equator).
And it introduces a
latitude-nut-setting-property at which the gyro can be calibrated to the latitude the plane will be at. This cancels that error for the most part.It defaults to 0, which let it exhibit the drift seen before (however note: the "old" drift was errornous always 15°/hour assuming northern hemisphere, which was wrong in sign and magnitude!)
Last edit: Benedikt Hallinger 2023-12-13
I also detected that transport wander error is not modelled yet.
I think I give that a go too. I currently have a run here :)
Just pushed commit 24baf7063.
We have transport error now, and that means that all errors are simulated as far as my knowlede goes :)
You can fetch my private git clone here: https://beni.hallinger.org/git/flightgear.git
The branch is named
gyroEnhancement.Last edit: Benedikt Hallinger 2023-12-13
Yes that was fun.
Added tumbling induced by excess G-Forces and caging of the gyro to prevent it.
The new prop
limits/g-limit-tumble-factor(same name for the instrumentation.xml config) allows tuning when the tumbling should start (it is signified in the newtumble-flag) andcaged-flagcan be set from instrument models to allow caging (C182s has a branch for the new features here)Just had a test flight in the GA Wednesday group and it looks good.
Should be ready for review. :)
Last edit: Benedikt Hallinger 2023-12-15
This weekend is crazy but will try to review soon!
(Note: Merging this will also fix #2840)
Just stumbled over this.
I think the gyro spins up way too fast, manufacturer (kellys), spin up starts at 2.5inHg and will be able to reach 100% at 4.5inHg.
We should make spinup (and spin down) time also configurable.
https://www.kellymfg.com/faqs.html#:~:text=It%20requires%20approximately%203%20minutes,the%20rotor%20reaches%20full%20speed.
OK; just pushed to my repo.
I made the gyro configurable in commit 48f1587232b58fcae14e.
The change is twofold:
(1) The base is at the C++ level; so there are just two new methods that can optionally be called to adjust the gyros speeds (
Gyro::set_spin_upandGyro::set_spin_down).So in the future, any instrument that wants values different from the previously hard coded defaults (4 and 180 seconds) are now able to call the methods to adjust it.
Probably in the future it would be a good thing, if other instruments would follow the approach taken in (2) by heading_indicator_dg:
(2) This is then used by heading_indicator_dg onward from commit 77380212f3113f4, which introduces two new config properties for instrumentation.xml:
<gyro-spin-up-sec> and/or <gyro-spin-down-sec>. These are again also exposed to the instrument tree to be changed at runtime.</gyro-spin-down-sec></gyro-spin-up-sec>
I just had extensive testing with the updated Issue525_saveDG_offset branch from the C182.
(And again; I still think this is ready to be merged)