Board index FlightGear Development Nasal

FGFSCopilot Hybrid

Nasal is the scripting language of FlightGear.

FGFSCopilot Hybrid

Postby redneck » Tue Nov 06, 2012 4:27 am

I am creating a brand new topic just for my latest project: FGFSCopilot Hybrid. It's "Hybrid" b/c this version is going to be run by a collaboration between Java and Nasal code. Two different languages running the same thing, kinda like gas and electric running the same car, or an air-breathing rocket-SCRAMjet propelling daring test pilots to hypersonic speeds at the edge of space. This is more than an update to the old FGFSCopilot. Perhaps you could think of it as a partial Nasal port, but without all the bugs (at least not the same bugs :roll: ), as the old FGFSCopilot, and a bunch of new features. Except for the GUI, I'm essentially rewriting the whole thing, since I found out that my system for checking the phase of flight was not only as confusing as trying to fly an R/C plane headed towards you with all control axes inverted, but it just didn't work quite right to begin with. I scrapped it, and decided on using a giant nested if-statement, which I had to draw up from scratch. Since Java will only be running the GUI, there is no longer any need to keep the program stuck in an infinite loop so that it continues to manipulate FG properties. This means that the GUI will no longer freeze upon clicking the "Activate!" button. Furthermore, I've added an override button. That way, if, for any reason, a user decides they need to make FGFSCopilot stop, they can just click that button, instead of having to force terminate the program. The other added benefit to this feature is that it will leave the GUI running, in case the user has to stop FGFSCopilot just to fix a typo in one of the textfields. The user can then click the "Activate!" button again to get FGFSCopilot going again immediately. So, we'll have a Java GUI at the front taking in user input, and sending it off to the property tree, with a few other calculated values, and we'll have Nasal working the magic behind the scenes. If I manage to do this right, we can expect it to make a flight correction during every frame! Also, since Nasal has write access to several properties that are restricted to Java, I'll be able to include other things like auto thrust reversers. I'll also be able to make it manipulate flight controls directly so that it can lower the throttle to idle itself after touchdown, instead of setting the A/T to -999 kts.

At its current state of development, the Java code is essentially done. I just gotta convert some code, which I mistakenly wrote in Java, over to Nasal. The GUI is tested and confirmed fully functional at this time; however, I will be removing some of the properties that it will be creating, as they just happen to be properties that I need Nasal to create. So, I will have to test it again. On the Nasal side, it's vastly incomplete, as I just just started it a few hours ago. It's gonna take some time before I get any of it running. I have no ideas for any estimated release date. I have no plans for trying to estimate when it'll be done. Anything can happen. I'll release it when I know it's ready, or at least working for fixed wing aircraft. I'm still gonna have to run it through several flight tests, anyway, and each one will last anywhere from 20 minutes to an hour or maybe a little longer. I'll probably broadcast them live on twitch (formerly justin tv) like before. AFAIK, they will be recorded to the website and available for viewing indefinitely.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby Hooray » Tue Nov 06, 2012 2:10 pm

If you hadn't already completed the Java GUI, I'd be tempted to suggest that even the GUI could now be implemented directly in FlightGear using the Canvas system. We are still looking for "first adopters" who help us shape the API for GUI programming needs, but as can be seen below, it's already possible to create fully custom GUIs in FlightGear using Nasal+Canvas:


Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: FGFSCopilot Hybrid

Postby redneck » Tue Nov 06, 2012 8:47 pm

Well, as far as the GUI is concerned, it's mostly recycled code. The only changes on the Java side are the new override button and the new handler for the activate button. I was wondering what that canvas thing was when I cloned the Git version, but I wasn't curious enough to really check it out. However, that's changed now. I'll still release FGFSCopilot Hybrid, once I finish it, but my true goal is still to get it completely integrated in FG. Hybrid is kind of a transition state, as far as achieving a complete FG integration. It seemed like the most logical step to me at my current skill level. The whole idea is to avoid biting off more than I can chew. So, if I convert the code that controls the AP and other stuff to Nasal first, then I will know, when I encounter a problem (it's rare that I don't in a project like this), I'll have an easier time figuring out what it is, b/c my list of things that can go wrong will be kept to a minimum. So, thanks for letting me know about this new Canvas thing. I'll definitely check it out once I get Hybrid to a fully functional state.

