Board index FlightGear Development Aircraft

Multiplayer Aircraft Properties  Topic is solved

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

Multiplayer Aircraft Properties

Postby D-ECHO » Sat Jun 13, 2020 4:07 pm

Hi there

I'm trying to make animations over MP visible. The properties are transmitted via sim/multiplay/generic/. To use human-readable property names in the XML file, I want to use the method described in this wiki article: http://wiki.flightgear.org/Howto:Transm ... es_over_MP
Code: Select all
var rplayer = cmdarg();
# Set up property aliases for animations.
rplayer.getNode("engines/engine/prop-pos-norm", 1).alias(rplayer.getNode("sim/multiplay/generic/float[10]"));

(inside the animation .xml file, under <nasal><load>).

Unfortunately this doesn't seem to work, because engines/engine/prop-pos-norm is not existing in the multiplayer aircraft sub-tree. Am I missing something or is this a bug?

Regards and thanks
D-ECHO
 
Posts: 2462
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Multiplayer Aircraft Properties

Postby wlbragg » Sat Jun 13, 2020 6:22 pm

Only the obvious question, is sim/multiplay/generic/float[10] defined in the set as

Code: Select all
<multiplay>
  <chat_display>1</chat_display>
   <generic>
     ~~~
     <float n="10" alias="/engines/engine/prop-pos-norm"/>
     ~~~
   </generic>
</multiplay>
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: Multiplayer Aircraft Properties

Postby D-ECHO » Sat Jun 13, 2020 6:38 pm

Yes it is
D-ECHO
 
Posts: 2462
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Multiplayer Aircraft Properties

Postby SurferTim » Sun Jun 14, 2020 12:00 pm

I played with that yesterday, and couldn't get any nasal script to execute in nasal load.
This is from the link in your OP. Any idea what this means?
Code: Select all
##############################################################################
   # The on-load Nasal is not executed when this file is loaded as the user
   # aircraft.
   ##############################################################################
Fly low. Fly slow. Land on a dime. Twin Otter. https://github.com/SurferTim/dhc6p
My other aircraft is a Citation-X https://github.com/SurferTim/CitationX
PirateAir videos at https://www.youtube.com/user/SurferTim850
User avatar
SurferTim
 
Posts: 1718
Joined: Sun Dec 09, 2018 6:49 pm
Location: Miramar Beach, FL
Callsign: Pirate
Version: 2020.4.0
OS: Ubuntu 18.04

Re: Multiplayer Aircraft Properties

Postby D-ECHO » Sun Jun 14, 2020 12:28 pm

It basically means exactly what it states - the block in <nasal> is only loaded when the aircraft is shown as a multiplayer aircraft, not when being the user aircraft
D-ECHO
 
Posts: 2462
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Multiplayer Aircraft Properties

Postby wlbragg » Sun Jun 14, 2020 5:04 pm

Have you tried making a filter for /engines/engine/prop-pos-norm to be a different property and trying to pass that property instead?

Where does /engines/engine/prop-pos-norm come from?
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: Multiplayer Aircraft Properties

Postby wlbragg » Sun Jun 14, 2020 5:20 pm

We used different property for spin in both c172p and Cub

c172p
In set.xml
Code: Select all
    <controls>
        <flight>
            <speedbrake alias="/engines/active-engine/rpm"/>
        </flight>
    </controls>

Models/
Code: Select all
    <params>
        <engine>
            <rpm>controls/flight/speedbrake</rpm>
            <crashed>sim/multiplay/generic/int[3]</crashed>
        </engine>
    </params>


J3Cub
set
Code: Select all
        <engine n="2">
            <rpm alias="/engines/active-engine/rpm"/>
        </engine>

Models/
Code: Select all
        <engine>
            <rpm>engines/engine[2]/rpm</rpm>
        </engine>


A shot in the dark, is there an initialization in the set file for /engines/engine/prop-pos-norm as in
Code: Select all
<engines>
 <engine>
  <prop-pos-norm type="float">0.0</prop-pos-norm>
 </engine>
</engines>
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: Multiplayer Aircraft Properties

Postby D-ECHO » Sun Jun 14, 2020 5:25 pm

The property is coming from a nasal script.
Code: Select all
         interpolate("/engines/engine/prop-pos-norm", 1.00, 5);


I have tried with a completely different property, which is not modified by anything (once declared in -set.xml) and it worked, so now I'm going to try and find out the reason it didn't work at first :P

Will keep you updated!

[EDIT] Yes it is initialized in the set file, it was a double but changing to a float didn't change the situation
D-ECHO
 
Posts: 2462
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Multiplayer Aircraft Properties  

Postby D-ECHO » Sun Jun 14, 2020 5:35 pm

