Board index FlightGear Support Flying

Default Cessna fuel weirdness, stuck at 9 pounds of fuel.

Controlling your aircraft, using the autopilot etc.

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby TheEagle » Fri Oct 28, 2022 4:33 pm

That
property_tree wrote in Fri Oct 28, 2022 3:47 pm:
Code: Select all
246.92 [INFO]:nasal      1.5
246.92 [INFO]:nasal      1.500000000000001


is a well-known phenomenon - see https://stackoverflow.com/questions/588 ... ath-broken ! :) To fix this, you can do
Code: Select all
round(getprop("/whatever"), 1);
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3433
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby property_tree » Fri Oct 28, 2022 4:41 pm

Ah, thank you, I was not aware of that function for nasal.
However, it seem that in the actual source code, there is some rubberbanding for fuel values, so, right now I am checking out those.

Also, where can I find the nasal API, so to speak?
The wiki only has tutorials...but you seem to know an actual body of functions provided by the system.
property_tree
 
Posts: 98
Joined: Wed Oct 26, 2022 1:13 pm

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wkitty42 » Fri Oct 28, 2022 4:42 pm

when all is said and done, it would be a good idea to report this as an issue on the c172p's development github...
https://github.com/c172p-team/c172p
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9165
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 22.04

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 4:52 pm

If you wouldn't mind, we have a development project for the c172p at GitHub, You can create an issue report and we can help diagnose and fix the issue. I was probably the last one to touch the fuel system, I didn't create it but I did participate in creating and programming the different fuel tank options. It's very possible I mucked something up. However the floating point theory seems viable as well. I'm pretty sure we have a math operation to address stuff like that that.. I would need to apply it to the calculation and see if it fixes your problem. I am curious if this is for some reason a hardware specific issue? I say that as I find if interesting it hasn't been reported before. If anyone following this thread can reproduce this it would also be helpful.
I'll take a look on my system and see if I can reproduce it. I am on the tail end of a covid infection, "lucky me", I made it a couple years without getting it and my luck finally ran out. So my involvement might be limited until I get feeling better.

@wkitty42 I tired to post and you beat me to it.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby property_tree » Fri Oct 28, 2022 4:54 pm

Thanks for pointing me to the proper place, in fact...I had asking about this 'being moved' at the back of my mind, but I'll go to the proper tracker.
property_tree
 
Posts: 98
Joined: Wed Oct 26, 2022 1:13 pm

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby TheEagle » Fri Oct 28, 2022 4:55 pm

Yes, there is an API documentation for the global functions including small examples: https://wiki.flightgear.org/Nasal_library
If you scroll down to the end of the page, there are links to the API docs for a few Nasal "standard library" modules ! :)

@wlbragg: sorry to hear this … I hope you will get better soon ! :)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3433
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 4:59 pm

A couple questions, you may have already answered, if so please indulge me.

What happens when you drive the fuel down under the 9 lbs, will it run out then?
What happens when you try to start it under 9 lbs?
Does selecting only one tank make a difference?
Does shutting off the fuel flow make a difference?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby property_tree » Fri Oct 28, 2022 5:09 pm

Sweet, thanks for linking the library, TheEagle.

And oh, right. Well first, good health to you, wlbragg, but I have also failed to answer your question.

It could very well be a system specific bug, but I think Polly was able to confirm this, too, but perhaps in a different way (cause I think the propeller on my installation just keeps going).

Anyway, I have added some std::couts to drain and fill in fgtank.cpp and
Code: Select all
double FGTank::Calculate(double dt, double TAT_C)
{
  if(ExternalFlow < 0.) Drain( -ExternalFlow *dt);
  else Fill(ExternalFlow * dt);

  if (Temperature == -9999.0) return 0.0;
  double HeatCapacity = 900.0;        // Joules/lbm/C
  double TempFlowFactor = 1.115;      // Watts/sqft/C
  double Tdiff = TAT_C - Temperature;
  double dTemp = 0.0;                 // Temp change due to one surface
  if (fabs(Tdiff) > 0.1 && Contents > 0.01) {
    dTemp = (TempFlowFactor * Area * Tdiff * dt) / (Contents * HeatCapacity);
  }

  return Temperature += (dTemp + dTemp);    // For now, assume upper/lower the same
}

Is a bit confusing to me since it keeps on calling Fill a lot...but again, I don't want to drag this out any further, I'll write something up for Git later. I'm feeling a bit run down myself, to be honest.