As for my progress on Hybrid, I have now finished converting the Java code, which I had meant to write in Nasal *facepalm*, over to Nasal. That code consists of the entire system for determining phase of flight in fixed-wing aircraft. I'm putting the heli stuff on hold for now. I may or may not decide to scrap that option. The old FGFSCopilot is pretty far off from what I had planned for in terms of flight automation in helis. Unless I can change things up so that altitude is controlled by collective pitch, and speed is controlled by cyclic pitch, it's pretty useless to even consider keeping it, as demanding that the user sit and watch that their airspeed doesn't get too high by adjusting collective pitch manually, thereby reducing lift, and causing the AP to respond to the drop in altitude by pulling on the cyclic with the end result being that altitude is maintained while speed is reduced, defeats the whole purpose.

Anyway, with the system for determining phase of flight in fixed wing aircraft completed, I'm going to start working on functions that will manipulate the AP, gear, flaps, etc. based on the phase of flight.

EDIT: Actually, since I'll need those functions to update when they run, I'll probably just make a brand new Nasal file for each one. Otherwise, it'll just be a big mess.

EDIT2: Or perhaps, it would be better to use a hash to map a key (phase of flight) to functions (what to do in that phase of flight), and have a unique loop id for each function that needs to loop (all of them, except "end", since that one will just toggle a prop to stop the the update function from getting anywhere), so I won't end up with bad loop issues, and, at the same time, won't have to write the whole thing in about a dozen different Nasal files. It's my first time actually trying this, but the wiki seems to be pretty clear so far, so I think it'll be fine.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby redneck » Thu Nov 08, 2012 8:56 pm

redneck wrote in Tue Nov 06, 2012 8:47 pm: and have a unique loop id for each function that needs to loop

Not sure what I was thinking there. Those functions will be called every time the update function is called (every frame). The proper flight phase function will then run through the checks and do its thing. When the flight phase changes, then a different flight phase function will be called, instead.

Anyway, I've managed to get the Nasal code done to a level of completion suitable for testing. In other words, at this time, it will ONLY support fixed-wing aircraft on flights using an ILS approach. I can't test it now, since I gotta eat, but I'll be sure to broadcast the flight test(s). Of course, how many I do today will depend on how soon I encounter a bug, and the number of bugs I encounter.

EDIT: Looks like I won't be broadcasting tonight. I hadn't configured Xsplit for my home Internet. Was used to being able to upload at 60 Mbps. Now, it's only 0.35 Mbps. Took me about 3 hours just to get it set up right, but now, due to other unexpected circumstances in RL, I got other things I need to do before I can go to bed, and then I need to somehow wake up early, when I haven't been sleeping for less than 12 hours a night for about the past month or so. It's 2215 over here now.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby redneck » Sat Nov 10, 2012 1:59 am

http://www.twitch.tv/redneck1180

First flight test now live!

EDIT: Nevermind. Didn't even activate, and no errors in the console :?

