Board index FlightGear Support Interfacing

DC3 gear down Nasal puzzler - * solved *  Topic is solved

Connecting two computers, using generic protocol, connecting with Matlab?

Re: DC3 gear down Nasal puzzler - *** solved ***

Postby Volador » Fri Apr 30, 2021 10:43 pm

WoodSTokk you cracked it!! Thank you (see you on the return flight on Wednesday?). And thanks Wlbragg too! Polly had been helping and advising too and had spotted the confusion in the logic <0 >0 but I'd not joined the dots so to speak. Wlbragg, thank you for your explanation - I was wondering why I couldn't find a reference to func(state) or func(node) anywhere ...and I as looking everywhere, so it's just a variable name (doh!) - I now get the bit about calling the command rather than duplicating the actual nasal code (and my listener for the arduino property was working fine) but the really confounding thing was the -1 rather than 0 or 1 ...oh to standardise, thanks again everyone :)

[edit] Polly spotted that the arduino property did need to be set as below (even if it was already 1 on startup) otherwise the gear was down on startup, so the working solution is the code below and it needs to be included in the DC3.nas file. To keep things tidy I'd rather it was in a separate arduino-dc3.nas file that I've created and I've put a path:
<arduino-control>
<file>Aircraft/Douglas-Dc3/Nasal/arduino-DC3.nas</file>
</arduino-control>
in the dc-3-jbsim-cnf.xml but it's not working...

Code: Select all
setprop("input/arduino/gear-down", 1);   

setlistener("input/arduino/gear-down", func(v)
    {
    if (v.getBoolValue())
      {
      controls.gearDown(1);
      }
    else if (v.getBoolValue() == 0 )
      {
      controls.gearDown(-1);
      }
    },1,0);
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit

Previous

Return to Interfacing

Who is online

Users browsing this forum: No registered users and 3 guests