But for the further questions I am seeing now:
>What happens when you drive the fuel down under the 9 lbs, will it run out then?
If I drag it under the threshold, it chokes out after a little bit...not immediately so maybe there's a bit of give between nasal and the cpp code -shrug-
And at the moment all my tests are with the modified nasal script the one that checks against the unusable instead of 0.
>What happens when you try to start it under 9 lbs?
"out of fuel" (but with my edited nasal script)
>Does selecting only one tank make a difference?
A single tank over the threshold starts the plane successfully
>Does shutting off the fuel flow make a difference?
If you mean fuel mixture? then yes. It chokes out.
If you mean pulling the throttle to 0? then yes, it chokes out.
In fact, it chokes at 5% or so (I just pulled it out awkwardly in one stuttery go and it seemed to have started to choke above zero but definetely then died at 0)

----
A quick re-run with the origina script:
It starts up just fine under 9 pounds but...oh it died now.
Weird.

It does not start up again, but also does not 'print' on the gui that the fuel's gone either.

If I drag even one tank up again over 9 pounds it starts again, even if I drag it down afterwards.

If I drag it down afterwards then it will run for ~10 seconds and then die.
Might be 6 seconds, really.

In other words, original script:
start above 9 pounds? in either tank? starts up.
drag it below 9 pounds while it's running: it runs a bit, then chokes out.
try to start it after a chokeout from being below 9 pounds: it won't start (but also won't print that it's out of fuel)
drag the fuel back over 9 pounds after the chokeout, it will start, even if one drags the slider down below 9 pounds.
The simple act of going above 9 pounds reinvigorates the system and gives it a bit of life that makes the engine run for ~10 seconds if one drags it underneath 'usable fuel levels' of 9 pounds.

But I cannot 'naturally' drain the plane during flight, unless time multiplication is on really high like 32x ...which again I assume makes the timestep so dramatic that it 'bites off' enough from the value to trigger it.
property_tree
 
Posts: 98
Joined: Wed Oct 26, 2022 1:13 pm

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 5:25 pm

Does shutting off the fuel flow make a difference?

If you mean fuel mixture? then yes. It chokes out.


I meant with the fuel selector.

Also is there a difference in behavior between the standard tanks and the integral tanks?

I just tested the latest development branch/release and so far with the integral tanks, they test ok, no issues. As soon as both tanks hit 9 gal, rpm's dropped and eventually I fall out of the sky. I also tried it with integral tanks, left tank with some fuel and right tank empty. As soon as the left tank hit 9, the engine stops working.

However with the default tanks, there does appear to be a problem. I'm at 9 in each tank and it's still going strong.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 5:30 pm

It's because there is a float bowl that fills with gas and takes a few seconds to consume it.

Everything is working per spec except the default tanks in my installation and the way it is acting I think it may be a floating point issue. I'll see if I can verify it and fix it in the fuel code.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby TheEagle » Fri Oct 28, 2022 6:00 pm

@property_tree there's no point in doing anything to the Nasal script - all that is done there is to show a popup when the fuel level reaches 0.
The JSB fuel system looks fine to me ! :?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3433
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 6:45 pm

I posted an issue on the development repository as in needs to be fixed there at any rate.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 6:59 pm

Code: Select all
    #this block should be moved out of nasal and into jsbsim or autopilot logic
    var leftTankUsable  = 0;
    var rightTankUsable = 0;
    if (getprop("/consumables/fuel/tank[0]/selected") and getprop("/consumables/fuel/tank[0]/level-gal_us") > 0) leftTankUsable  = 1;
    if (getprop("/consumables/fuel/tank[1]/selected") and getprop("/consumables/fuel/tank[1]/level-gal_us") > 0) rightTankUsable = 1;
    if (getprop("/consumables/fuel/tank[2]/selected") and getprop("/consumables/fuel/tank[2]/level-gal_us") > 0) leftTankUsable  = 1;
    if (getprop("/consumables/fuel/tank[3]/selected") and getprop("/consumables/fuel/tank[3]/level-gal_us") > 0) rightTankUsable = 1;
    var outOfFuel = !(leftTankUsable or rightTankUsable);


Yet, the nasal check is against zero, which would always evaluate to true since the Cessna due to the source code cannot suck the entire tank dry.

Thus, a check against the unusable amount in the nasal code will probably fix this, but I don't know how ^^ lol cause I am not familiar with the properties system enough.


