Board index FlightGear Development Aircraft Flight dynamics model

[JSBSim] implicit property exchange JSBSIM <-> FlightGear

Good sims require good FDMs (the "thing" that makes an aircraft behave like an aircraft).

[JSBSim] implicit property exchange JSBSIM <-> FlightGear

Postby amue » Mon Oct 21, 2019 6:46 pm

Is there already a list about what properties get implicitly exchanged between the JSBSim sub property tree and the FlightGear property tree?

E.g. /controls/flight/aileron -> /fdm/jsbsim/fcs/aileron-cmd-norm or /fdm/jsbsim/fcs/left-aileron-pos-norm -> /surface-positions/left-aileron-pos-norm

Or do I have to look at the source code?
amue
 
Posts: 19
Joined: Tue Apr 03, 2018 9:13 am

Re: [JSBSim] implicit property exchange JSBSIM <-> FlightGea

Postby Octal450 » Mon Oct 21, 2019 6:58 pm

I suggest ignoring this defaults "crap" totally and building a custom FCS - you can maybe check out the FCS I made for the PA28: https://github.com/Octal450/IDG-PA28/bl ... 28-fcs.xml

Kind Regards,
Josh
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: [JSBSim] implicit property exchange JSBSIM <-> FlightGea

Postby amue » Mon Oct 21, 2019 7:28 pm

Octal450 wrote in Mon Oct 21, 2019 6:58 pm:I suggest ignoring this defaults "crap" totally and building a custom FCS - you can maybe check out the FCS I made for the PA28: https://github.com/Octal450/IDG-PA28/bl ... 28-fcs.xml

Unfortunately this didn't answer my question.
And what do you mean with "this default crap". Is the implicit property exchange between JSBSim and FlightGear "crap"? I'm confused. AFAICS the aircraft you have linked to, also uses this implicit property exchange: e.g. your FCS writes to /fdm/jsbsim/fcs/left-aileron-pos-norm. This property is then implicitely written to /surface-positions/right-aileron-pos-norm. And via /surface-positions/right-aileron-pos-norm the aileron on the aircraft is animated. Without those implicit exchange the animation wouldn't work.
amue
 
Posts: 19
Joined: Tue Apr 03, 2018 9:13 am

Re: [JSBSim] implicit property exchange JSBSIM <-> FlightGea

Postby Thorsten » Mon Oct 21, 2019 7:40 pm

Well, it would, because you can drive the animation with the JSBSim value just as well.

But I fear you have to look at the source code, I have never seen such a list. Otherwise I agree with Josh - the defaults leave no room for things like failure simulation, so if you aim for realism, you ignore them.
Thorsten
 
Posts: 11135
Joined: Mon Nov 02, 2009 8:33 am

Re: [JSBSim] implicit property exchange JSBSIM <-> FlightGea

Postby Octal450 » Mon Oct 21, 2019 8:36 pm

@amue,
"Without those implicit exchange the animation wouldn't work."
Wrong. I can animate off whatever property I want. I simply write via <output> to the /surface-positions/ ONLY so that he goes over MP automatically. But you really should use name="" for all JSB property assigning unless you specifically need <output> for something.

If I set it to in the animation "fdm/jsbsim/fcs/aileron-left-deg" (NEVER put a leading / in the model's XML unless you specifically need it), it would take from this line: https://github.com/Octal450/IDG-PA28/bl ... cs.xml#L97

Kind Regards,
Josh
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: [JSBSim] implicit property exchange JSBSIM <-> FlightGea

Postby abassign » Thu Oct 24, 2019 6:25 am

amue wrote in Mon Oct 21, 2019 6:46 pm:Is there already a list about what properties get implicitly exchanged between the JSBSim sub property tree and the FlightGear property tree?

E.g. /controls/flight/aileron -> /fdm/jsbsim/fcs/aileron-cmd-norm or /fdm/jsbsim/fcs/left-aileron-pos-norm -> /surface-positions/left-aileron-pos-norm

Or do I have to look at the source code?



The glue that joins JSBSim with FGFS starts here:

https://github.com/JSBSim-Team/jsbsim/blob/master/examples/FlightGear.cxx

At the beginning of the G91R1B project I thought that JSBSim was connected in a bidirectional way with FGFS, but it was just an illusion, as JSBSim is a server-type process that is started by the code I showed you and allows to display in the property tree of FGFS the property tree of JSBSim.

The best thing is to build a property tree in JSBSim and use it for animations. JSBSim may overwrite some properties of FGFS, but you have to be very careful because that property could be rewritten by a FGFS core process.

A typical case, for example, is the use of the handbrake, which is managed by the FGFS system keyboard and which JSBSim can only read as a state.

Here is an example of what I had to do to pseudo synchronize this command with JSBSim:

https://github.com/abassign/G91-R1B_HD/blob/master/Systems/G91-handle-switches.xml

This is the part of the code that modifies the property tree of FGFS:

Code: Select all
       
       <switch name="set controls gear brake-parking">
            <default value="/controls/gear/brake-parking"/>
            <test logic="AND" value="0">
                systems/handle-switches/sw-handle-brake-pos-status == 0
            </test>
            <test logic="AND" value="1">
                systems/handle-switches/sw-handle-brake-pos-status GT 0
            </test>
            <output>/controls/gear/brake-parking</output>
        </switch>


The line code:
<output>/controls/gear/brake-parking</output>
in the JSBSim code, it allows to write "also" on a property tree external to SBSim.

But if a program, in my example the one that manages the keyboard or performs a binding with an action on the 3D object writes above this property, it is re-write in competition with what JSBSim does. So the JSBSim program, which I had to write, must consider this event and handle it appropriately. It sounds complicated, but it's the exact same problem I have in NASAL if I change something in the property tree!

[JSBSim code] --> [output] --> [FGFS Property Tree]

Conversely, if I want to read a value from the FGFS property tree from JSBSim, I just have to remember to insert the "/" character at the top of the course, because if this character is not present, JSBSim considers the path inside its property tree.

As you can see in the XML code line of the example:

<default value="/controls/gear/brake-parking"/>

The reason for this choice comes from the best and lightest CPU-level animation management with JSBSim compared to what can be done with NASAL and / or XML. They are obviously design choices that someone may not like, but that within a project of a plane made for FGFS are absolutely consistent.

In this Wiki link I talk about the problem of replacing the NASAL code in JSBSim:

http://wiki.flightgear.org/Howto:Methods_to_replace_the_NASAL_code_with_JSBSim_code

In particular this cap: Using the variables defined in the Flightgear properties tree, by JSBSim

if you have other questions, ask yourself why the topic is very important.
abassign
 
Posts: 809
Joined: Mon Feb 27, 2012 5:09 pm
Location: Italy (living 5 Km from airport LIME)
Callsign: I-BASSY
Version: 2018.3
OS: Linux Mint 19. x


Return to Flight dynamics model

Who is online

Users browsing this forum: No registered users and 1 guest