c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
82 stars 43 forks source link

CG of wing tanks too far outboard #1327

Closed okroth closed 4 years ago

okroth commented 4 years ago

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.

wlbragg commented 4 years ago

A very brief look indicates you can't change these dynamically. It's multiple tank configurations or not at all.

wlbragg commented 4 years ago

I really don't want to proceed any farther unless there is a consensus to take this approach. If we decide not to do this then were done and I merge.

wlbragg commented 4 years ago

Notice that consumables/fuel/tank/level-gal-us and consumables/fuel/tank/unusable-gal_us are set in c172p-set.xml (lines 690 to 708)

consumables/fuel/tank/level-gal-us is only the amount of fuel in the tank. That number can dynamically change up to the capacity of the tank but not beyond. The capacity is set in the c172p.xml line 631 and an initial starting value on the next line.

dany93 commented 4 years ago

@wlbragg wrote

I'm concerned you appeared to have calculated CoG 39.98. The 41.02 I got is what FG calculated.

Tanks-160hp-CoG

dany93 commented 4 years ago

@wlbragg wrote

@dany93 can you find where these are originated or created? /fdm/jsbsim/propulsion/tank[0]/contents-lbs /fdm/jsbsim/propulsion/tank[0]/unusable-volume-gal /fdm/jsbsim/propulsion/tank[0]/density-lbs_per_gal

/fdm/jsbsim/propulsion/tank[0]/contents-lbs is set in the FDM (line 632, value = 100 lbs). It is also set in c172p-set .xml, line 693, but at 20 US Gallons: <level-gal_us type="double">20</level-gal_us> 20 (gallon) x 6.02 (lb/gallon)= 120.4 lb, which is the value displayed in Fuel and Payload. This is the current, dynamic content (amount of fuel). We can see that the value in c172p-set.xml takes priority on the FDM. Giving these values in c172p-set.xml is necessary to have the tanks listed in Fuel and Payload in the simulator.

Oh, I think the later group are suppose to be

/fdm/jsbsim/propulsion/tank[0]/contents-lbs
/fdm/jsbsim/propulsion/tank[0]/contents-volume-gal
/fdm/jsbsim/propulsion/tank[0]/unusable-volume-gal

Yes, sorry (corrected in my post).


/fdm/jsbsim/propulsion/tank[0]/unusable-volume-gal If I understand well (and you are way better than me on this), this property has been introduced in JSBSim, to connect JSBSim and FlightGear (unusable-gal_us) values. https://sourceforge.net/p/flightgear/mailman/message/36505193/ see

+      prop = node->getNode( "unusable-gal_us", true );
+  property_name = base_property_name + "/unusable-volume-gal";

/fdm/jsbsim/propulsion/tank[0]/density-lbs_per_gal See JSBSim Fuel System It can be given as <density unit="{KG/L | LBS/GAL}"> {number} </density> or (like in the c172p.xml) <type>AVGAS</type> In this case, the Fuel Densities (lb/gallon) table is used. 6.02 for AVGAS.

As you can guess, I have not a good knowledge of this, I just searched to respond to your questions, hoping it helps as it is. Please, be critical.

wlbragg commented 4 years ago

I think your correct in all the sources. I traced a couple in question since I last posted. But the bottom line is you can't dynamically change the tank size once it is set. The only other option is make one tank to the max size (integral) /2 and then limit the max fill amount to the chosen tank size. Personally I like the multi tank setup better as you have the Fuel and Payload GUI supporting it depending on your selection. You can even dynamically adjust the fuel and payload GUI to hide the selections your not using, but that is more work and not necessary. I think we need some other opinions as to whether to proceed or not. If this were my aircraft exclusively, I think I would offer the choice because they are actually used in some rigs. Same as we offer the rudder trim or the digital clock, gps, etc. 43 gal to 68 gal is 25 gal, that is a huge difference and effectively changes the range of the aircraft. Not a small thing.

dany93 commented 4 years ago

To make thing much less complicated (hopefully), would it be possible to just have

@wlbragg wrote

But the bottom line is you can't dynamically change the tank size once it is set.

In this case, this is an issue...

wlbragg commented 4 years ago

That makes as much sense as anything. My only question would be that the 160 comes with integral tanks? I think you still are going to see both tank selections in the fuel and payload. If that is the case why not make the 2 choices available to both?

wlbragg commented 4 years ago

I agree the long range is not necessary if we do a Integral.

wlbragg commented 4 years ago

Integral tanks would change the weight load on the wings quit a bit, yes? Would it also change the Y axis of the load? I suppose with the same weigh tin each side it mitigates that substantially, but the overall weight of extra 25 gal is substantial as well on the X axis.

dany93 commented 4 years ago

but the overall weight of extra 25 gal is substantial as well on the X axis.

@dany93 wrote

160 hp

  • Standard: 2 x 129.43 lbs x 2 (2 x 21.5 gal), 1906 lbs, CoG 39.98 in
  • Integral: 2 x 204 lbs (2 x 34 gal), 2055 lbs, CoG 40.57 in (very close, slightly greater than POH limit 40.5 ! ).
wlbragg commented 4 years ago

I'm looking at J3Cub implementation. There is quite a bit of logic involved to effectively handle two tank configurations. Add to it the sampling, gravity and what else, it gets complicated in a hurry. I was going to push what i had to a different branch so you could test it and mess around with it. But I wanted to add the GUI selection and polish the limiting and canceling of selections in Fuel and Payload first. Once I started I realized the complexity. It's not insurmountable, but is extensive.

dany93 commented 4 years ago

Integral tanks would change the weight load on the wings quit a bit, yes?

Yes, but as the load is closer to the center of lift action for each corresponding wing, it is no so hard for the structure (moment at the wing shaft) as if the fuel load were in the fuselage.

Would it also change the Y axis of the load?

The Y component of the load force? Negligible, IMO.Theoretically, the load force is in the XZ plane at rest and at coordinated flight. The Y location shift (if there is with content) of the vertical force is defined by the shape of the tank. It should not change much.

wlbragg commented 4 years ago

@dany93 @gilbertohasnofb @legoboyvdlp I pushed a branch for testing that incorporates @dany93 changes and the addition of a second fuel tank selection. It's not complete and it has other work, issue #1325, that I forgot I had been working on. So don't mix this with anything else, it is just for testing.

wlbragg commented 4 years ago

@dany93 any discrepancy we had on the COG is because I was working on multiple tank selection without incorporating your change to the CG and tank positions. In the temporary test branch https://github.com/c172p-team/c172p/tree/FUEL-TANK-OPTION I incorporated your changes here.

dany93 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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

wlbragg commented 4 years ago

@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 commented 4 years ago

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

dany93 commented 4 years ago

@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 commented 4 years ago

@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?

2) 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?

3) 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 commented 4 years ago

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 commented 4 years ago
  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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 :smile:

wlbragg commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Done, thanks @dany93

wlbragg commented 4 years ago

@dany93 thanks!

dany93 commented 4 years ago

@wlbragg, thanks for this work!