I don't think so. While this is something we might need to address, I think it is only driving a user information prompt. But I agree it might need to be change in that context to address the unusable fuel in the tank. I'll have to look closer at the logic.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 7:20 pm

I realized I just repeated what TheEagle already said. That section of logic isn't the issue.

Code: Select all
246.92 [INFO]:nasal      1.5
246.92 [INFO]:nasal      1.500000000000001


This appears to be it. But why does this not work...

Code: Select all
 <!-- from Tank 0 (to Collector Tank 4) -->
        <fcs_function name="propulsion/tank[0]/contents-volume-gal">
            <function>
                <quotient>
                    <p> propulsion/tank[0]/contents-lbs </p>
                    <p> propulsion/tank[0]/density-lbs_per_gal </p>
                </quotient>
            </function>
        </fcs_function>
        <switch name="fuel/from-tank0-to-tank4">
            <default value="0"/>
            <test logic="AND" value="0.1">
                propulsion/tank[0]/priority EQ 1
                propulsion/tank[0]/contents-volume-gal GT propulsion/tank[0]/unusable-volume-gal
                /consumables/fuel/tank[4]/level-lbs LT 0.05
                propulsion/tank[4]/priority EQ 1
                accelerations/Nz GE 0
                fuel/tank EQ 0
            </test>
        </switch>


Yet this does work...

Code: Select all
<!-- from Tank 2 (to Collector Tank 4) -->
        <fcs_function name="propulsion/tank[2]/contents-volume-gal">
            <function>
                <quotient>
                    <p> propulsion/tank[2]/contents-lbs </p>
                    <p> propulsion/tank[2]/density-lbs_per_gal </p>
                </quotient>
            </function>
        </fcs_function>
        <switch name="fuel/from-tank2-to-tank4">
            <default value="0"/>
            <test logic="AND" value="0.1">
                propulsion/tank[2]/priority EQ 1
                propulsion/tank[2]/contents-volume-gal GT propulsion/tank[2]/unusable-volume-gal
                /consumables/fuel/tank[4]/level-lbs LT 0.05
                propulsion/tank[4]/priority EQ 1
                accelerations/Nz GE 0
                fuel/tank EQ 1
            </test>
        </switch>


This is the section of code that is driving the fuel to the float bowl. The first block is tank 1 of the default tanks that is not working.
The second block is tank 1 of the integral tanks which does work.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Default Cessna fuel weirdness, stuck at 9 pounds of fuel

Postby wlbragg » Fri Oct 28, 2022 7:50 pm

What appears to be a quick fix is to change the following consumable values in c172p-main.xml (starting at line 675). The question is, does this just put off the situation. My first thought is this may need to be reported to the jsbsim folks and addressed there.

Code: Select all
    <consumables>
        <fuel>
            <tank n="0">
                <name>Left Tank</name>
                <level-gal_us type="double">0</level-gal_us>
                <selected type="bool">false</selected>
                <water-contamination type="double">0.0</water-contamination>
                <sample-water-contamination type="double">0.0</sample-water-contamination>
                <fuel-sample-taken type="bool">false</fuel-sample-taken>
                <unusable-gal_us type="double">1.49</unusable-gal_us>
            </tank>
            <tank n="1">
                <name>Right Tank</name>
                <level-gal_us type="double">0</level-gal_us>
                <selected type="bool">false</selected>
                <water-contamination type="double">0.0</water-contamination>
                <sample-water-contamination type="double">0.0</sample-water-contamination>
                <fuel-sample-taken type="bool">false</fuel-sample-taken>
                <unusable-gal_us type="double">1.49</unusable-gal_us>
            </tank>

            <tank n="2">
                <name>Integral Left Tank</name>
                <level-gal_us type="double">0</level-gal_us>
                <selected type="bool">false</selected>
                <unusable-gal_us type="double">1.49</unusable-gal_us>
            </tank>
            <tank n="3">
                <name>Integral Right Tank</name>
                <level-gal_us type="double">0</level-gal_us>
                <selected type="bool">false</selected>
                <unusable-gal_us type="double">1.49</unusable-gal_us>
            </tank>
            <tank n="4">
                <name>Float Chamber</name>
                <capacity unit="LBS"> 0.1 </capacity>
                <selected type="bool">true</selected>
                <hidden type="bool">true</hidden>
            </tank>
            <contamination_allowed type="bool">false</contamination_allowed>
        </fuel>
    </consumables>
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7610
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

PreviousNext

Return to Flying

Who is online

Users browsing this forum: No registered users and 4 guests