Board index FlightGear Support Hardware

Joystick xml binding power decimal?

Joysticks, pedals, monitors.

Joystick xml binding power decimal?

Postby mathieugouin » Fri Mar 08, 2019 3:51 am

Hello,

I'm tweaking my joystick xml and I stumbled on what seems contradictory references.

I would like to know if I can put something like this (notice power = 1.5):

Code: Select all
    <axis n="0">
        <desc>Aileron</desc>
        <dead-band type="double">0.0</dead-band>
        <binding>
            <command>property-scale</command>
            <property>/controls/flight/aileron</property>
            <offset type="double">0.0</offset>
            <factor type="double">0.6</factor>
            <power type="double">1.5</power>
        </binding>
    </axis>


From: http://wiki.flightgear.org/Writing_Joys ... de:_Part_1 (seems to be decimal)
<power ...... : Sometimes the axes are too sensitive - a slight touch on aileron makes the plane barrel-roll. You can reduce this sensitivity by making the value of power more than 1. (It is a decimal number, so you can make small adjustments, but small adjustments are usually not enough to be noticible.) Never mind the maths, but the larger the value of power the less sensitive the aircraft will be to axis movement.


From: http://wiki.flightgear.org/Bindings#property-scale (seems to be integer only)
power: the resulting value will be taken to the power of this integer value (overrides squared).


Thanks!
Mathieu
mathieugouin
 
Posts: 36
Joined: Thu Jan 06, 2011 4:37 am
Location: CYHU
Callsign: MGOUIN
Version: V2018.1.1
OS: Lubuntu 18.04

Re: Joystick xml binding power decimal?

Postby mathieugouin » Mon Mar 11, 2019 3:21 am

Based on some more tests, it seems to only allow for integer (a rounding seems to occur), but I would have liked to have developer confirmation on this...
Mathieu
mathieugouin
 
Posts: 36
Joined: Thu Jan 06, 2011 4:37 am
Location: CYHU
Callsign: MGOUIN
Version: V2018.1.1
OS: Lubuntu 18.04

Re: Joystick xml binding power decimal?

Postby wkitty42 » Fri Mar 15, 2019 3:47 pm

i'm not a developer but i will state the following:
  • decimal numbers are base 10.
  • integers are decimal numbers which are whole numbers.
  • decimal numbers use a decimal point if they are fractional numbers.
i write the above because it seems that you are confusing a decimal number with one requiring a decimal point... yes, it would be better/clearer if the "writing joystick code" wiki link used the term "integer" instead of "decimal number" but i can understand it being written that way so as to distinguish between decimal, hexadecimal and octal numbering schemes...

another possible clue that it is an integer may be because it is used as a power since it overrides the square power seemingly indicated by the comment in the "bindings#propertyscale" quote...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9148
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Joystick xml binding power decimal?

Postby mathieugouin » Sun Mar 17, 2019 9:11 pm

Thanks for the response, however, a power is perfectly valid "mathematically" to be fractional (or even irrational ;) ). Reference: http://mathworld.wolfram.com/Power.html

My question was in hoping I could have put a power of something like 1.5 because I find that linear (power = 1) is too sensitive in the middle, vs square (power = 2) is too steep at the end.

Could this be added as a suggestion? The c pow function (I assume this is the one used in the code, I did not look) supports that: http://pubs.opengroup.org/onlinepubs/00 ... s/pow.html

Thanks anyway :)
Mathieu
mathieugouin
 
Posts: 36
Joined: Thu Jan 06, 2011 4:37 am
Location: CYHU
Callsign: MGOUIN
Version: V2018.1.1
OS: Lubuntu 18.04

Re: Joystick xml binding power decimal?

Postby wkitty42 » Mon Mar 18, 2019 4:05 pm

you are correct about power values...

what happens when you test with 1.5??
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9148
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Joystick xml binding power decimal?

Postby mathieugouin » Tue Mar 19, 2019 12:10 am

It seems to behave like power = 1 (linear). A floor operation seems to be done. I even tried 1.99.

Thanks!
Mathieu
mathieugouin
 
Posts: 36
Joined: Thu Jan 06, 2011 4:37 am
Location: CYHU
Callsign: MGOUIN
Version: V2018.1.1
OS: Lubuntu 18.04

Re: Joystick xml binding power decimal?

Postby Johan G » Sat Jun 01, 2019 5:42 pm

I have unsuccessfully tried to find the code that read the joystick configuration file, looking for what data type it for sure is, but the closest I get is flightgear/src/Input/FGJoystickInput.cxx which is not the right place.

Not being a programmer and not having looked around in the code base for two years does not really help either. :roll:
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Joystick xml binding power decimal?