Turns out my mistake was that you have to purposefully look at the other model in order for it to be loaded and thus in order for the on-load nasal to be executed. Thanks everyone for the help though!
D-ECHO
 
Posts: 2462
Joined: Sat May 09, 2015 1:31 pm
Pronouns: Bea (she/her)
Version: next

Re: Multiplayer Aircraft Properties

Postby wlbragg » Sun Jun 14, 2020 5:54 pm

FYI

Using rplayer.initNode, may have meaning for you?

I don't know why we use the nasal initNode and then the normal MP alias property?

initNode
Code: Select all
    <nasal>
        <load>
            var rplayer = cmdarg();

            # Gear
            rplayer.initNode("sim/multiplay/generic/int[6]", 0, "BOOL");
            rplayer.initNode("sim/multiplay/generic/int[7]", 0, "BOOL");
            rplayer.initNode("sim/multiplay/generic/int[8]", 0, "BOOL");
        </load>
    </nasal>

and
Code: Select all
    <params>
        <gear_nose_broken>
            <property>sim/multiplay/generic/int[6]</property>
        </gear_nose_broken>
        <gear_left_broken>
            <property>sim/multiplay/generic/int[7]</property>
        </gear_left_broken>
        <gear_right_broken>
            <property>sim/multiplay/generic/int[8]</property>
        </gear_right_broken>
    </params>


Could this be written as

<nasal>
<load>
var rplayer = cmdarg();

rplayer.initNode("sim/multiplay/generic/int[6]", 0, "FLOAT");
or
rplayer.initNode("engines/engine/prop-pos-norm", 0, "FLOAT");

rplayer.getNode("engines/engine/prop-pos-norm", 1).alias(rplayer.getNode("sim/multiplay/generic/int[6]"));
</load>
</nasal>
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: Multiplayer Aircraft Properties

Postby wlbragg » Sun Jun 14, 2020 5:55 pm

OK, scratch my last post.
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: Multiplayer Aircraft Properties

Postby MariuszXC » Thu Dec 15, 2022 11:41 am

Not to multiply threads I'll ask a related question here.
I want to use more compact MP data types to shorten the packet size and lessen the load on MP servers.
New/additional types are described here: https://wiki.flightgear.org/Multiplayer ... Data_types

In my -set.xml I have:
Code: Select all
      <multiplay>
         <generic>
            ...
            <float n="0" alias="/controls/flight/elevator-trim"/>
            ...
            <Short_float_norm n="0" alias="/gear/gear[0]/steering-norm"/>
            ...
         </generic>
      </multiplay>

and in my model.xml I have:
Code: Select all
   <nasal>
      <load>
         <![CDATA[
            var rplayer = cmdarg();
            ...
            rplayer.getNode("controls/flight/elevator-trim", 1).alias(rplayer.getNode("sim/multiplay/generic/float[0]") );
            ...
            rplayer.getNode("gear/gear[0]/steering-norm", 1).alias(rplayer.getNode("sim/multiplay/generic/Short_float_norm[0]") );
         ]]>
      </load>
...


This results in a Nasal error:
Code: Select all
  99.56 [ALRT]:nasal      Nasal runtime error: props.alias() with bad argument
  99.56 [ALRT]:nasal        at /opt/fg/next/install/flightgear/fgdata/Nasal/props.nas, line 43


So how do I use the new shortened data types/encodings in a correct way?

EDIT:
after looking at flightgear/src/MultiPlayer/multiplaymgr.cxx it seems that there is no direct way of requesting some data transmission types for chosen properties.
Types like short_float_norm or short_float_{1..4} are used in a fixed way for predefined properties.

Directly accessible are sim/multiplay/generic/{string[],float[],int[],short[],bool[]}.

I will need to experiment if I can repurpose transmitted but unnecessary properties gear/gear[{3,4}]/{compression,position}-norm, they use short_float_norm encoding.
Or engines/engine[1..9]/rpm in a single engine aircraft (it uses short_float_1 encoding).
INOP
MariuszXC
 
Posts: 1062
Joined: Tue May 18, 2021 5:38 pm
Location: Europe
Callsign: SP-MRM
Version: 2020.4
OS: Ubuntu 16.04

Re: Multiplayer Aircraft Properties

Postby TheEagle » Tue May 23, 2023 11:52 pm

MariuszXC wrote in Thu Dec 15, 2022 11:41 am:I will need to experiment if I can repurpose transmitted but unnecessary properties gear/gear[{3,4}]/{compression,position}-norm, they use short_float_norm encoding.
Or engines/engine[1..9]/rpm in a single engine aircraft (it uses short_float_1 encoding).

Could you ? I'm in the process of multiplayerising my 310 so would really like to know ! :) And is there any possibility to monitor the outgoing MP packet size ?
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: Multiplayer Aircraft Properties

