Menu

#2793 controls.nas throttleAxis() does not allow (invert:1)

2020.3
Invalid
nobody
Medium
2024-11-08
2023-02-07
No

Investigating a query on the forum, set the following simple settings for a two-throttle ( AV8R) joystick:

    <!-- Analog axis 2. Throttle 1 -->
    <axis>
        <number>
            <unix>2</unix>
            <mac>3</mac>
            <windows>3</windows>
        </number>
        <desc>Throttles</desc>
        <binding>
        <command>nasal</command>
        <script>
        controls.propellerAxis(invert:1);
    </script>
      </binding>
    </axis>

    <!-- Analog axis 4. Throttle 2 -->
    <axis n="4">
        <desc>Prop Pitch; +Trg Mode0: Mixture;  </desc>
        <binding>
            <command>nasal</command>
            <script>
                controls.throttleAxis(invert:1);
        </script>
      </binding>
    </axis>

moitoring property tree at
/controls/engines/engine/propellor-pitch
and
/controls/engines/engine/throttle

the propellor pitch value is properly inverted while the throttle value is not.

Exchanging the bindings to the alternate axes does not change the situation, while propellorAxis() honours (invert:1) the throttle axis remains unaffected.

Inserting print statements in controls.nas @ 108 ff :

# Joystick axis handlers (use cmdarg).  Shouldn't be called from
# other contexts.  A non-null argument reverses the axis direction.
var axisHandler = func(pre, post) {
    print("entr axisHandler");
    func(invert = 0) {
        print("entr innerFunc");
        var val = cmdarg().getNode("setting").getValue();
        if(invert) val = -val;
        foreach(var e; engines)
            if(e.selected.getValue())
                setprop(pre ~ e.index ~ post, (1 - val) / 2);
    }
}

results in console printouts only for the propellorAxis movement, not for the throttle axis.

The commentary for the above function sould read 'uses cmdarg', descriptive, not 'use cmdarg', imperative.

Discussion

  • Huntley Palmer

    Huntley Palmer - 2023-02-07

    ref joystick.nas @ 285. RJH' comments suggest that
    controls.nas @ 72 setfor allenginesProperty() may be involved; this functio does not seem to honour 'invert'

    The entire code path seems a little esoteric bearing in mind the skill level of a user simply attempting to get an input device working !

     
  • Huntley Palmer

    Huntley Palmer - 2023-02-07

    Additionally the default model, c172p, has its own flavour of throttleAxis:
    at fgdata/Aircraft/c172p/Nasal/engine.nas @ 475

    # backwards compatibility only - the controls.throttleAxis should not be overridden like this. The joystick binding Throttle (all) has
    # been replaced and controls.throttleAxis will not be called from the controls binding - so this is to
    # maintain compatibility with existing joystick xml files.
    controls.throttleAxis = func {
        var value = (1 - cmdarg().getNode("setting").getValue()) / 2;
        var new_value = std.max(0.0, std.min(value, 1.0));
        setprop("/controls/engines/current-engine/throttle", new_value);
    };
    

    The commentary is unclear as to who should be obeying the 'should not be overridden like this'

    In any case, if the forum user is attempting to configure a device using the default model it looks as if completely different behaviour to that noted in controls.nas will be experienced.

     
    • Richard Harrison

      The problem is that the c172 overrides throttleAxis without implementing all of the parameters that are defined in controls.nas.

      I have previously recommended that aircraft models should never do this; and instead use a listener on the engine property to perform any special functions.

      This is why there is no output for throttle by adding print into controls.nas

       
  • xDraconian

    xDraconian - 2023-04-04

    @lightwork, Nice analysis work. I agree with your conclusions. This will need to be addressed by the aircraft maintainers.

     
  • xDraconian

    xDraconian - 2023-04-04
    • labels: --> Joystick, Aircraft
     
  • Proteus Four

    Proteus Four - 2024-03-30

    Someone have submitted this analyse to the aircraft maintainers ? I have the same problem see the ticket 1849

     
  • Gijs

    Gijs - 2024-11-07
    • status: New --> Invalid
     
  • Gijs

    Gijs - 2024-11-07

    I have now: https://github.com/c172p-team/c172p/issues/1524, so closing it here (as invalid, because c172p bugs are not tracked here).

     
  • Wayne Bragg

    Wayne Bragg - 2024-11-08

    I have a possible fix for this, but I need someone to test it.
    See https://github.com/c172p-team/c172p/issues/1524#issuecomment-2465630634

     
    • Proteus Four

      Proteus Four - 2024-11-08
      Hello, I'm interested to test it but let me the week for that. 

      I will try it this weekend. 

      Thanks for the work.

      Le 8 nov. 2024 20:48, Wayne Bragg <wlbragg@users.sourceforge.net> a écrit :

      I have a possible fix for this, but I need someone to test it.
      See https://github.com/c172p-team/c172p/issues/1524#issuecomment-2465630634


      [codetickets:#2793] controls.nas throttleAxis() does not allow (invert:1)

      Status: Invalid
      Milestone: 2020.3
      Labels: Joystick Aircraft
      Created: Tue Feb 07, 2023 12:45 PM UTC by Huntley Palmer
      Last Updated: Thu Nov 07, 2024 06:25 PM UTC
      Owner: nobody

      Investigating a query on the forum, set the following simple settings for a two-throttle ( AV8R) joystick:

          <!-- Analog axis 2. Throttle 1 -->
          <axis>
              <number>
                  <unix>2</unix>
                  <mac>3</mac>
                  <windows>3</windows>
              </number>
              <desc>Throttles</desc>
              <binding>
              <command>nasal</command>
              <script>
              controls.propellerAxis(invert:1);
          </script>
            </binding>
          </axis>
      
          <!-- Analog axis 4. Throttle 2 -->
          <axis n="4">
              <desc>Prop Pitch; +Trg Mode0: Mixture;  </desc>
              <binding>
                  <command>nasal</command>
                  <script>
                      controls.throttleAxis(invert:1);
              </script>
            </binding>
          </axis>
      

      moitoring property tree at
      /controls/engines/engine/propellor-pitch
      and
      /controls/engines/engine/throttle

      the propellor pitch value is properly inverted while the throttle value is not.

      Exchanging the bindings to the alternate axes does not change the situation, while propellorAxis() honours (invert:1) the throttle axis remains unaffected.

      Inserting print statements in controls.nas @ 108 ff :

      # Joystick axis handlers (use cmdarg).  Shouldn't be called from
      # other contexts.  A non-null argument reverses the axis direction.
      var axisHandler = func(pre, post) {
          print("entr axisHandler");
          func(invert = 0) {
              print("entr innerFunc");
              var val = cmdarg().getNode("setting").getValue();
              if(invert) val = -val;
              foreach(var e; engines)
                  if(e.selected.getValue())
                      setprop(pre ~ e.index ~ post, (1 - val) / 2);
          }
      }
      

      results in console printouts only for the propellorAxis movement, not for the throttle axis.

      The commentary for the above function sould read 'uses cmdarg', descriptive, not 'use cmdarg', imperative.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/flightgear/codetickets/2793/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/


       

Log in to post a comment.

MongoDB Logo MongoDB