EDIT2: Actually, there was an error message, but I missed it, since the 787-8 was flooding it with its own errors (can't find a bunch of models for animation) :roll:

EDIT3: Got everything cleaned up, but now it just doesn't seem to run, while also not producing errors. I'm not sure what's going on on here. It was my understanding that using the following:

setprop("/path/to/prop", "value");

wasn't limited to changing values of currently existing properties, but would also allow me to create new ones. I know that's how omega and I got new features to work with the 787-8 revamp project; however, it almost seems as though the rules have been changed, now that I'm working on my own thing. Funny how the Java GUI can create new properties, but Nasal, all of a sudden, can't/won't.

Btw, I wasn't using a setlistener, and thought that that might have something to do with it. But, when I try to use one, I get an undefined symbol error. Maybe it's b/c the file is in Nasal's home directory. But, moving it to an aircraft's Nasal directory doesn't provide much change. The undefined symbol error goes away, but the one property that it's supposed to create during the init function just doesn't show up. It just happens to be the "on/off switch" for fgfscopilot, so I can't really do anything without it. Anyway, I'm not sure when I'll be able to get back to this again. Life is getting hectic again :(

EDIT4: Found and fixed problems... mostly. Will work when added to an aircraft, and that aircraft's -set.xml file is edited to load it. Now, I just gotta fine tune the update interval, as it seems I had over-estimated my laptop's processing capability. So, we'll probably probably be looking at a rate of 1 flight adjustment per second, which still isn't bad, considering that it won't be flying the plane directly, but instead, feeding settings and adjustments to those settings into the AP. The only time it's gonna have direct control is just after touchdown, when it cuts the throttle down to idle directly, as well as when it toggles thrust reversers on, and then slams the throttles to full until the jet slows down to 60 KIAS, and then it will pull the throttle back to idle again, and toggle the thrust reversers off.

If I find the MUCH longer update interval to be a problem, then, I'll have to look into modularization again. Of course, it won't work if I can't at least use a simple Nasal script that will ONLY create the connection prop, without looping. Then, instead of listening for the FDM to initialize, I can have a flight phase checker listen for the connection prop to be set to 1, which would indicate that the user has clicked the "activate" button. This one should be safe to loop once every second, as well as most flight phase functions, those which control AP settings and other stuff to make the plane do what it needs to do. Of course, I'd prefer to have those that cause settings to change in increments to execute every frame. Since the flight phase functions only contain about 10 lines of code or so, I wouldn't expect that to be so bad. The main issue I see is that it's a big file, and it's already executing before FG has completely initialized, making startup take quite a while longer, if it starts at all.
Last edited by redneck on Mon Nov 12, 2012 5:22 am, edited 1 time in total.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby Hooray » Sat Nov 10, 2012 3:20 pm

Funny how the Java GUI can create new properties, but Nasal, all of a sudden, can't/won't.


That sounds like you made some weird mistake there - Nasal can DEFINITELY make up new properties from scratch easily - otherwise, you wouldn't even be able to start up fgfs at all. I'd suggest you come up with a down-stripped test case and use the Nasal console to see for yourself:

Code: Select all
 var path = "/redneck/says/Nasal/is/broken";
 setprop(path, "but Hooray disagrees ");


You should make sure to fully understand a problem before you are drawing wrong conclusions ;-)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: FGFSCopilot Hybrid

Postby redneck » Tue Nov 13, 2012 5:06 am

I really should work on moving away from code when I get tired :oops:

Anyway, latest update: As mentioned before, I managed to fix the problems I had, only to wind up making a Nasal script that was essentially DOSing my FGFS instance. So, I've begun work on splitting it up into several small files, which will execute ONLY when needed, and then die when they are no longer needed, assuming I'm doing this right. Furthermore, after rummaging through the wiki, I managed to find a small stub on Nasal modules, and get scripts to execute without having to add them to an aircraft. I now have a total of four separate files to make this work, and I expect I'll need to make about 10 more. On the bright side, some of them don't even have to loop at all. For those that do, I'm expecting my update intervals to range from 0.001 seconds to 2.5 seconds, and perhaps only the autoland script will use the shortest update interval, as it will be initialized once the plane descends through 40 AGL, and, I'm expecting that there will be less than 3 seconds for most jetliners to "realize" they need to flare, and do it, before slamming into the runway. Maybe I'll just change that 40 AGL thing to an approach speed-dependent value. I'll see how things go when I manage to reach a stage of completion sufficient for flight testing on a cross-country flight again.

EDIT1: Running into some weird issues. I probably have some issues with the setlisteners. Not that that matters. I just realized, since there's no way to revoke a settimer loop, this method is a bad idea as well. I got thinking, and realized I had already made an aircraft-specific XML/Nasal port of FGFSCopilot already. I just never recognized it as such. But, all the stuff that I wrote for the 787-8's virtual copilot are for serving the exact same purpose as FGFSCopilot. Of course, I won't be able to make things exactly the same, but it will be a good model to work from, nonetheless.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby Hooray » Tue Nov 13, 2012 3:16 pm

I just realized, since there's no way to revoke a settimer loop

Use the "loopid" method: http://wiki.flightgear.org/Nasal_Loops

Alternatively, just introduce a loop-running flag at the top of your loop and check it every time. This can be a Nasal space variable or even a property tree variable. By changing the value of the variable, you can then interrupt the settimer() loop. That's the way this is commonly done.

That way, you can also encapsulate a timer loop that can be controlled via a listener - all in a single Nasal hash (class).
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: FGFSCopilot Hybrid

Postby redneck » Wed Nov 14, 2012 8:26 am

I've been there several times. I was using the loopid method, but I couldn't figure out exactly how the id could ever not match the global loopid to make the loop die off. As for your alternative method, I noticed the following in the wiki:

FG wiki wrote:Unfortunately, this method is rather unreliable. What if the loop is "stopped" and a new instance immediately started again? Then the running variable would be 1 again, and a pending old loop call, which should really finish this chain, would happily continue. And the new loop chain would start, too, so that we would end up with two loop chains.

I kinda just expected that to be a common issue with that method for controlling settimer loops, and figured that that would not be a viable option. I might try it out later. OTOH, I've been tinkering aaround with making a simple XML dialog to simply skip the whole hybrid thing, and so far, I've been coming along pretty well. The documentation (both offline and online) was a bit of a hassle with trying to find what I needed to know, but I've managed with the generic autopilot settings dialog as a guide. Even its nasal code for managing the checkboxes and radiobuttons came in handy. I know had no clue what it was doing when I looked at it the last time I tried making an XML dialog for FGFSCopilot. Nasal OOP looks a lot different from Java OOP. It doesn't do anything yet, but at least the layout looks okay so far. The only issue right now, is that it's label doesn't show in the menu off the menubar. I placed it under the last item in the Autopilot menu. It's there, and I can click it, but it just looks kinda funny-looking.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby Hooray » Wed Nov 14, 2012 3:52 pm

dialog-wise there's lots to be learnt just by looking at existing dialogs that do something that you need and then copy/paste useful stuff from it into your own dialog file.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: FGFSCopilot Hybrid

Postby redneck » Thu Nov 15, 2012 6:34 am

Yeah. Now, if I could just make COMPLETE sense of it, I'd be fine. I've been through the wiki concerning OOP in Nasal, and it just isn't catching on anywhere near as fast as Java OOP did. It just seems to make more sense to have something like:

Code: Select all
public class Jet extends Aircraft{
   private double mach = 0;
   private double n1 = 0;
   public Jet(){
      super("Jet");
      mach = 0;
      n1 = 0;
   }
...getters/setters and other useful methods

than to have:
Code: Select all
var Jet = {
               new : func(mach, n1){
                  var j = {parents: [Jet, Aircraft.new()]};
                  j.mach = mach;
                  j.n1 = n1;
                  return j;
               },
            };
...getters/setters and other useful functions


I'm not asking anyone to remake Nasal or anything. I'm just saying, I'm having a hard time wrapping my head around this. I noticed that the autopilot dialog uses Nasal OOP such that only one setter function was needed, which acted as a different setter for each variable. I couldn't seem to figure it out though. It makes use of a lot of Nasal functions I have yet to get acquainted with. Maybe I'll just end up not implementing such awesome, efficient code, and just use a script binding on all the radio buttons and text fields.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby Hooray » Thu Nov 15, 2012 2:34 pm

It would help us if you could ask specific questions :D

The OOP style isn't all that weird actually: forget about public/protected/private: In Nasal, everything is ALWAYS public.
Also, there's no such thing as constructors or destructors in Nasal: these need to be manually implemented and called explicitly.
Class members (fields/methods) can be either declared in an embedded fashion:

Code: Select all
var Class = { field1:0, field2:0, field3:0};


or like this:

Code: Select all
var Class = {};
Class.field1 = 0;
Class.field2 = 0;
Class.field3 = 0;


Functions and methods can be also declared both ways:

Code: Select all
var Class = {
  hello : func { print("Hello"); },
};


or:

Code: Select all
var Class = {};
Class.hello = func {
  print("Hello");
}


The latter style is probably more intuitive to most people.

Maybe post the Nasal snippets that you don't quite understand, so that we can take a stab at explaining things?
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

FGFSCopilot Integra

Postby redneck » Fri Nov 16, 2012 3:09 am

Interesting... Well, it seems I've managed to get a better understanding on my own anyway. Idk how, but sometimes, when I just stop trying, and I'm off doing something else, it just clicks in one massive "Aha!" moment. Anyway, I seem to have hit a wall again. I feel like the dialog is VERY close to working properly. Of course, the problem lies in the embedded Nasal code, which I've pasted below.

Code: Select all
Group = {
               new : func(name, elements){
                  var m = {parents: [Group]};
                  m.name = name;
                  m.element = elements[0];
                  m.elements = [];
                  foreach (var o; elements) {
                     var node = dlg.getNode(o);
                     if (node == nil) {
                        node = dlg.getNode(o, 1);
                        node.setBoolValue(0);
                     }
                     append(m.elements, node);
                  }
               },
               get_name : func{
                  return name;
               },
               set : func(setting){
                  me.setting = setting;
                  foreach(var s; me.elements){
                     setprop("/fgfscopilot/settings/"~ me.get_name(), setting);
                  }
               },
            };
            var dlg = props.globals.getNode("/sim/gui/dialogs/fgfscopilot", 1);
            
            var ac = Group.new("aircraft", ["jet", "prop"]);
            var app = Group.new("approach", ["vis_rnav", "ils", "vor", "ndb"]);

The problem occurs whenever I try to select a radio button. For example, selecting the Jet radio button, will call ac.set("jet"). As you can see, "ac" is an instance of the Group class with name "aircraft", and elements "jet" and "prop". Calling the set function with parameter "jet", should do setprop("/fgfscopilot/settings/aircraft", "jet"), if I've written this correctly (me.get_name() returns "aircraft" in this example), yet I am led to believe that is not the case here. The selection is kinda rejected. I mean, the radio button appears to have been selected for about .5 - 1 second, and then reverts back to its deselected state, and the following error is thrown:
Code: Select all
Nasal runtime error: non-objects have no members
  at /sim/bindings/gui/binding[1], line 1

I go into that property, and find nodes with the following:
Code: Select all
<command>nasal</command>
<script>ac.set("jet")</script>
/sim/gui/dialogs/fgfscopilot/jet

with the word "unspecified", enclosed in single quotes, sitting next to at least two of those values. I mean, it's not EXACTLY like the way it appears in the XML file as I have pasted it here, but it has all the same contents.

So, if you or any others have any ideas as to exactly what I've done wrong, and how to fix it, that would help.

Btw, sorry for not being specific last time. My mind was whirling all over this thing so bad, I couldn't even figure out exactly what I wanted to ask. It's been too long since I've last done this that I'm just not settled into my system for thinking in code and making it work. Well, I don't actually think in code... just have weird dreams about floating around in some weird space filled with my latest programming project code swirling around me, and debugging itself... sometimes. Obviously, not a phenomenon that I primarily depend on, but pretty handy nonetheless :mrgreen:

EDIT: If you're wondering about the new topic name, I've decided that, since work has veered off the path of what I had envisioned with Hybrid, I should change the title to make sure it's obvious that I am now working on the full integration version, which I have named: Integra (It's just "integration", truncated, and it sounds cool 8) ).
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3630
Joined: Mon Feb 02, 2009 2:17 am
Location: Pennsylvania, USA
Version: 240