Postby wlbragg » Wed May 24, 2023 12:59 am

Yes, you can repurpose any of those unused properties. See the c172p MP aliases in c172p-main.xml

These are a portion of what we used.
Code: Select all
    <engines>
        <!-- Following properties are part of a static list of properties
             that FlightGear transmits during multiplay. Because the number
             of properties in /sim/multiplay/generic/ is quite limited and
             the properties in /engines/ are unused, we can use them instead
             to get FlightGear to transmit all the required properties.
        -->
        <engine n="2">
            <rpm alias="/engines/active-engine/rpm"/>
        </engine>

        <!-- Amphibious front left -->
        <engine n="3">
            <n1 alias="/gear/gear[19]/compression-ft"/>
            <n2 alias="/gear/gear[19]/position-norm"/>
            <rpm alias="/gear/gear[19]/rollspeed-ms"/>
        </engine>

        <!-- Amphibious front right -->
        <engine n="4">
            <n1 alias="/gear/gear[20]/compression-ft"/>
            <n2 alias="/gear/gear[20]/position-norm"/>
            <rpm alias="/gear/gear[20]/rollspeed-ms"/>
        </engine>

        <!-- Amphibious rear left -->
        <engine n="5">
            <n1 alias="/gear/gear[21]/compression-ft"/>
            <n2 alias="/gear/gear[21]/position-norm"/>
            <rpm alias="/gear/gear[21]/rollspeed-ms"/>
        </engine>

        <!-- Amphibious rear right -->
        <engine n="6">
            <n1 alias="/gear/gear[22]/compression-ft"/>
            <n2 alias="/gear/gear[22]/position-norm"/>
            <rpm alias="/gear/gear[22]/rollspeed-ms"/>
        </engine>

        <!-- Rotation of default/26"/36" tires -->
        <engine n="7">
            <rpm alias="/gear/gear[0]/rollspeed-ms"/>
            <n1 alias="/gear/gear[1]/rollspeed-ms"/>
            <n2 alias="/gear/gear[2]/rollspeed-ms"/>
        </engine>

        <!-- Rain spray for default/26"/36" tires -->
        <engine n="8">
            <rpm alias="/gear/gear[0]/sprayspeed-ms"/>
            <n1 alias="/gear/gear[1]/sprayspeed-ms"/>
            <n2 alias="/gear/gear[2]/sprayspeed-ms"/>
        </engine>
        <engine n="9">
            <rpm alias="/gear/gear[0]/spray-density"/>
            <n1 alias="/gear/gear[1]/spray-density"/>
            <n2 alias="/gear/gear[2]/spray-density"/>
        </engine>
    </engines>

    <rotors>
        <main>
            <!-- Ski ( 23 = both nose wheels) and tiedown right -->
            <blade n="0">
                <position-deg alias="/gear/gear[23]/rollspeed-ms"/>
                <flap-deg alias="/sim/model/c172p/tiedowns/right/heading-deg"/>
            </blade>
            <blade n="1">
                <position-deg alias="/gear/gear[24]/rollspeed-ms"/>
                <flap-deg alias="/sim/model/c172p/tiedowns/right/pitch-deg"/>
            </blade>
            <blade n="2">
                <position-deg alias="/gear/gear[25]/rollspeed-ms"/>
                <flap-deg alias="/sim/model/c172p/tiedowns/right/length"/>
            </blade>

            <!-- Tiedown left -->
            <blade n="3">
                <position-deg alias="/sim/model/c172p/tiedowns/left/heading-deg"/>
                <flap-deg alias="/sim/model/c172p/tiedowns/left/pitch-deg"/>
            </blade>
            <rpm alias="/sim/model/c172p/tiedowns/left/length"/>
        </main>

        <!-- Tiedown tail -->
        <tail>
            <blade n="0">
                <position-deg alias="/sim/model/c172p/tiedowns/tail/heading-deg"/>
            </blade>
            <blade n="1">
                <position-deg alias="/sim/model/c172p/tiedowns/tail/pitch-deg"/>
            </blade>
            <rpm alias="/sim/model/c172p/tiedowns/tail/length"/>
        </tail>
    </rotors>
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: Multiplayer Aircraft Properties

Postby MariuszXC » Wed May 24, 2023 8:24 am

Yes, I could, exactly as @wlbragg explained. However I was disgusted with how ugly a kludge it was and gave up for now. Or, to put it in a more politically-correct way, I moved it way down in my priority list for further consideration.
INOP
MariuszXC
 
Posts: 1062
Joined: Tue May 18, 2021 5:38 pm
Location: Europe
Callsign: SP-MRM
Version: 2020.4
OS: Ubuntu 16.04

Next

Return to Aircraft

Who is online

Users browsing this forum: No registered users and 19 guests