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: 51
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
What I do: Flight Dynamics, Systems, Canvas Displays, Autoflight, FlyByWire, Cockpit Animations
Aircraft I currently develop: MD-11 (Mainly), Secret, A320-family (Quality over Quantity)

My GitHub|MD-11 and ITAF Dev Discord|Airbus Dev Discord
User avatar
Octal450
 
Posts: 4709
Joined: Tue Oct 06, 2015 12:51 pm
Callsign: WTF411/Octal
Version: next
OS: Windows 7/10 x64

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: 51
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: 11748
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
What I do: Flight Dynamics, Systems, Canvas Displays, Autoflight, FlyByWire, Cockpit Animations
Aircraft I currently develop: MD-11 (Mainly), Secret, A320-family (Quality over Quantity)

My GitHub|MD-11 and ITAF Dev Discord|Airbus Dev Discord
User avatar
Octal450
 
Posts: 4709
Joined: Tue Oct 06, 2015 12:51 pm
Callsign: WTF411/Octal
Version: next
OS: Windows 7/10 x64

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

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

Postby albcem » Wed Jun 17, 2020 9:37 pm

Hello all,

I am posting in here as my issue seems to resemble the context of the discussion in here - How to pass jsbsim variable values to Flightgear variables when jsbsim is acting as an externally linked FDM?

As for the context, I built a new FlightGear aircraft model with jsbsim serving as the FDM. I fly the aircraft by linking it with ArduPilot (external autopilot) to run SITL (Software In the Loop) simulations. In this operation mode, I belive that jsbsim runs through the ArduPilot framework and is linked to FlightGear as an external fdm.

When I fly the model manually without the autopilot (i,e with Joystick, not SITL), /surface-positions/*-pos-norm and fcs/*-pos-norm values update properly and move the rudder, flaps and ailerons in the 3D visual model. I think in this case, FlightGear manages jsbsim as an embedded fdm. So all key variable values seem to be accessible to FlightGear.

When I fly the aircaft with SITL (the externally linked autopilot and fdm - jsbsim), the aircraft flies correctly but the control surfaces do not move iat all in the 3D model. It is a visual pain but it also causes difficulties with troubleshooting things. I need to visualize the external autopilot's command actions...

Luckily, I am able to confirm the extenal autopilot's servo-actions with the following script:

<output name="C:/tmp/datalog.csv" type="CSV" rate="10">
<property>fcs/aileron-pos-norm</property>
<property>fcs/elevator-pos-norm</property>
<property>fcs/rudder-pos-norm</property>
</output>

Essentially, fcs/*-pos-norm values update, but somehow FlightGear is unable to "see" the updated values or it is automatically setting them to 0s...

So, how do I pass fcs/*-pos-norm properties to FlightGear - either sync the values across the 2 software or just copy JSBSim: fcs/*-pos-norm values to FlightGear: /surface-positions/*-pos-norm? I can use either variable set for surface movement animations....

Could somoone provide guidance or some script example to do this?

Thanks
albcem
 
Posts: 1
Joined: Wed Jun 17, 2020 7:43 pm

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

Postby Thorsten » Thu Jun 18, 2020 5:15 pm

When I fly the aircaft with SITL (the externally linked autopilot and fdm - jsbsim), the aircraft flies correctly but the control surfaces do not move iat all in the 3D model.


Don't you select which properties you transmit from the external FDM to FG? I don't think it does 'all' and if that list doesn't contain surface positions, you don't have surface positions.
Thorsten
 
Posts: 11748
Joined: Mon Nov 02, 2009 8:33 am


Return to Flight dynamics model

Who is online

Users browsing this forum: No registered users and 2 guests