Board index FlightGear Development Add-ons

Add-On LittleNavMap connection (with additional tool)

FlightGear has support for add-ons, to further extend the simulator's core functionality.

Re: Add-On LittleNavMap connection (with additional tool)

Postby sfr » Tue Jan 12, 2021 4:23 pm

here's a little patch that adds fuelflow flow data to LNM. atm it might only work correctly for single-engine planes using JSBSIM.
i've also changed the callsign property to /sim/multiplay/callsign as this is what seems to be used.

Patch for littlefgconnect:

Code: Select all
diff --git a/src/fgconnect.cpp b/src/fgconnect.cpp
index 7ef2ef0..0035777 100644
--- a/src/fgconnect.cpp
+++ b/src/fgconnect.cpp
@@ -80,6 +80,8 @@ bool XpConnect::fillSimConnectData(QString simData, atools::fs::sc::SimConnectDa
     float fuelTotalWeightLbs = pieces.at(index++).toFloat();
     //      <name>fuelFlowPPH (in PPS)
     float fuelFlowPPS = pieces.at(index++).toFloat();
+    //      <name>fuelFlowGPH (in GPH)</name>
+    float fuelFlowGPH = pieces.at(index++).toFloat();
     //      <name>magVarDeg = 0.f</name>
     float magVarDeg = pieces.at(index++).toFloat();
     //      <name>ambientVisibilityMeter = 0.f;f</name>
@@ -159,7 +161,8 @@ bool XpConnect::fillSimConnectData(QString simData, atools::fs::sc::SimConnectDa
     userAircraft.fuelTotalWeightLbs = fuelTotalWeightLbs;
     userAircraft.fuelTotalQuantityGallons = fuelTotalQuantityGallons;
     userAircraft.fuelFlowPPH = fuelFlowPPS * 3600;
-    userAircraft.fuelFlowGPH = fuelFlowPPS * 3600 * 8.35; // for water ??
+    //userAircraft.fuelFlowGPH = fuelFlowPPS * 3600 * 8.35; // for water ??
+    userAircraft.fuelFlowGPH = fuelFlowGPH;
     // userAircraft.numberOfEngines

     userAircraft.ambientVisibilityMeter = ambientVisibilityMeter;


And for the add-on:

Code: Select all
diff --git a/FGData/Protocol/littlenavmap.xml b/FGData/Protocol/littlenavmap.xml
index 38f158b..94ab588 100644
--- a/FGData/Protocol/littlenavmap.xml
+++ b/FGData/Protocol/littlenavmap.xml
@@ -89,10 +89,14 @@
                 <name>fuelFlowPPH (in PPS) = 0.f</name>
                 <format>%f</format>
                 <type>float</type>
-                <node>/fdm/jsbsim/fuel/flow-rate-pps</node>
+                <node>/fdm/jsbsim/propulsion/engine/fuel-flow-rate-pps</node>
+            </chunk>
+            <chunk>
+                <name>fuelFlowGPH (in GPH) = 0.f</name>
+                <format>%f</format>
+                <type>float</type>
+                <node>/fdm/jsbsim/propulsion/engine/fuel-flow-rate-gph</node>
             </chunk>
-            <!--fuelFlowGPH = 0.f-->
-
             <chunk>
                 <name>magVarDeg = 0.f</name>
                 <format>%f</format>
@@ -135,7 +139,7 @@
                 <name>airplaneReg = ""</name>
                 <format>%s</format>
                 <type>string</type>
-                <node>/sim/user/callsign</node>
+                <node>/sim/multiplay/callsign</node>
             </chunk>
             <!--airplaneAirline = ""-->
             <!--airplaneFlightnumber = ""-->
sfr
 
Posts: 93
Joined: Sun Nov 17, 2019 6:25 pm
Callsign: D-CSFR
Version: 2020.4
OS: Kubuntu 18.04 LTS

Re: Add-On LittleNavMap connection (with additional tool)

Postby WoodSTokk » Tue Jan 12, 2021 9:48 pm

For correct PPH you need the density of fuel. This depends on fuel temperature.
Here is the density calculation for Jet-A fuel (as prop-filter):
Code: Select all
<!--
    density relation of Jet A fuel:
    fuel has 7.275 lbs/gal at -100 °F
    fuel has 6.950 lbs/gal at 0 °F
    fuel has 6.625 lbs/gal at 100 °F
    change 0.00325 lbs/gal per 1 °F
-->
    <filter>
        <name>fuel-density</name>
        <debug>false</debug>
        <type>gain</type>
        <input>
            <expression>
                <sum>
                    <product>
                        <property>environment/temperature-degf</property>
                        <value>-0.00325</value>
                    </product>
                    <value>6.95</value>
                </sum>
            </expression>
        </input>
        <output>consumables/fuel/density-ppg</output>
    </filter>


And for LL100:
Code: Select all
<!--
    density relation of LL100 (AVGAS) fuel:
    fuel has 6.490 lbs/gal at -100 °F
    fuel has 6.080 lbs/gal at 0 °F
    fuel has 5.670 lbs/gal at 100 °F
    change 0.0041 lbs/gal per 1 °F
-->
    <filter>
        <name>fuel-density</name>
        <debug>false</debug>
        <type>gain</type>
        <input>
            <expression>
                <sum>
                    <product>
                        <property>environment/temperature-degf</property>
                        <value>-0.0041</value>
                    </product>
                    <value>6.08</value>
                </sum>
            </expression>
        </input>
        <output>consumables/fuel/density-ppg</output>
    </filter>


Now you can calculate from gallons per hour to pounds per hour:
Code: Select all
  <filter>
    <name>fuel-flow_pph</name>
    <debug>false</debug>
    <type>gain</type>
    <input>
        <expression>
            <product>
                <property>engines/engine[0]/fuel-flow-gph</property>
                <property>consumables/fuel/density-ppg</property>
            </product>
        </expression>
    </input>
    <output>engines/engine[0]/fuel-flow_pph</output>
  </filter>


Or pounds per second:
Code: Select all
  <filter>
    <name>fuel-flow_pph</name>
    <debug>false</debug>
    <type>gain</type>
    <input>
        <expression>
            <div>
                <product>
                    <property>engines/engine[0]/fuel-flow-gph</property>
                    <property>consumables/fuel/density-ppg</property>
                </product>
                <value>3600</value>
            </div>
        </expression>
    </input>
    <output>engines/engine[0]/fuel-flow_pps</output>
  </filter>
WoodSTokk
 
Posts: 1077
Joined: Tue Oct 17, 2017 3:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: SX-W57
IRC name: WoodSTokk
Version: 2020.4.0
OS: Debian Bullseye

Re: Add-On LittleNavMap connection (with additional tool)

Postby slawekmikula » Tue Jan 12, 2021 10:43 pm

Cool ! Thanks a lot. I'll try to implement/merge all of your data. Thank you again :)
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Add-On LittleNavMap connection (with additional tool)

Postby sfr » Tue Jan 12, 2021 11:19 pm

i've 'reworked' the previous patches. guess it shows i'm not a good programmer.
Somehow the calculation of 'userAircraft.airplaneEmptyWeightLbs' didn't work for me.
Then i also noticed it would always detect the flightModel as 'jsb'. With below changes yasim is detected fine (Linux; tested with the CitationX).
I've also reverted sending the GPH parameter.

Code: Select all
diff --git a/src/fgconnect.cpp b/src/fgconnect.cpp
index 7ef2ef0..12be2cf 100644
--- a/src/fgconnect.cpp
+++ b/src/fgconnect.cpp
@@ -145,15 +145,15 @@ bool XpConnect::fillSimConnectData(QString simData, atools::fs::sc::SimConnectDa

     // Weight
     // userAircraft.airplaneMaxGrossWeightLbs
-    if (QString::compare(flightModel, "\"jsb\"", Qt::CaseInsensitive)) {
-        userAircraft.airplaneTotalWeightLbs = airplaneTotalWeightLbsJsbsim;
-        // simplification - does not account people & luggage weight
-        userAircraft.airplaneEmptyWeightLbs = airplaneTotalWeightLbsJsbsim - fuelTotalWeightLbs;
+    float airplaneTotalWeightLbs;
+    if (flightModel.contains("jsb")) {
+        airplaneTotalWeightLbs = airplaneTotalWeightLbsJsbsim;
     } else {
-        userAircraft.airplaneTotalWeightLbs = airplaneTotalWeightLbsYasim;
-        // simplification - does not account people & luggage weight
-        userAircraft.airplaneEmptyWeightLbs = airplaneTotalWeightLbsYasim - fuelTotalWeightLbs;
+        airplaneTotalWeightLbs = airplaneTotalWeightLbsYasim;
     }
+    userAircraft.airplaneTotalWeightLbs = airplaneTotalWeightLbs;
+    // simplification - does not account people & luggage weight
+    userAircraft.airplaneEmptyWeightLbs = airplaneTotalWeightLbs - fuelTotalWeightLbs;

     // Fuel flow in weight
     userAircraft.fuelTotalWeightLbs = fuelTotalWeightLbs;


The related protocol changes are shorter now.

Code: Select all
diff --git a/FGData/Protocol/littlenavmap.xml b/FGData/Protocol/littlenavmap.xml
index 38f158b..af12bc8 100644
--- a/FGData/Protocol/littlenavmap.xml
+++ b/FGData/Protocol/littlenavmap.xml
@@ -89,7 +89,7 @@
                 <name>fuelFlowPPH (in PPS) = 0.f</name>
                 <format>%f</format>
                 <type>float</type>
-                <node>/fdm/jsbsim/fuel/flow-rate-pps</node>
+                <node>/fdm/jsbsim/propulsion/engine/fuel-flow-rate-pps</node>
             </chunk>
             <!--fuelFlowGPH = 0.f-->
 
@@ -135,7 +135,7 @@
                 <name>airplaneReg = ""</name>
                 <format>%s</format>
                 <type>string</type>
-                <node>/sim/user/callsign</node>
+                <node>/sim/multiplay/callsign</node>
             </chunk>
             <!--airplaneAirline = ""-->
             <!--airplaneFlightnumber = ""-->
sfr
 
Posts: 93
Joined: Sun Nov 17, 2019 6:25 pm
Callsign: D-CSFR
Version: 2020.4
OS: Kubuntu 18.04 LTS

Re: Add-On LittleNavMap connection (with additional tool)

Postby slawekmikula » Thu Jan 14, 2021 1:12 am

Thanks all for patches and fuel flow helpers. All is implemented in addon and littlefgconnect source and pushed to repositories. I hope the calculation for PPH/GPH is correct for jsb/yasim aircrafts :? . Currently using fixed AVGAS fuel density for calculation. Added also flags for pause/replay and callsign fix.

Happy flying :D ! and do not forget to report anything suspicious
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Add-On LittleNavMap connection (with additional tool)

Postby benih » Thu Jan 14, 2021 8:33 am

Hi there,
i just noticed you define two "<node>" nodes in some <chunks>.
Does this work?
From the c++ code i can see only the first <node> definition should be used: https://sourceforge.net/p/flightgear/fl ... eneric.cxx, Line 915 ff.

And for the PPH, i would assume that the pph property is caluclated by jsbsim correctly already from its corresponding fuel definitions?
User avatar
benih
 
Posts: 1689
Joined: Tue Aug 15, 2017 10:34 am
Callsign: D-EBHX
Version: next
OS: Debian Linux 64bit

Re: Add-On LittleNavMap connection (with additional tool)

Postby slawekmikula » Thu Jan 14, 2021 8:46 am

benih wrote in Thu Jan 14, 2021 8:33 am:i just noticed you define two "<node>" nodes in some <chunks>.
Does this work? And for the PPH, i would assume that the pph property is calculated by jsbsim correctly already from its corresponding fuel definitions?


Where do you find double nodes in protocol file ? In https://github.com/slawekmikula/flightg ... navmap.xml there is no such thing (I hope ?).
Regarding PPH. Yes but GPH have to be calculated with what WoodStock wrote (pounds -> gallons) using fuel density. Everything is around here: https://github.com/slawekmikula/littlef ... t.cpp#L183 if anyone care to see if it is correct that would be good (sorry don't have much time flying around and testing).
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Add-On LittleNavMap connection (with additional tool)

Postby slawekmikula » Thu Jan 14, 2021 9:23 am

I've simplified GPH calculation for jsbsim. GPH is taken from /fdm/jsbsim/propulsion/engine/fuel-flow-rate-gph, PPH as PPS from /fdm/jsbsim/propulsion/engine/fuel-flow-rate-pps (then * 3600). Checked c182s and data are correctly transferred to LNM. Pushed to both repositories. Have fun !
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Add-On LittleNavMap connection (with additional tool)

Postby benih » Thu Jan 14, 2021 12:38 pm

Where do you find double nodes in protocol file

Oh dear, sorry for the noise. I misinterpreted the patch quote above.
User avatar
benih
 
Posts: 1689
Joined: Tue Aug 15, 2017 10:34 am
Callsign: D-EBHX
Version: next
OS: Debian Linux 64bit

Re: Add-On LittleNavMap connection (with additional tool)

Postby slawekmikula » Sun Feb 21, 2021 1:43 pm

Hi all.

Questions for the Nasal experts. I want to feed the AI and MP aircrafts to the LittleNavMap. The easiest solution (right now in my mind) is to query propertytree in add-on nasal code and stitch it into one liner text (csv etc.) and feed it to the LittleNavMap via standard protocol. There I can parse it and create information about each AI/MP aircraft currently available in FlightGear session.

How can I do this ? In PropertyTree we have e.g.

Code: Select all
        /ai/models/aircraft[0]
            /arrival-airport-id -> EKCH
            /callsign -> D3424
            /departure-airport-id -> EPKK
                /position/altitude-ft -> 0.00
                /position/latitude-deg -> 0.00
                /position/longitude-deg -> 0.00


I have to iterate each Node and concatenate into single string. I know simple answer is RTFM, but if someone, who is currently 'deep' into Nasal can feed me some help I could push this addon faster forward. Thanks :)
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Add-On LittleNavMap connection (with additional tool)

Postby FirstOfficerDelta » Wed May 05, 2021 1:32 pm

I apologise if I am asking the very beginner's type question in here, but so far, I just want to clarify the workflow of building littlefgconnect since I am completely new to building something in Qt [5.15.2 on Mac]. Simply put, I build atools, then littlefgconnect?
FirstOfficerDelta
 
Posts: 69
Joined: Thu Mar 26, 2020 1:59 am
Callsign: CPA830

Re: Add-On LittleNavMap connection (with additional tool)

Postby slawekmikula » Wed May 05, 2021 2:49 pm

FirstOfficerDelta wrote in Wed May 05, 2021 1:32 pm:I apologise if I am asking the very beginner's type question in here, but so far, I just want to clarify the workflow of building littlefgconnect since I am completely new to building something in Qt [5.15.2 on Mac]. Simply put, I build atools, then littlefgconnect?


Yes. They should be in the directories on the same level - see littlefgconnect.pro lines 78-83 for exact paths. Project is borrowed from the littlexpconnect and littlenavconnect so maybe there is some leftovers from that source. Littlefgconnect mimicks littlexpconnect (interface for XPlane) and works the same way.
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Add-On LittleNavMap connection (with additional tool)

Postby FirstOfficerDelta » Thu May 06, 2021 6:55 am

Hello!

I built atools (I think) as close as possible to how I read the BUILD.txt, then proceeded to build littlefgconnect, but this is what I got: /bin/sh: -c: line 1: syntax error: unexpected end of file

I don't think I can share an image as of the moment.

[Edit: Nevermind, it worked after I gave it a few more minutes. Though just for anyone who wants to try this on Mac, this is how I did it using Qt Creator:

Dependencies:
Qt (https://www.qt.io) (Tried it on Qt 5.15.2)
When you configure your modules when you download Qt, select "Custom", and pick "Qt 5.15.2" and "Developer and Designer Tools" (Just to be safe)
OpenSSL 1.1.1 (can download via Homebrew)
Atools: https://github.com/slawekmikula/atools
LittleFGConnect: https://github.com/slawekmikula/littlefgconnect


Follow the BUILD.txt of atools. Don't mind if you cannot run atools.

Follow the BUILD.txt of littlefgconnect. Make sure that you select atools as one of your dependencies. Then build and deploy]
FirstOfficerDelta
 
Posts: 69
Joined: Thu Mar 26, 2020 1:59 am
Callsign: CPA830

Re: Add-On LittleNavMap connection (with additional tool)

Postby F-PTCZ » Sun Sep 26, 2021 5:10 pm

HEllo, i'm coming to the news ! is there an easy way now to execute littlefgconnect on Mac ,without compiling? An executable ?

Thanks
F-PTCZ
 
Posts: 59
Joined: Wed Mar 25, 2020 3:28 pm
Location: Paris
Callsign: F-PTCZ
Version: 2020.4.0
OS: MaC OS 12.0.1

Re: Add-On LittleNavMap connection (with additional tool)

Postby slawekmikula » Sun Sep 26, 2021 5:30 pm

AFAIK no. Someone should provide this binary. Maybe there is anyone with the mac to share it.
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

PreviousNext

Return to Add-ons

Who is online

Users browsing this forum: No registered users and 0 guests