Postby tom_nl » Thu Dec 10, 2020 11:12 pm

Opening up an older thread - interested if there's been any progress/consideration on having the joystick xml <power> modifier accept values other than integers?

I've found that one way to improve the issues with the Logitech yoke dead zone (short of cracking out the soldering iron), is after setting the dead zone to the smallest possible range in the windows driver, is to use a <power> modifier on the elevator and aileron axes, so that when the yoke moves out of the dead zone the control movement is gradual rather than sudden. As others have mentioned the <power> modifier in the joystick xml file only seems to accept integers - for me having <power.> set to 2 is a little insensitive, whereas 1 is of course the linear response and the movement coming out of the dead zone is too abrupt. I've been fiddling about with Grapher on my mac to see what the effects of various power functions on the response would be - somewhere around 1.5 seems to be the sweet spot in the curve shape.

I guess I could probably write some nasal code to do the same - if I can't take the joystick values directly from the property tree, map the joystick outputs to holding values in the property tree using the XML, then use some nasal to then transform this to the control surface values with a 'float' power modifier. Guess i've found my project for the weekend....

Tom
tom_nl
 
Posts: 84
Joined: Tue Aug 04, 2020 11:41 am
Location: Netherlands
OS: OS X Big Sur

Re: Joystick xml binding power decimal?

Postby Johan G » Fri Dec 11, 2020 3:59 pm

tom_nl wrote in Thu Dec 10, 2020 11:12 pm:I guess I could probably write some nasal code to do the same - if I can't take the joystick values directly from the property tree, map the joystick outputs to holding values in the property tree using the XML, then use some nasal to then transform this to the control surface values with a 'float' power modifier. Guess i've found my project for the weekend....

Since you will need this in real time you might instead want to test out using filters/property rules for that.

For details on property rules, see the FlightGear wiki article: Autopilot configuration reference (permalink).
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Joystick xml binding power decimal?

Postby tom_nl » Fri Dec 11, 2020 5:23 pm

Good tip - thanks!

Tom
tom_nl
 
Posts: 84
Joined: Tue Aug 04, 2020 11:41 am
Location: Netherlands
OS: OS X Big Sur

Re: Joystick xml binding power decimal?

Postby tom_nl » Fri Dec 11, 2020 8:44 pm

Problem solved!

Technically this is probably classed as quick and dirty but it seems to work nicely. I've replaced the usual <factor> <offset> <power> for the elevator and aileron axes with some nasal code that reads the raw joystick axes, then applies an arbitrary power to them which unlike the <power> modifier can be a floating point number (the aileronpower and elevatorpower variables in the code), then sends the results to /controls/flight/elevator and /controls/flight/aileron in the property tree.

Code: Select all
  <axis>
    <desc type="string">Aileron</desc>
    <binding>
      <command>nasal</command>
      <script><![CDATA[
 var aileronin = getprop("/devices/status/joysticks/joystick[1]/axis");
       
       var aileronpower = 1.6;
       var aileronout = 0;
          if(aileronin > 0)
                {
                aileronout = math.pow(aileronin,aileronpower);
               }
                elsif (aileronin < 0)
                {
                aileronin = -aileronin;
                aileronout = -(math.pow(aileronin,aileronpower));
                }
            else
            {
                aileronout = 0;
                }
                  setprop("/controls/flight/aileron", aileronout);
                ]]></script>
    </binding>
  </axis>
  <axis n="1">
    <desc type="string">Elevator</desc>
    <binding>
      <command>nasal</command>
      <script><![CDATA[
 var elevin = getprop("/devices/status/joysticks/joystick[1]/axis[1]");
       
       var elevpower = 1.8;
       var elevout = 0;
                if(elevin > 0)
                {
                elevout = -math.pow(elevin,elevpower);
                }
                elsif (elevin < 0)
                {
                elevin = -elevin;
                elevout = math.pow(elevin,elevpower);
                }
            else
            {
                elevout = 0;
                }
                  setprop("/controls/flight/elevator", elevout);
                ]]></script>
    </binding>
  </axis>


I now have nice progressive easy to control aileron and elevator axes. The yoke dead zone is barely noticeable, and flying is much smoother and I can finally do a proper nice smooth landing flare :-)

@Johan G - I looked through the filters/property rules documentation but although it does a lot, it doesn't seem to have the ability to apply a power to an input value. Happy to be corrected here though.

Tom
tom_nl
 
Posts: 84
Joined: Tue Aug 04, 2020 11:41 am
Location: Netherlands
OS: OS X Big Sur


Return to Hardware

Who is online

Users browsing this forum: Alant, nerdjuice and 4 guests