Re: FGFSCopilot Hybrid

Postby Hooray » Fri Nov 16, 2012 3:41 am

I cannot currently test any of this. However, are you sure that your "ac" variable is available to your binding at all ?
That would actually be the first thing I'd check. Just add some debugging code to your binding to print out the type (typeof()) and value of the variable and you'll probably see that that's exactly the problem here, i.e. you are trying to access an object that's not available in your binding like this.
In case of doubt, always try to understand the error message - and then add tons of "print" statements to your code to see where something stops working properly.

Just a wild guess, cannot test it at the moment, but that's my first thought after looking at your code....
And if I'm totally off here, I'm sure that Philosopher & manab will chime in and actually test your code to see what's wrong :-)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: FGFSCopilot Integra

Postby Philosopher » Fri Nov 16, 2012 4:22 am

redneck wrote in Fri Nov 16, 2012 3:09 am:Idk how, but sometimes, when I just stop trying, and I'm off doing something else, it just clicks in one massive "Aha!" moment.

They're called moments of insight and they happen most often when a person is relaxed, see the book "Imagine" for more info ;).

Anyways, the error message is saying that "ac" is not a hash. Now I have no idea why, your code looks fine to me (other than what I think is an extraneous 'm.element = elements[0];'). That said, why the for loop in Group.set that loops through me.elements? All you're going to do is to set the property recursively... And what is elements for? initializing properties? being a list of states for "/fgfscopilot/settings/" ~ me.name? 

Hooray is completely correct about typeof(), debug.dump() also works wonderfully here. Also, get out your friend the property browser and see what happens to /fgfscopilot/settings/aircraft when you click the button.

Also regarding whether 'ac' is available to the binding, that means that the first snippet needs to be from the <open> of the dialog and the binding in the dialog proper (which I assume it is). Otherwise, you'll need to figure out namespaces to access that variable.

Thanks,
Philosopher (the 3rd or 4th nasal developer... from the end ;))

P.S. Welcome back, even though I didn't know you. I wish you all the luck with RL
P.P.S. I started this post before Hooray finished his... I do appreciate the mention ;D. And actually, ditto on the "I cannot test this", so take my post with a grain of salt.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Next

Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest