Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CG of wing tanks too far outboard #1327

Closed
okroth opened this issue Jul 28, 2020 · 92 comments · Fixed by #1328
Closed

CG of wing tanks too far outboard #1327

okroth opened this issue Jul 28, 2020 · 92 comments · Fixed by #1328
Labels

Comments

@okroth
Copy link

okroth commented Jul 28, 2020

in the c172p.xml file, the CG position of tank 0 and 1 seem to be wrong. The y-position shall be 112" outboard, whereas in reality the tanks are, according to the parts catalogue, positioned between WS38.38 and WS65.125. That would result in a y-position near 51.8 inches.
On top the x position is given with 56" aft of firewall, but the POH indicates 48" on page 6-9.
The capacity is given with 185lbs eq. to 30.6gallons. Is this correct?
Although of minor influence, one should position the float chambers tank 3 and 4 near the engine, about x=-10, y=0, z=26.

@dany93
Copy link
Collaborator

dany93 commented Jul 28, 2020

Thank you @okroth, I'm looking at this.

@dany93 dany93 added the FDM label Jul 28, 2020
@wlbragg
Copy link
Collaborator

wlbragg commented Jul 28, 2020

@dany93 let me know what you come up with including the feeder tanks. I'll merge any changes if you feel a need to adjust.
Thank you @okroth for reporting this.

@dany93
Copy link
Collaborator

dany93 commented Jul 28, 2020

Thank you @wlbragg.
The feeder tanks (3 and 4) should give no noticeable effect.
For the rest (main tanks) it's not so simple, I think I will appreciate your help, depending on the solution and options we choose.

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 28, 2020

For the rest (main tanks) it's not so simple

How come, isn't it just a matter of changing the position in the "fuel" section of c172p.xml?

Looking at them briefly in the code. What the coded position should be is the center of the tank on the x and y, I don't know about the z position, that should either be the bottom of the tank or the center as well. I did a rough measurement of where the center of the "modeled" tank would likely be and it was indeed right around 50-52"

Below is the position being calculated in the code (center of the arrows) which is off by quite a bit. How we never noticed is interesting. Top = Y and Z, Bottom = X.
tank

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 28, 2020

If we changed the fuel center position in the code to the below numbers, (see the cursor position in the Blender image), I think it would be close enough. Certainly way closer to what it should be.
tank2

@okroth
Copy link
Author

okroth commented Jul 29, 2020

I just found in the POH, page 6-10 (or page 1-4), that for the C172P there are four tank options:

  1. standard tanks 40gal
  2. long range tanks 50gal
  3. Integral tanks 62gal
  4. Integral tanks, partially (up to a mark) filled: 42gal.
    So one may assume that your C172P has integral tanks. And these are a little bit different to those of the C172R in that they start at WS23.65. This puts their CG near y= 44"

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 29, 2020

That would be about here then...
tank3

@dany93
Copy link
Collaborator

dany93 commented Jul 29, 2020

@okroth
Yes, I found it yesterday when trying to understand this.
BTW, thank you too for having searched and giving us all the details, calculated values. All the more that I never could find the Y location for the wing tanks.

What you are giving in your last message is for the 160 hp.
For the 180 hp, I only found total capacity 56 gal, usable 53 gal (p. 1-5, 2-11, 6-12).

The 2 x 129 lbs (43 gal) in the current FDM corresponds to the 160 hp standard tanks. (historical remaining)

Hence my response to @wlbragg

For the rest (main tanks) it's not so simple, I think I will appreciate your help, depending on the solution and options we choose.

