c172p-team / c172p

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

Implement oil level management #499

Closed gilbertohasnofb closed 8 years ago

gilbertohasnofb commented 8 years ago

Implement oil level management (splitting issue from #303, which is getting too large already)

@Juanvvc wrote:

You must check the oil level always, and refill about once out of ten flights. I don't know if flighgear implements engine failures if the oil lever is too low, or they must be simulated by the aircraft.

@tigert wrote:

Oil amount is usually measured in "quarts" (imperial unit pretty close to a liter), minimum 6 in that engine I think (depends on engine size, so the 180hp might have a bigger oil sump, need to verify from the handbook). If you plan for a longer cross country trip, you want to up it close to 8, since the lycoming engine does eat something like a quart in every 10 hours. For this reason you have a bottle or two in the trunk, and if it is much below 7qt when you check you add one quart before the flight.

gilbertohasnofb commented 8 years ago

A couple of questions for you all:

I am thinking about the following strategy:

What do you all think about this? @onox, @wlbragg, @dany93, @Juanvvc, @tigert, any opinions?

gilbertohasnofb commented 8 years ago

Some more info I found of things to take into consideration:

Oil pressure: After engine start the first and most important item to check is the oil pressure, it must register within 30 seconds (60 seconds when in cold to freezing conditions). Low pressure [m]ay be caused by a low level [of oil]

Juanvvc commented 8 years ago

I agree with your strategy. My experience says the engine consumes 1-2 quarts every 10 hours. The max capacity of the 160HP is 8 quarts and 6 quarts is the minimum safe level. I know nothing about the 180HP version. Your last point (if oil level < threshold and engine is on => engine fails) is going to be by far the most difficult to implement. I'd say let's focus on the other points and, once they are working, we can try to implement engine failure.

Regarding the oil cap, it is not really a cap but a small door. In any case, remember we can use a transparent/hidden object only to receive inputs from the user. Most gauge knobs are implemented like this: you are actually not clicking on the knob but on two transparent planes next to the knob: one to increase a value and the other to decrease this value. I think it is enough to define this transparent object in the starboard side of the engine and it could be much bigger than the real "door" for usability reasons.

http://www.weekendcfii.com/photos/c172preflt/C172_oil_dipstick.jpg http://i.imgur.com/M2gXSLi.jpg

gilbertohasnofb commented 8 years ago

Your last point (if oil level < threshold and engine is on => engine fails) is going to be by far the most difficult to implement. I'd say let's focus on the other points and, once they are working, we can try to implement engine failure.

Why do you think that would be difficult? Also, I think we should ideally have an engine coughing for some short time before completely failing, right?

In any case, remember we can use a transparent/hidden object only to receive inputs from the user.

Yeah, that's what I meant by "hotspot" :smile: But on top of that, I volunteer to redo the textures and add the door to the plane. I have always seen that door on top of the nose, never on the side and I don't know what the object circled in red in your second image is supposed to represent

dany93 commented 8 years ago

Your strategy seems good.

Like every engine (cars included), low oil level can give:

To stop (kill) the engine, you can use the float chamber. But that will immediately stop the engine without make it cough. In fact, I would rather say that a jammed engine slows down then stops without coughing.

gilbertohasnofb commented 8 years ago

So one more idea here:

Finally, I will try to at least come up with some concrete pseudo-code for this, but it may be too much for my skills right now. I will give it a try, but at least I would like to gather some information here and make a concrete plan, so that if I am not able to do it alone, someone else can pick up the work. Sounds good?

gilbertohasnofb commented 8 years ago

To stop (kill) the engine, you can use the float chamber. But that will immediately stop the engine without make it cough. In fact, I would say that a jammed engine slows then stops without coughing.

In that case, let's use the float chamber.

dany93 commented 8 years ago

Now, since the 160 and 180 hp engines, it seems that the property to use is (see c172p/systems/fuel.xml) /engines/active-engine/killed = true

gilbertohasnofb commented 8 years ago

Yes, I discovered that property already. Actually, my oil level management is starting to work well. I already created a dialog to control the oil level, and I can kill the engine if level < 6.0 quarts. Now I am trying to figure it out how to handle the oil consumption (I guess I will need Nasal for that).

wkitty42 commented 8 years ago

On 11/03/2015 06:27 PM, Gilberto Agostinho wrote:

Yes, I discovered that property already. Actually, my oil level management is starting to work well. I already created a dialog to control the oil level, and I can kill the engine if level < 6.0 quarts. Now I am trying to figure it out how to handle the oil consumption (I guess I will need Nasal for that).

you should be able to model it in the FDM with some sort of consumption formula... i would try to introduce some sort of randomness that maybe gets worse over the long run... that might include the hobbs runtime in the calculation... i suspect that a brand new engine would use very little oil in X hours of engine runtime... as that count of hours gets larger, then a bit more oil would be used as more and more runtime elapsed...

how often (hours of runtime) does a 160HP and 180HP engine need to be rebuilt?

it really is better to stay off of nasal scripting for everything possible... specifically because of the frame rate execution mentioned elsewhere previously... the trick is to understand the way to code it in xml so that the FDM can handle it properly :smile_cat:

onox commented 8 years ago

@gilbertohasnofb You can try to use a <pid> to control the amount of oil depending on the oil rate (how fast you lose oil). See Systems/bushkit.xml at the bottom. Use ki = 1 and set kp and kd to 0.

If you want to use the regular XML autopilot system, you can use an integrator filter:

<filter>
    <name>Oil Volume Integrator</name>
    <type>integrator</type>
    <gain>1.0</gain>
    <input>
        <property>/my/oil/rate</property>
    </input>
    <output>
        <property>/my/oil/volume</property>
    </output>
    <u_min>0.0</u_min>
    <u_max>8.0</u_max>
</filter>

I don't know how to reset the integrator to 0 though. Might need to ask JSBSim developers on the mailing list because @andgi would like to see it too for the hydrodynamics.

gilbertohasnofb commented 8 years ago

@onox Sounds good. I actually had it implemented and kind of working yesterday but using Nasal (I don't get why would using the Hobbs meter property outside Nasal would be such a better idea given that the Hobbs function is a Nasal function!). I didn't create a new branch nor push because of those issues we were experiencing yesterday with the repo, so I was just playing around in another folder. Later today I will show you what I have, but your <filter> idea may be more interesting indeed.

wkitty42 commented 8 years ago

On 11/04/2015 05:35 AM, Gilberto Agostinho wrote:

@onox https://github.com/onox Sounds good. I actually had it implemented and kind of working yesterday but using Nasal (I don't get why would using the Hobbs meter property outside Nasal would be any good idea given that the Hobbs function is a Nasal function!).

I mentioned using the hobbs because it is the time that the engine has been running... the randomness I mentioned was because engines don't always use oil (and other fluids) at the same rate. I was also thinking, without actually looking, that you might have saved the hobbs in a property where it would be easily accessible to the FDM.

tigert commented 8 years ago

Okay, some references:

160HP

180HP

gilbertohasnofb commented 8 years ago

@tigert Thanks for all the info!

onox commented 8 years ago

the randomness I mentioned was because engines don't always use oil (and other fluids) at the same rate.

JSBSim has <random> (gaussian) and <urandom> (uniform) that you can use in functions.

Like every engine (cars included), low oil level can give:

heating, oil pressure drop, jammed engine (broken).

Just an idea: you could also try two tanks: 'oil-engine' (1 qt) and 'oil-sump' (8 qt). Engine consumes 'oil-engine' and you move (replenish) 'oil-sump' to 'oil-engine'. This allows you to have different rates (consumption and moving).

gilbertohasnofb commented 8 years ago

My first attempts do not use randomness, but the RPM affects the oil consumption. This should give a "random" feel for the consumption rate within a certain margin.

dany93 commented 8 years ago

My opinion is that it is sufficient. I feel that no aircraft in FG has gone so far in the details towards realism.

legoboyvdlp commented 8 years ago

Another thing to consider is that oil can be contaminated; ie, if it is anything like my Dad's car, it should be changed every so often. Thoughts?

Juanvvc commented 8 years ago

Oil must be changed often, but I think this is a task for the regular (and mandatory) inspections done by professional engineers.

I believe changing oil or performing a regular inspection is something that must be simulated by a virtual airline company operating the aircraft, and not the aircraft itself. We must set the limits to the realism somewhere!

onox commented 8 years ago

This YouTube video shows how the oil cap moves.

gilbertohasnofb commented 8 years ago

I think that oil contamination is waaaay too specific already. Also, exchanging oil is something beyond what I planed, I just want to implement a simple pre-flight inspection. What I did so far (and I will push soon) is:

I think that's pretty much it, it's just a matter of refining the code now. I will push this to a new branch soon so you can all comment the code, but today I won't have time for that

gilbertohasnofb commented 8 years ago

@onox that would be a 3D model issue, but I think that for now I will just create a hotspot above the normal map oil cap.

onox commented 8 years ago

Yes, we should leave the 3D modeling of the oil cap to @thevirtualfer.

gilbertohasnofb commented 8 years ago

Okay, so I started working on this on a branch called oil-management, where a first implementation is already pushed. @wlbragg similarly to what happened to the fuel tank sumps, the oil door is not displaying the yellow contour when I hit Ctrl+C. Could you please have a look on it using this branch and try to fix it? You don't have to worry about any kind of conflicts with what I am doing because I won't touch the .ac nor the .blend models myself.

wlbragg commented 8 years ago

OK

gilbertohasnofb commented 8 years ago

Thanks!

wlbragg commented 8 years ago

It's done. Sorry for the delay.

gilbertohasnofb commented 8 years ago

No worries, thanks a lot!