We will have to make a choice for the 160 hp tanks.
Either 'Long Range' (2 x 27 = 54 gal), almost the same as the 180 hp. The easiest way, we can let a common value in the FDM for 160 and 180 hp, if we accept the approximation.
Or we propose the choice between the 3 possibilities for the 160 hp, and I will need the contribution from @wlbragg (I'm not very skilled at system files with switches etc...).
Or only integral tanks for the 160 hp, and we will also need a system file for the location and capacity for the 180 hp.

I think that the tank locations are not an issue. We can take @okroth's values
IMO, the Z value (59.4 in) can be let as it is.

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 29, 2020

This is the current setting unless we're changing it elsewhere that I don't know about.

<!-- Tank number 0 -->
        <tank type="FUEL">
            <location unit="IN">
                <x> 56 </x>
                <y> -112 </y>
                <z> 59.4 </z>
            </location>
            <capacity unit="LBS">129.43</capacity>
            <contents unit="LBS">100.0 </contents>
            <type>AVGAS</type>
        </tank>

        <!-- Tank number 1 -->
        <tank type="FUEL">
            <location unit="IN">
                <x> 56 </x>
                <y> 112 </y>
                <z> 59.4 </z>
            </location>
            <capacity unit="LBS">129.43</capacity>
            <contents unit="LBS">100.0 </contents>
            <type>AVGAS</type>
        </tank>

the Z value (59.4 in) can be let as it is.

Why do you think the Z is OK, shouldn't that be in the wing and not a few feet above it as it is now?

For the rest (main tanks) it's not so simple, I think I will appreciate your help, depending on the solution and options we choose.

I have no problem making a system file to manage the fuel tank change to engine change. I know I did it for the J3Cub/PA-18 switch, but that was one center tank to two wing tanks. I'll have to review how I did that and see if that is the approach needed here. I don't know off hand what properties are dynamically exposed for fuel tank location.

@wkitty42
Copy link
Contributor

it would seem to be more proper to be located in the wing, yes... especially if the FDM engine takes the location and weight into account... not to mention the raised CoG with the tanks being higher than the wing... how high off the ground is the center of the leading edge?

@okroth
Copy link
Author

okroth commented Jul 30, 2020

POH, page 6-10 gives a cabin height of 48", which is pretty much the distance from cabin floor to mid of wing height.

@wkitty42
Copy link
Contributor

that would work in with where is 0,0,0 and is there an offset that comes into affect... but that's more 3D detail stuff that i haven't picked up (yet)...

@dany93
Copy link
Collaborator

dany93 commented Jul 30, 2020

I was trying to make that clear once more. The axis locations are a nightmare in FG...

The Blender and FDM Z-axes are different.
The Blender Z axis is close to the propeller axis (Blender about 0.05 m higher than propeller). Easy to see in Blender.
The propeller axis is at Z = 26.6 inches in the FDM. Which makes the FDM Z-axis slighly below the aircraft belly.
The Blender and propeller axes are tilted by about 3°.

Looking at Blender and with these values, it makes about 50 inches between the aircraft belly and a tank close to the wing shaft. Hence, a bit more between the FDM Z-axis and the tank.

I think that Z = 59.4 inches (for the initial tanks, but also for the AERORP, line 31in the FDM) is at mid length of the wings. The wing shaft is a bit lower (dihedral angle). 50 to 55 inches for the tanks would be a good approximation.

Difficult to be accurate, but I think that the Blender Z-axis is higher than the FDM Z-axis by about 33 to 35 inches (40 ?) measured at the propeller X location.

@dany93
Copy link
Collaborator

dany93 commented Jul 30, 2020

c172-Blender-FDM-axes

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 30, 2020

@dany93 why then when we determine an animation and need the center coordinates can we take the numbers directly from blender without taking into account the model position z against the blender z? I have never dealt with this conversion as long as I have been doing this. Not on any aircraft. Not even the zposition of the wheels for WOW, all the gear change outs and the ground softness routines I programed.
My assumption was the model xyz translated to world xyz one to one?

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 30, 2020

@gilbertohasnofb @legoboyvdlp we could use some input here when you get a chance! I'd like some more input.

@dany93 I'll admit the original zpositions for the wheels are a bitch to tune, maybe that is why. If so then anyone that makes a model and doesn't position it with the wheels sitting on the Blender Z is a fool and are making nothing but trouble for all those that follow.

The propeller axis is at Z = 26.6 inches in the FDM. Which makes the FDM Z-axis slighly below the aircraft belly.

Why "belly" and not wheel bottom?

Dany, I'm not arguing with you, I'm only trying to understand this so please don't take any questioning the wrong way. I may have been working under false assumptions for awhile now or merely having a brain fart.

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 30, 2020

OK, stepped back and tried to grasp this, your propeller axis is key here 26.6".
But what about CG at 36.5, why are you using propeller axis for reference and not CG?
You got me totally confused. I desperately need a refresher course in FDM design, well actually I need a 101 course as I have never had any instruction.
Also AERORP and VRP how do they apply here if at all?

@okroth
Copy link
Author

okroth commented Jul 30, 2020

The propeller axis is fixed in the plane's coordinate system, CG not. Consume fuel and the z-coordinate of the CG goes down (slightly). CG position is only nice for the FDM as the forces from accelerations (gravitational included) refer to this. The z-coordinate of the empty-weight CG may actually be too high; the Cessna POHs show a location slightly below the propeller axis, whereas the C172P model puts it 10" higher than the prop.
Prop above CG creates a nose-down pitching moment being compensated by increased tail effectiveness (propwash), prop below CG would add prop-wash and nose-up pitching moment.
I did not find actual values for the z-coordinate of the CG, but I tend to put it near the prop axis, but I keep searching.

AERORP is the point where the forces of the main airfoil attack; usually 25% of the mean airfoil cord; here as well.
VRP is used to compute back from the CG coordinates the additional masses and torques from loads.

@okroth
Copy link
Author

okroth commented Jul 31, 2020

Found some data about CG positions in a report about three crash tests conducted at the NASA LaRC:
https://core.ac.uk/download/pdf/42700089.pdf
Vertical CG is 48"+/-2 inch above ground, with crash test dummies, measuring equipment and 75% simulated fuel.

@dany93
Copy link
Collaborator

dany93 commented Jul 31, 2020

@okroth wrote
VRP is used to compute back from the CG coordinates the additional masses and torques from loads.
I believed it was to make the 3D and FDM axes match? Only for the view.
http://wiki.flightgear.org/JSBSim_Aerodynamics#Metrics

@dany93
Copy link
Collaborator

dany93 commented Jul 31, 2020

@wlbragg
My mood is here #1327 (comment)
The axis locations are a nightmare in FG...
Don't worry, I do not take it the wrong way, and I would like being able to answer your questions. But I am almost as you, and you did many more animations than I did.

Why "belly" and not wheel bottom?

I don't know how it came.
The logical would be, in the 3D model (Blender) to locate the Z = 0 axis at the propeller level. Like X = 0 which is located at the manufacturer's DATUM, the best choice.

If I rememember well, I have determined this Z = 0 location mainly by deleting every contact and adding several new ones located at Z = 0. If the test contacts are hard enough to avoid a noticeable spring compression (but not too hard, which would prevent the JSBSim consergence), the aircraft sits on the ground at Z = 0 in the FDM (structural) frame.
I would like to redo this for confirmation, but it is a bit long to do.

However, I don't unserstand how it works in the code. The VRP (in the FDM) and offsets (Models/c172p.xml) are here to make the 3D model and the FDM match, but the values are not consistent with my observations (except maybe the 3 deg pitch).

@legoboyvdlp
Copy link
Member

@gilbertohasnofb @legoboyvdlp we could use some input here when you get a chance! I'd like some more input.
Really not sure here -- so there are different axises?

In any case moving the tanks on the x and y should be fine?

@okroth
Copy link
Author

okroth commented Jul 31, 2020

@dany93:
I meant, there are additional masses (pilot, baggage) defined in the vehicle coordinate system which need to be set in relation to the empty aircraft CoG. The 3D model is adjusted in the Models/c172p.xml.

@legoboyvdlp :
The x-position is given in the POH, so that's safe,
The y-position can be computed using the maintenance manual for the WS positions. That should be safe enough. It would not have that much effect if it is wrong by 2". It was wrong by nearly 80".

@wlbragg
Copy link
Collaborator

wlbragg commented Jul 31, 2020

OK, I defer the positions to the two of you to determine. I really dislike it when we have to get into these types of offsets. I am willing however to write any code we need to dynamically switch the load positions if necessary as soon as it is determined what direction to go.

So the Y axis should be a one to one match with Blender tank coordinates (even though there really is no modeled tank), X will be related to DATUM and Z will be related to prop axis.

I really wish I understood this well as I have two aircraft that have more complex fuel systems that are dynamic in nature. The AirCrane which is YASim has the position in the fdm as a 1to1 match with the Blender coordinates I believe. I have a feeling the J3Cub may be off as well.

@dany93
Copy link
Collaborator

dany93 commented Jul 31, 2020

@okroth wrote
Found some data about CG positions in a report about three crash tests conducted at the NASA LaRC:
https://core.ac.uk/download/pdf/42700089.pdf
Seems this video (C172 from 7 mn)

Your criteria
the Cessna POHs show a location slightly below the propeller axis
is much easier to apply.
And the aerodynamics justification that you give is clearly convincing.

@okroth
Copy link
Author

okroth commented Aug 1, 2020

The tests were made July 2015: This video : https://www.youtube.com/watch?v=FsRwlr7RDkk shows test #2.
I found some more report, and for test #3 I could compute a CG location of x=40.7" and z=34.0" when I subtracted the dummies, fuel simulation, and the data collecting equipment and added the rear bench at a eight of 1430lbs.
But that test specimen is (was) a C172M. A 127P or 172R could be slightly different.

@gilbertohasnofb
Copy link
Member

@gilbertohasnofb @legoboyvdlp we could use some input here when you get a chance! I'd like some more input.

Sorry team, I've been a bit busy these days. I just took a look at the whole discussion but I am not sure I would have any relevant input to give, FDM is one of those areas I am very uncomfortable with. But I'm happy to test and give feedback on any PRs, as well as review code and merge. Or did you have something more specific in mind @wlbragg?

@dany93
Copy link
Collaborator

dany93 commented Aug 1, 2020

I'm not far from being ready to propose commits.
For a few values, we still have to make decisions.

To summarize: (according to my current understanding)

  • Empty CG: Z = 26 or 34 inches?

  • Fuel tanks [0] and [1] (main tanks)
    160 hp and 180 hp
    X = 48 inches, Y = +/-44, Z = 50 to 55? (less than 59.4).
    For X, I've seen 46 inches (160 hp POH p.6.4, 180hp p.6.5).
    From 180 hp p.6-12 (moment), X = 48 inches seems more probable.

Capacities: (total for both wing tanks)
160 hp: 54 gallons (2 x 27)
180 hp: 56 gallons (2 x 28)
Can we approximate 160 and 180hp at 55 gallons? Otherwise, needs a system file.

Or farther but more complicated:
For the 160hp, choice between 3 capacities (total)
Standard: 43 gallons
Long Range: 54 gallons
Integral: 68 gallons
??

(My opinion is that's not worth the extra complication)

  • Fuel tanks [2] and (3] (feed tanks) would be at X = -10, Z = 26 (close to the engine)

@gilbertohasnofb
Copy link
Member

Can we approximate 160 and 180hp at 55 lbs? Otherwise, needs a system file.

I think the question is how perceptible the difference in the FDM would be. If we are talking of a barely perceptible difference, it might be worth to generalise the different engines using a single value as you propose.

@dany93
Copy link
Collaborator

dany93 commented Aug 7, 2020

I've tested your FUEL-TANK-OPTION branch.
Wonderful. The main features work well. Impressive coding work.

Now, I agree with Gross Weight and CoG with the 160hp engine, using Standard or Integral Tanks. X, Y, Z tank locations and capacities are OK.
(I had not tried the Integral tank config with 180hp, but I don't see why there would be a CoG issue).

The Integral tanks [2] and [3] do not feed the float chamber [4] (no consumption). After a few seconds, the engine stops "Out of fuel".
After looking at fuel.xml, I'd say that's because fdm/jsbsim/ fuel/tank does not change from 0 to 1 for "Integral tank".

One can change the amount of fuel for the non-active tanks, but I think that you know this (unfinished).

A small mistake: Integral left (and right) tank (not "Intergal").

@wlbragg
Copy link
Collaborator

wlbragg commented Aug 7, 2020

The Integral tanks [2] and [3] do not feed the float chamber [4]

Corrected the feed and the Integral typo. Added the new tanks to the fuel gauges.
See:https://github.com/c172p-team/c172p/tree/FUEL-TANK-OPTION

TODO:
Identify all other areas the fuel system touches. fuel contamination, etc.
Identify persistence feature of tank selection (when is it to be persistent?)
Limit Fuel and Payload dialog fuel controls to selected configuration only.
Test, when complete transfer work from test branch to #1328

I just learned something really interesting. I had a backup of the original aircraft-dialog.xml named aircraft-dialogORG.xml in my local dialog folder and FG pick up the one with the ORG appended on the end. It was the last one in the folder alphabetically. So I wasn't getting the tank selection in the GUI, talk about weird.
There were three files total.
aircraft-dialog.xml
aircraft-dialogMULTI.xml
aircraft-dialogORG.xml
and FlightGear settled on the last one even though I specifically called for aircraft-dialog.xml, that'll make you scratch your head!

@wlbragg
Copy link
Collaborator

wlbragg commented Aug 7, 2020

@legoboyvdlp @gilbertohasnofb @dany93 @wkitty42 @okroth

I've been working out of the test branch because I wasn't sure if this was going to come to fruition. Are we far enough into this to finish it and add a fuel tank option to the c172p? Is everyone convinced and ok with this? If so I will start adding the conversion into the PR @dany93 created, with logical git commit progressions and then when we get it all verified and we tie up any loose ends we can merge. Everyone onboard?

@dany93
Copy link
Collaborator

dany93 commented Aug 8, 2020

Checked your last commits, nothing to say at first tests, its' working fine.

About the fuel tank options, I'm not rigid.

Adding the integral tanks on the 180 hp is a code compromise, acceptable even if we have no mention of it on the real one. Useless to say that I'm more focused on the FDM and as much as possible a correct flight behavior (at least from my point of view...). Even if the integral tanks do no appear in the180 hp 552SP POH, some 160 hp owners with initially integral tanks might have fitted it with a 180 hp engine. Waiting for better informed opinions...

The other compromise would be a single 55 (2 x 27.5) gallons configuration (intermediate between 160hp "Long range" 54 gallons and 180 hp 56 gallons). But after the amount of work that you did, that would be a pity.

@wlbragg, another thing: if you (we) decide for the multiple tanks configuration, I'm wondering if the best, the more logical, wouldn't be to include my changes into your branch (which is already done) and merge your branch. You did (are still doing) at least 99% of the coding work.

@wlbragg
Copy link
Collaborator

wlbragg commented Aug 9, 2020

@dany93 I did a little searching and found an article about an Alaska club who talked about upgrading the 160 hp with long range tanks to a 180. I would think some one has upgraded the 160 integral to a 180. I'm OK offering the integral tanks on both engine configurations and let it go at that.

Another option if we want to remain pure in what we have verified is to limit the integral tanks to 50, 55 or the default 56 gal that is supposedly in the 180 POH when the 180 engine is selected. I can code it so you can't add more than the 56 gal amount when in the 180 + integral tank configuration. It would still show Integral 68 gal capacity but only allow 56 max gal. Not my first choice though.
I am completely comfortable allowing the entire 68 gal Integral on both engine configuration. Like I said, I'm OK assuming it's been done. Or at the least, could be done!

wouldn't be to include my changes into your branch (which is already done) and merge your branch. You did (are still doing) at least 99% of the coding work.

Well, I actually have a little more in that branch than just the fuel stuff and the commit history doesn't really show it. So I think I would still rather add commits to your PR branch. I do want to add the other unrelated stuff that's in my branch to master, but I think it need to go in it's own issue and PR as well. It has some fairly extensive -set file refactoring.
We also have the KAP140 Issue #1302 work to be merged. We may need to just merge it as is and find out later if it is completely sound by letting the masses test it as we don't currently have enough manpower to adequately test it.

So, I am going to go on under the assumption we are good with it in the current configuration of tank selections and I will over the next few days get it all committed in a descriptive way. I will do another issue and PR for the -set file work I have and I will review the KAP140 PR and finish up any loose ends on it and ask for a merge of it as well.
Maybe will all that complete and @legoboyvdlp tutorial reset merge we can set a new version and get a request to the dev list to get it in ??? release.

@gilbertohasnofb
Copy link
Member

Maybe will all that complete and @legoboyvdlp tutorial reset merge we can set a new version and get a request to the dev list to get it in ??? release.

Sounds good, it's been a while since we last did a release. We could also take a look at fixing some other bugs too, I flagged a couple that could be addressed.

@dany93
Copy link
Collaborator

dany93 commented Aug 10, 2020

@wlbragg wrote

found an article about an Alaska club who talked about upgrading the 160 hp with long range tanks to a 180. I would think some one has upgraded the 160 integral to a 180

it's a proof (at least a clue) that, technically, it can be done. That the 160 hp structure can sustain a 180 hp upgrade.

@okroth
Copy link
Author

okroth commented Aug 10, 2020

For the 172R exists a Cessna documentation MK172-72-01C that explains how to upgrade from 160HP to 180HP. However, the engine stays the same IOC360L2A, it just gets a new propeller, engine instruments, etc. The higher power rating comes from higher RPM allowed (2700 instead 2500)

@dany93
Copy link
Collaborator

dany93 commented Aug 10, 2020

@okroth wrote

However, the engine stays the same IOC360L2A

If I understand well, the IOC360L2A engine is from the IO360 family, already a 180 hp engine.

@okroth
Copy link
Author

okroth commented Aug 10, 2020

Correct. But rated at 160 hp in the standard configuration with 2500 rpm limitation

@wlbragg
Copy link
Collaborator

wlbragg commented Aug 16, 2020

@dany93 @gilbertohasnofb @legoboyvdlp
I pushed what I have to Dany's PR. I really didn't want to add the variant work to this PR, I was going to make a separate issue for it but it was to deeply embedded in my code to do it separated out. The variant stuff isn't really that much or complicated. I simply cleaned it up so we aren't duplicating all the descriptions and c172p-main.xml held the information that needed to be consolidated.
Please test the fuel tank options.
Left TODO:
Identify all other areas the fuel system touches. fuel contamination, etc.
Identify persistence feature of tank selection (when is it to be persistent?)
Limit Fuel and Payload dialog fuel controls to selected configuration only.

@wlbragg
Copy link
Collaborator

wlbragg commented Aug 16, 2020

Note to myself:
Autostart, logic to select appropriate tanks.
Fuel Save State and Contamination in c172p.nas

@dany93
Copy link
Collaborator

dany93 commented Aug 17, 2020

@wlbragg
Tested.
Fuel tank options: work,
"Limit Fuel and Payload dialog fuel controls to selected configuration only" : works.
Respective fuel consumption vs selected tank option: works.

@wlbragg
Copy link
Collaborator

wlbragg commented Sep 11, 2020

@gilbertohasnofb @dany93
I have a couple question,.

  1. Autostart originally set the default tanks to 10 us gal each but there is a function that is always called at startup that sets them to 20 us gal each if the save fuel state is NOT selected. Is there a reason for this discrepancy?
    Note: default tanks max capacity 43 us gal so autostart sets total us gal to 20 and startup sets it to 40 us gal unless save fuel state is selected in which case it would be whatever was left on last sim exit.
    I'm also needing to know this to set the integral tanks accordingly when selected.

For simplicity sake and to eliminate and extra function I would like to have autostart and the default startup fuel load be the same, Is that OK and how much fuel should be onboard for each configuration, default tanks and integral tanks?

  1. Is this the way we want the tanks to be set on startup anyway, with a preset amount of fuel vs empty? Was this maybe done becasue we have a choice to introduce the possibility of water in the fuel and thus fuel in the tank is necessary?

  2. There is a property being set in autostart

# Checking for minimal fuel level
    var fuel_level_left  = getprop("/consumables/fuel/tank[0]/level-norm");
    var fuel_level_right = getprop("/consumables/fuel/tank[1]/level-norm");

    if (fuel_level_left < 0.25)
        setprop("/consumables/fuel/tank[0]/level-norm", 0.25);
    if (fuel_level_right < 0.25)
        setprop("/consumables/fuel/tank[1]/level-norm", 0.25);

I did a find-in-files and there is no other reference to these properties anywhere else in the entire c172p project files, what is this /consumables/fuel/tank[x/level-norm?

@wlbragg
Copy link
Collaborator

wlbragg commented Sep 11, 2020

Note: this PR is introducing a fairly aggressive refactoring of the variants and I really need to get this finished and pushed before we can even consider introducing #1335.

This is really close to being finished as soon as I can get the above questions resolved.

Notes to myself, check preflight tutorial and limit fuel contamination check to default tanks.

@gilbertohasnofb
Copy link
Member

  1. I think that's a bug. Both the startup function as well as autostart should set the fuel to a certain fixed level if save state is not on AND if the fuel is below that level (above is fine, of course); this is there to make sure the aircraft turn on either manually or via autostart, but the level should be the same. The discrepancy is probably there because it was implemented at different points or by different people. Could you please ensure that both use 20 gal as the default fuel level when save state is not on?

  2. Aircraft are normally kept with fuel in so there is no need for an option to start with empty fuel IMO. In RL, this only happens if you either land with nearly no fuel in or if you removed the fuel from the tanks manually for a checkup. Both things can be done in the sim since you can open the dialog and lower the fuel level to 0.0. So IMO nothing should be done here.

  3. Isn't that just the fuel quantity property?

@wlbragg
Copy link
Collaborator

wlbragg commented Sep 11, 2020

Isn't that just the fuel quantity property?

I don't know, my point is /consumables/fuel/tank[1]/level-norm is set to .25 in these four lines of code and never used again anywhere else in the aircraft code, anywhere.

After investigating farther, I assume it is a tied property and if you adjust /consumables/fuel/tank[2]/level-gal_us then /consumables/fuel/tank[1]/level-norm is adjusted as well.

If you adjust /consumables/fuel/tank[1]/level-norm then /consumables/fuel/tank[2]/level-gal_us is adjusted.

They are tied together with level-gal_us being the one measure and level-norm being a percentage from 0 to 1.
So all we are doing in autostart is to set the fuel level twice using two different properties, has to be a bug?

In fact in c172p.nas we essentially we're setting it three times, ie:

Once on startup, total 40 gal, 20 gal in each tank times 2.
Then something a bit different on autostart, 10 gal.
Then again farther down in the autostart. we set it to .25 of a full tank.

So, I think I can safely use the .25 (level-norm method). Once on startup and again on autostart. I can then use or call just one function that sets the fuel level for either on startup or on autostart.

@gilbertohasnofb
Copy link
Member

I think the level-norm property is the normalised fuel, all others are the converted level-norm into units such as gallons, litres, etc. I think this is the reason I used level-norm, the others should be used as read-only if I am not mistaken (it's been ages since I wrote that code).

So, I think I can safely use the .25 (level-norm method). Once on startup and again on autostart. I can then use or call just one function that sets the fuel level for either on startup or on autostart.

Sounds good to me.

@wlbragg
Copy link
Collaborator

wlbragg commented Sep 11, 2020

I think the level-norm property is the normalised fuel, all others are the converted level-norm into units such as gallons, litres, etc. I think this is the reason I used level-norm, the others should be used as read-only if I am not mistaken

Yeah, I agree.

Also, I noticed the level-norm method checked to see if there was less than .25 (a quarter tank) and only then would it make it change the volume to quarter tank on autostart. So if the fuel was set to anything more than a quarter when autostart was executed, then autostart didn't adjust the fuel.
I'm going to leave that logic in place. In other words I am going to use that logic VS setting it regardless of what is already in the tank. It will be done that way at sim startup as well.
So in essence., the only time it won't touch the fuel amount is if the tank has over .25 percent of fuel or the "save-state-of-aircraft" is selected.

@gilbertohasnofb
Copy link
Member

So in essence., the only time it won't touch the fuel amount is if the tank has over .25 percent of fuel or the "save-state-of-aircraft" is selected.

I think the autostart logic is fine, but applying the same thing to the aircraft when the sim starts regardless of save state is wrong IMO. I think we should only override the amount of fuel at the start of the sim if save state is off and if the fuel level is below 0.25. The idea behind these two is: beginners or people who just want to fly will always have a working autostart or always have a minimum amount of fuel for manual start; people who want a realistic simulation will need to refuel their aircraft from time to time. So autostart not considering save states is fine (autostart is not realistic anyway), but the startup function must consider it.

@wlbragg
Copy link
Collaborator

wlbragg commented Sep 11, 2020

I think we should only override the amount of fuel at the start of the sim if save state is off and if the fuel level is below 0.25.

Right, I must have said that poorly, that is indeed my conclusion.

At startup...
If saved state is active, nothing will be done.
If it isn't active, it will check that there is at least .25 percent fuel onboard, if not it will set it to .25.
I think where i confused you is if it is over .25 without save state checked, it wont reduce the fuel to .25. It willl simply leave it alone.
That is kind of how it was originally using the level norm method. The other methods were interfering with that and setting it regardless.
Sound right?
Or do you think if saved state is off and there is over.25 percent fuel onboard we should reduce it to .25?

@gilbertohasnofb
Copy link
Member

Sound right?

Yes, I think we are on the same page now, I indeed had misunderstood you. This all sounds like a reasonable approach to it.

Or do you think if saved state is off and there is over.25 percent fuel onboard we should reduce it to .25?

No, I'd never reduce it, we are just ensuring the newbie pilot won't crash out of gas within 2 minutes of take off 😄

@wlbragg
Copy link
Collaborator

wlbragg commented Sep 11, 2020

List of items to check!

  1. Fuel tank options: work,
  2. "Limit Fuel and Payload dialog fuel controls to selected configuration only" : works.
  3. Respective fuel consumption vs selected tank option: works.
    The above were tested by @dany93 and may need to be verified again right before merge
  4. Fuel tanks configured correctly at startup, dependent upon tanks selected with save state on
  5. Fuel tanks configured correctly at startup, dependent upon tanks selected with save state off
  6. Fuel tanks configured correctly upon autostart, dependent upon tanks selected
  7. Test fuel cap on wing logic (click on fuel caps on wings), dependent upon tanks selected
  8. Check cockpit fuel tank selection knob works correctly, dependent upon tanks selected
  9. Checklist - verify fuel selector works during checklist
  10. Preflight tutorial fuel tank selector works, tutorial should defaults to standard tanks
  11. State Manager "On approach" fuel selector working correctly, fuel tanks are selected and configured correctly, dependent upon tanks selected
  12. Water contamination test works correctly regardless of tanks selected. I think using contamination properties of 0 and 1 works with tanks 2 and 3 becasue the only check on the tanks are that they have enough fuel in them. I was able to condition on whether or not 0/1 OR 2/3 had enough fuel to test. The rest of the test logic just uses references to tank 0 and 1 but because it is pseudo logic it works, it doesn't have to actually be tied to tanks 2 and 3, please verify.
  13. Save/Resume works regardless of tank configuration
  14. Flight Recorder works correctly regardless of tank configuration

@gilbertohasnofb @dany93 this is done as far as I can tell. The fuel tank portion touched a bunch of areas.

The variant refactoring also needs to be checked, Basically all variant set files should be relatively short and all tie to c172p-main.xml where the details are and the main setup of the aircraft occurs.

@dany93
Copy link
Collaborator

dany93 commented Sep 12, 2020

A few small typos, to be changed for "Integral".
c172p-main.xml lines 711 and 717
(appears in "Fuel and Payload" window)

            <tank n="2">
                <name>Intergal Left Tank</name>
                (skip)
            <tank n="3">
                <name>Intergal Right Tank</name>

Fuel.xml, line14
<!-- Main tanks: 0 and 1, Intergal 2 and 3

@wlbragg
Copy link
Collaborator

wlbragg commented Sep 12, 2020

Done, thanks @dany93

@wlbragg
Copy link
Collaborator

wlbragg commented Oct 3, 2020

@dany93 thanks!

@dany93
Copy link
Collaborator

dany93 commented Oct 5, 2020

@wlbragg, thanks for this work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants